GroupsController.cs 1002 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using Microsoft.AspNetCore.SignalR;
  7. using Microsoft.EntityFrameworkCore.Query.Internal;
  8. using NPOI.HSSF.UserModel;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.UserModel;
  11. using NPOI.SS.Util;
  12. using NPOI.XSSF.UserModel;
  13. using OASystem.API.Middlewares;
  14. using OASystem.API.OAMethodLib;
  15. using OASystem.API.OAMethodLib.APNs;
  16. using OASystem.API.OAMethodLib.File;
  17. using OASystem.API.OAMethodLib.Hub.HubClients;
  18. using OASystem.API.OAMethodLib.Hub.Hubs;
  19. using OASystem.API.OAMethodLib.JuHeAPI;
  20. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  21. using OASystem.Domain.AesEncryption;
  22. using OASystem.Domain.Dtos.CRM;
  23. using OASystem.Domain.Dtos.FileDto;
  24. using OASystem.Domain.Dtos.Financial;
  25. using OASystem.Domain.Dtos.Groups;
  26. using OASystem.Domain.Entities.Customer;
  27. using OASystem.Domain.Entities.Financial;
  28. using OASystem.Domain.Entities.Groups;
  29. using OASystem.Domain.ViewModels.Financial;
  30. using OASystem.Domain.ViewModels.Groups;
  31. using OASystem.Infrastructure.Repositories.CRM;
  32. using OASystem.Infrastructure.Repositories.Financial;
  33. using OASystem.Infrastructure.Repositories.Groups;
  34. using OfficeOpenXml;
  35. using Org.BouncyCastle.Asn1.Ocsp;
  36. using Org.BouncyCastle.Utilities.Encoders;
  37. using Quartz.Util;
  38. using SqlSugar.Extensions;
  39. using System.Collections;
  40. using System.Data;
  41. using System.Diagnostics;
  42. using System.Globalization;
  43. using System.IO.Compression;
  44. using static OASystem.API.OAMethodLib.JWTHelper;
  45. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  46. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  47. using Bookmark = Aspose.Words.Bookmark;
  48. using Cell = Aspose.Words.Tables.Cell;
  49. using Table = Aspose.Words.Tables.Table;
  50. namespace OASystem.API.Controllers
  51. {
  52. /// <summary>
  53. /// 团组相关
  54. /// </summary>
  55. //[Authorize]
  56. [Route("api/[controller]/[action]")]
  57. public class GroupsController : ControllerBase
  58. {
  59. private readonly ILogger<GroupsController> _logger;
  60. private readonly GrpScheduleRepository _grpScheduleRep;
  61. private readonly IMapper _mapper;
  62. private readonly DelegationInfoRepository _groupRepository;
  63. private readonly TaskAssignmentRepository _taskAssignmentRep;
  64. private readonly AirTicketResRepository _airTicketResRep;
  65. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  66. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  67. private readonly DelegationEnDataRepository _delegationEnDataRep;
  68. private readonly DelegationVisaRepository _delegationVisaRep;
  69. private readonly VisaPriceRepository _visaPriceRep;
  70. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  71. private readonly HotelPriceRepository _hotelPriceRep;
  72. private readonly CustomersRepository _customersRep;
  73. private readonly MessageRepository _message;
  74. private readonly SqlSugarClient _sqlSugar;
  75. private readonly TourClientListRepository _tourClientListRep;
  76. private readonly TeamRateRepository _teamRateRep;
  77. #region 成本相关
  78. private readonly CheckBoxsRepository _checkBoxs;
  79. private readonly GroupCostRepository _GroupCostRepository;
  80. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  81. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  82. #endregion
  83. private readonly SetDataRepository _setDataRep;
  84. private string url;
  85. private string path;
  86. private readonly EnterExitCostRepository _enterExitCostRep;
  87. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  88. private readonly UsersRepository _usersRep;
  89. private readonly IJuHeApiService _juHeApi;
  90. private readonly InvertedListRepository _invertedListRep;
  91. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  92. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  93. private readonly ThreeCodeRepository _threeCodeRepository;
  94. private readonly HotelInquiryRepository _hotelInquiryRep;
  95. private readonly FeeAuditRepository _feeAuditRep;
  96. private readonly VisaCommissionRepository _visaCommissionRep;
  97. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  98. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  99. private readonly List<CurrencyInfo> _currencyInit;
  100. private readonly List<int> _portTypeData;
  101. private readonly TableOperationRecordRepository _tableorRep;
  102. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  103. private readonly RestaurantRepository _restaurantRep;
  104. /// <summary>
  105. /// 构造函数
  106. /// </summary>
  107. /// <param name="logger"></param>
  108. /// <param name="mapper"></param>
  109. /// <param name="hubContext"></param>
  110. /// <param name="sqlSugar"></param>
  111. /// <param name="grpScheduleRep"></param>
  112. /// <param name="groupRepository"></param>
  113. /// <param name="taskAssignmentRep"></param>
  114. /// <param name="airTicketResRep"></param>
  115. /// <param name="decreasePaymentsRep"></param>
  116. /// <param name="InvitationOfficialActivitiesRep"></param>
  117. /// <param name="delegationEnDataRep"></param>
  118. /// <param name="enterExitCostRep"></param>
  119. /// <param name="delegationVisaRep"></param>
  120. /// <param name="message"></param>
  121. /// <param name="visaPriceRep"></param>
  122. /// <param name="carTouristGuideGroundRep"></param>
  123. /// <param name="checkBoxs"></param>
  124. /// <param name="GroupCostRepository"></param>
  125. /// <param name="CostTypeHotelNumberRepository"></param>
  126. /// <param name="GroupCostParameterRepository"></param>
  127. /// <param name="hotelPriceRep"></param>
  128. /// <param name="customersRep"></param>
  129. /// <param name="setDataRep"></param>
  130. /// <param name="tourClientListRep"></param>
  131. /// <param name="teamRateRep"></param>
  132. /// <param name="usersRep"></param>
  133. /// <param name="juHeApi"></param>
  134. /// <param name="invertedListRep"></param>
  135. /// <param name="visaFeeInfoRep"></param>
  136. /// <param name="ticketBlackCodeRep"></param>
  137. /// <param name="hotelInquiryRep"></param>
  138. /// <param name="threeCodeRepository"></param>
  139. /// <param name="feeAuditRep"></param>
  140. /// <param name="visaCommissionRep"></param>
  141. /// <param name="ffrRep"></param>
  142. /// <param name="opinionaireRep"></param>
  143. /// <param name="tableorRep"></param>
  144. /// <param name="enterExitCostDraftRep"></param>
  145. /// <param name="restaurantRep"></param>
  146. public GroupsController(
  147. ILogger<GroupsController> logger,
  148. IMapper mapper,
  149. IHubContext<ChatHub, IChatClient> hubContext,
  150. SqlSugarClient sqlSugar,
  151. GrpScheduleRepository grpScheduleRep,
  152. DelegationInfoRepository groupRepository,
  153. TaskAssignmentRepository taskAssignmentRep,
  154. AirTicketResRepository airTicketResRep,
  155. DecreasePaymentsRepository decreasePaymentsRep,
  156. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  157. DelegationEnDataRepository delegationEnDataRep,
  158. EnterExitCostRepository enterExitCostRep,
  159. DelegationVisaRepository delegationVisaRep,
  160. MessageRepository message,
  161. VisaPriceRepository visaPriceRep,
  162. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  163. CheckBoxsRepository checkBoxs,
  164. GroupCostRepository GroupCostRepository,
  165. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  166. GroupCostParameterRepository GroupCostParameterRepository,
  167. HotelPriceRepository hotelPriceRep,
  168. CustomersRepository customersRep,
  169. SetDataRepository setDataRep,
  170. TourClientListRepository tourClientListRep,
  171. TeamRateRepository teamRateRep,
  172. UsersRepository usersRep, IJuHeApiService juHeApi,
  173. InvertedListRepository invertedListRep,
  174. VisaFeeInfoRepository visaFeeInfoRep,
  175. TicketBlackCodeRepository ticketBlackCodeRep,
  176. HotelInquiryRepository hotelInquiryRep,
  177. ThreeCodeRepository threeCodeRepository,
  178. FeeAuditRepository feeAuditRep,
  179. VisaCommissionRepository visaCommissionRep,
  180. ForeignReceivablesRepository ffrRep,
  181. OpinionaireRepository opinionaireRep,
  182. TableOperationRecordRepository tableorRep,
  183. EnterExitCostDraftRepository enterExitCostDraftRep,
  184. RestaurantRepository restaurantRep
  185. )
  186. {
  187. _logger = logger;
  188. _mapper = mapper;
  189. _grpScheduleRep = grpScheduleRep;
  190. _groupRepository = groupRepository;
  191. _taskAssignmentRep = taskAssignmentRep;
  192. _airTicketResRep = airTicketResRep;
  193. _sqlSugar = sqlSugar;
  194. url = AppSettingsHelper.Get("ExcelBaseUrl");
  195. path = AppSettingsHelper.Get("ExcelBasePath");
  196. if (!System.IO.Directory.Exists(path))
  197. {
  198. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  199. }
  200. _decreasePaymentsRep = decreasePaymentsRep;
  201. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  202. _delegationEnDataRep = delegationEnDataRep;
  203. _enterExitCostRep = enterExitCostRep;
  204. _delegationVisaRep = delegationVisaRep;
  205. _message = message;
  206. _visaPriceRep = visaPriceRep;
  207. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  208. _checkBoxs = checkBoxs;
  209. _GroupCostRepository = GroupCostRepository;
  210. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  211. _GroupCostParameterRepository = GroupCostParameterRepository;
  212. _hotelPriceRep = hotelPriceRep;
  213. _customersRep = customersRep;
  214. _setDataRep = setDataRep;
  215. _tourClientListRep = tourClientListRep;
  216. _teamRateRep = teamRateRep;
  217. _hubContext = hubContext;
  218. _usersRep = usersRep;
  219. _juHeApi = juHeApi;
  220. _invertedListRep = invertedListRep;
  221. _visaFeeInfoRep = visaFeeInfoRep;
  222. _ticketBlackCodeRep = ticketBlackCodeRep;
  223. _hotelInquiryRep = hotelInquiryRep;
  224. _threeCodeRepository = threeCodeRepository;
  225. _feeAuditRep = feeAuditRep;
  226. _visaCommissionRep = visaCommissionRep;
  227. _ffrRep = ffrRep;
  228. _opinionaireRep = opinionaireRep;
  229. _currencyInit = new List<CurrencyInfo>()
  230. {
  231. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  232. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  233. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  234. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  235. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  236. };
  237. _portTypeData = new List<int>() { 2, 3 };
  238. _tableorRep = tableorRep;
  239. _enterExitCostDraftRep = enterExitCostDraftRep;
  240. _restaurantRep = restaurantRep;
  241. }
  242. #region 流程管控
  243. /// <summary>
  244. /// 获取团组流程管控信息
  245. /// </summary>
  246. /// <param name="paras">参数Json字符串</param>
  247. /// <returns></returns>
  248. [HttpPost]
  249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  250. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  251. {
  252. if (string.IsNullOrEmpty(_jsonDto.Paras))
  253. {
  254. return Ok(JsonView(false, "参数为空"));
  255. }
  256. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  257. if (_ScheduleDto != null)
  258. {
  259. if (_ScheduleDto.SearchType == 2)//获取列表
  260. {
  261. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  262. return Ok(JsonView(_grpScheduleViewList));
  263. }
  264. else//获取对象
  265. {
  266. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  267. if (_grpScheduleView != null)
  268. {
  269. return Ok(JsonView(_grpScheduleView));
  270. }
  271. }
  272. }
  273. else
  274. {
  275. return Ok(JsonView(false, "参数反序列化失败"));
  276. }
  277. return Ok(JsonView(false, "暂无数据!"));
  278. }
  279. /// <summary>
  280. /// 修改团组流程管控详细表数据
  281. /// </summary>
  282. /// <param name="paras"></param>
  283. /// <returns></returns>
  284. [HttpPost]
  285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  286. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  287. {
  288. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  289. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  290. .SetColumns(it => it.Duty == _detail.Duty)
  291. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  292. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  293. .SetColumns(it => it.JobContent == _detail.JobContent)
  294. .SetColumns(it => it.Remark == _detail.Remark)
  295. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  296. .Where(s => s.Id == dto.Id)
  297. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  298. .ExecuteCommandAsync();
  299. if (result > 0)
  300. {
  301. return Ok(JsonView(true, "保存成功!"));
  302. }
  303. return Ok(JsonView(false, "保存失败!"));
  304. }
  305. /// <summary>
  306. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  307. /// </summary>
  308. /// <param name="dto"></param>
  309. /// <returns></returns>
  310. [HttpPost]
  311. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  312. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  313. {
  314. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  315. _detail.IsDel = 1;
  316. _detail.DeleteUserId = dto.Duty;
  317. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  318. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  319. .SetColumns(it => it.IsDel == _detail.IsDel)
  320. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  321. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  322. .Where(it => it.Id == dto.Id)
  323. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  324. //.WhereColumns(s => s.Id == dto.Id)
  325. .ExecuteCommandAsync();
  326. if (result > 0)
  327. {
  328. return Ok(JsonView(true, "删除成功!"));
  329. }
  330. return Ok(JsonView(false, "删除失败!"));
  331. }
  332. /// <summary>
  333. /// 增加团组流程管控详细表数据
  334. /// </summary>
  335. /// <param name="dto"></param>
  336. /// <returns></returns>
  337. [HttpPost]
  338. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  339. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  340. {
  341. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  342. if (DateTime.Now < _detail.ExpectBeginDt)
  343. {
  344. _detail.StepStatus = 0;
  345. }
  346. else
  347. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  348. _detail.StepStatus = 1;
  349. }
  350. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  351. if (result > 0)
  352. {
  353. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  354. return Ok(JsonView(true, "添加成功!", _result));
  355. }
  356. return Ok(JsonView(false, "添加失败!"));
  357. }
  358. #endregion
  359. #region 团组基本信息
  360. /// <summary>
  361. /// 接团信息列表
  362. /// </summary>
  363. /// <param name="dto">团组列表请求dto</param>
  364. /// <returns></returns>
  365. [HttpPost]
  366. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  367. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  368. {
  369. var groupData = await _groupRepository.GetGroupList(dto);
  370. if (groupData.Code != 0)
  371. {
  372. return Ok(JsonView(false, groupData.Msg));
  373. }
  374. return Ok(JsonView(groupData.Data));
  375. }
  376. /// <summary>
  377. /// 分页查询团组列表
  378. /// </summary>
  379. /// <param name="dto"></param>
  380. /// <returns></returns>
  381. [HttpPost]
  382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  383. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  384. {
  385. var watch = new Stopwatch();
  386. watch.Start();
  387. RefAsync<int> total = 0;
  388. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  389. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  390. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  391. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  392. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  393. .Distinct()
  394. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  395. watch.Stop();
  396. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  397. }
  398. /// <summary>
  399. /// 接团信息列表 Page Init
  400. /// </summary>
  401. /// <returns></returns>
  402. [HttpPost]
  403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  404. public async Task<IActionResult> PostGroupPageListInit()
  405. {
  406. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  407. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  408. rankDatas.Insert(0, new { Id=0, Name ="全部" });
  409. var _view = new
  410. {
  411. depData = depDatas,
  412. rankData = rankDatas
  413. };
  414. return Ok(JsonView(true, "查询成功!", _view));
  415. }
  416. /// <summary>
  417. /// 接团信息列表 Page
  418. /// </summary>
  419. /// <param name="dto">团组列表请求dto</param>
  420. /// <returns></returns>
  421. [HttpPost]
  422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  423. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  424. {
  425. #region 参数验证
  426. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  427. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  428. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  429. #region 页面操作权限验证
  430. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  431. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  432. #endregion
  433. #endregion
  434. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  435. {
  436. string sqlWhere = string.Empty;
  437. if (dto.IsSure == 0) //未完成
  438. {
  439. sqlWhere += string.Format(@" And IsSure = 0");
  440. }
  441. else if (dto.IsSure == 1) //已完成
  442. {
  443. sqlWhere += string.Format(@" And IsSure = 1");
  444. }
  445. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  446. {
  447. string tj = dto.SearchCriteria;
  448. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  449. tj, tj, tj, tj, tj);
  450. }
  451. if (int.TryParse(dto.Rank,out int rankId))
  452. {
  453. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  454. }
  455. string sqlWhere1 = string.Empty;
  456. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  457. {
  458. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  459. }
  460. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  461. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  462. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  463. JietuanOperator,IsSure,CreateTime,IsBid
  464. From (
  465. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  466. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  467. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  468. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  469. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  470. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  471. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  472. From Grp_DelegationInfo gdi
  473. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  474. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  475. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  476. Where gdi.IsDel = 0 {0}
  477. ) temp {1}", sqlWhere, sqlWhere1);
  478. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  479. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  480. var _view = new
  481. {
  482. PageFuncAuth = pageFunAuthView,
  483. Data = _DelegationList
  484. };
  485. return Ok(JsonView(true, "查询成功!", _view, total));
  486. }
  487. else
  488. {
  489. return Ok(JsonView(false, "查询失败"));
  490. }
  491. }
  492. /// <summary>
  493. /// 团组列表
  494. /// </summary>
  495. /// <returns></returns>
  496. [HttpPost]
  497. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  498. {
  499. #region 参数验证
  500. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  501. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  502. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  503. #region 页面操作权限验证
  504. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  505. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  506. #endregion
  507. #endregion
  508. if (dto.PortType != 1 && dto.PortType != 2)
  509. {
  510. return Ok(JsonView(false, "查询失败!"));
  511. }
  512. string orderbyStr = "order by gdi.CreateTime Desc";
  513. string sqlWhere = string.Empty;
  514. if (dto.IsSure == 0) //未完成
  515. {
  516. sqlWhere += string.Format(@" And IsSure = 0");
  517. }
  518. else if (dto.IsSure == 1) //已完成
  519. {
  520. sqlWhere += string.Format(@" And IsSure = 1");
  521. }
  522. //团组类型
  523. if (dto.TeamDid > 0)
  524. {
  525. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  526. }
  527. //团组名称
  528. if (!string.IsNullOrEmpty(dto.TeamName))
  529. {
  530. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  531. }
  532. //客户名称
  533. if (!string.IsNullOrEmpty(dto.ClientName))
  534. {
  535. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  536. }
  537. //客户单位
  538. if (!string.IsNullOrEmpty(dto.ClientUnit))
  539. {
  540. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  541. }
  542. //出访时间
  543. if (!string.IsNullOrEmpty(dto.visitDataTime))
  544. {
  545. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  546. orderbyStr = "order by gdi.VisitDate";
  547. }
  548. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  549. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  550. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  551. JietuanOperator,IsSure,CreateTime
  552. From (
  553. Select row_number() over({0}) as Row_Number,
  554. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  555. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  556. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  557. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  558. From Grp_DelegationInfo gdi
  559. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  560. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  561. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  562. Where gdi.IsDel = 0 {1}
  563. ) temp ", orderbyStr, sqlWhere);
  564. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  565. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  566. #region 处理所属部门
  567. /*
  568. * 1.sq 和 gyy 等显示 市场部
  569. * 2.王鸽和主管及张总还有管理员号统一国交部
  570. * 2-1. 4 管理员 ,21 张海麟
  571. */
  572. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  573. List<int> userIds1 = new List<int>() { 4, 21 };
  574. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  575. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  576. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  577. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  578. .ToList();
  579. foreach (var item in _DelegationList)
  580. {
  581. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  582. }
  583. #endregion
  584. var _view = new
  585. {
  586. PageFuncAuth = pageFunAuthView,
  587. Data = _DelegationList
  588. };
  589. return Ok(JsonView(true, "查询成功!", _view, total));
  590. }
  591. /// <summary>
  592. /// 接团信息详情
  593. /// </summary>
  594. /// <param name="dto">团组info请求dto</param>
  595. /// <returns></returns>
  596. [HttpPost]
  597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  598. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  599. {
  600. var groupData = await _groupRepository.GetGroupInfo(dto);
  601. if (groupData.Code != 0)
  602. {
  603. return Ok(JsonView(false, groupData.Msg));
  604. }
  605. return Ok(JsonView(groupData.Data));
  606. }
  607. /// <summary>
  608. /// 接团信息 编辑添加
  609. /// 基础信息数据源
  610. /// </summary>
  611. /// <param name="dto"></param>
  612. /// <returns></returns>
  613. [HttpPost]
  614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  615. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  616. {
  617. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  618. if (groupData.Code != 0)
  619. {
  620. return Ok(JsonView(false, groupData.Msg));
  621. }
  622. return Ok(JsonView(groupData.Data));
  623. }
  624. /// <summary>
  625. /// 接团信息 操作(增改)
  626. /// </summary>
  627. /// <param name="dto"></param>
  628. /// <returns></returns>
  629. [HttpPost]
  630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  631. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  632. {
  633. // 创建 Stopwatch 实例
  634. Stopwatch stopwatch = Stopwatch.StartNew();
  635. decimal ffrPrice = 0.00M;
  636. DateTime? visitDt = null;
  637. if (dto.Status == 2)
  638. {
  639. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  640. if (groupInfo != null)
  641. {
  642. ffrPrice = groupInfo.PaymentMoney;
  643. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  644. }
  645. }
  646. var groupData = await _groupRepository.GroupOperation(dto);
  647. if (groupData.Code != 0)
  648. {
  649. return Ok(JsonView(false, groupData.Msg));
  650. }
  651. int diId = 0;
  652. try
  653. {
  654. //添加时 默认加入团组汇率
  655. if (dto.Status == 1) //添加
  656. {
  657. diId = groupData.Data;
  658. //添加默认币种
  659. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  660. //默认分配权限
  661. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  662. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  663. var _managerIds = new List<int>() { 22, 32, 21 };
  664. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  665. if (userIds.Count > 0)
  666. {
  667. userIds.Add(208);
  668. //创建团组管控
  669. GroupStepForDelegation.CreateWorkStep(diId);
  670. //发送消息
  671. string groupName = dto.TeamName;
  672. string createGroupUser = string.Empty;
  673. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  674. if (userInfo != null) createGroupUser = userInfo.CnName;
  675. string title = $"系统通知";
  676. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  677. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  678. }
  679. //默认创建倒推表
  680. await _invertedListRep._Create(dto.UserId, diId);
  681. }
  682. else if (dto.Status == 2)
  683. {
  684. diId = dto.Id;
  685. }
  686. #region 签证人员团组时间通知
  687. #region 计算出访起止时间
  688. var startTime = new DateTime();
  689. var endTime = new DateTime();
  690. if (DateTime.TryParse(dto.VisitDate, out startTime))
  691. {
  692. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  693. }
  694. #endregion
  695. #endregion
  696. #region 团组操作默认添加/修改收款账单
  697. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  698. {
  699. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  700. .Where(x => x.IsDel == 0 &&
  701. x.Diid == diId &&
  702. x.Remark.Equals("预付款")
  703. )
  704. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  705. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  706. .FirstAsync();
  707. ffrInfo = new Fin_ForeignReceivables()
  708. {
  709. Diid = diId,
  710. PriceName = dto.ClientUnit,
  711. Price = dto.PaymentMoney,
  712. Count = 1,
  713. Unit = $"元",
  714. ItemSumPrice = dto.PaymentMoney,
  715. Rate = 1.0000M,
  716. Currency = 836,
  717. AddingWay = 0,
  718. CreateUserId = dto.UserId,
  719. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  720. Remark = $"预付款"
  721. };
  722. if (ffrInfo == null) //Add
  723. {
  724. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  725. }
  726. else //修改
  727. {
  728. await _sqlSugar.Updateable(ffrInfo)
  729. .UpdateColumns(x => new
  730. {
  731. x.PriceName,
  732. x.Price,
  733. x.ItemSumPrice,
  734. x.CreateTime,
  735. x.CreateUserId
  736. })
  737. .WhereColumns(x => x.Id)
  738. .ExecuteCommandAsync();
  739. }
  740. }
  741. #endregion
  742. if (diId > 0)
  743. {
  744. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  745. }
  746. // 停止计时
  747. stopwatch.Stop();
  748. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  749. }
  750. catch (Exception ex)
  751. {
  752. // 停止计时
  753. stopwatch.Stop();
  754. Logs("[response]" + JsonConvert.SerializeObject(dto));
  755. Logs(ex.Message);
  756. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  757. }
  758. // 停止计时
  759. stopwatch.Stop();
  760. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  761. }
  762. /// <summary>
  763. /// 接团流程操作(增改)
  764. /// 安卓端使用 建团时添加客户名单
  765. /// </summary>
  766. /// <param name="dto"></param>
  767. /// <returns></returns>
  768. [HttpPost]
  769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  770. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  771. {
  772. #region 参数验证
  773. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  774. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  775. #region 页面操作权限验证
  776. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  777. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  778. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  779. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  780. #endregion
  781. #endregion
  782. try
  783. {
  784. //_sqlSugar.BeginTran();
  785. decimal ffrPrice = 0.00M;
  786. DateTime? visitDt = null;
  787. if (dto.Status == 2)
  788. {
  789. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  790. if (groupInfo != null)
  791. {
  792. ffrPrice = groupInfo.PaymentMoney;
  793. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  794. }
  795. }
  796. var _dto = new GroupOperationDto();
  797. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  798. var groupData = await _groupRepository.GroupOperation(_dto);
  799. if (groupData.Code != 0)
  800. {
  801. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  802. }
  803. int diId = 0;
  804. //添加时 默认加入团组汇率
  805. if (dto.Status == 1) //添加
  806. {
  807. diId = groupData.Data;
  808. //添加默认币种
  809. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  810. //默认分配权限
  811. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  812. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  813. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  814. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  815. if (userIds.Count > 0)
  816. {
  817. userIds.Add(208);
  818. //创建团组管控
  819. GroupStepForDelegation.CreateWorkStep(diId);
  820. //发送消息
  821. string groupName = dto.TeamName;
  822. string createGroupUser = string.Empty;
  823. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  824. if (userInfo != null) createGroupUser = userInfo.CnName;
  825. string title = $"系统通知";
  826. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  827. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  828. }
  829. #region 应用推送
  830. try
  831. {
  832. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  833. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  834. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  835. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  836. {
  837. List<string> userList = new List<string>() { users.QiyeChatUserId };
  838. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  839. }
  840. }
  841. catch (Exception ex)
  842. {
  843. }
  844. #endregion
  845. //默认创建倒推表
  846. await _invertedListRep._Create(dto.UserId, diId);
  847. }
  848. if (dto.Status == 2)
  849. {
  850. diId = dto.Id;
  851. if (diId == 0)
  852. {
  853. //_sqlSugar.RollbackTran();
  854. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  855. }
  856. }
  857. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  858. if (viewData.Code != 0)
  859. {
  860. //_sqlSugar.RollbackTran();
  861. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  862. }
  863. #region 团组操作默认添加/修改收款账单
  864. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  865. {
  866. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  867. .Where(x => x.IsDel == 0 &&
  868. x.Diid == diId &&
  869. x.Remark.Equals("预付款")
  870. )
  871. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  872. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  873. .FirstAsync();
  874. ffrInfo = new Fin_ForeignReceivables()
  875. {
  876. Diid = diId,
  877. PriceName = dto.ClientUnit,
  878. Price = dto.PaymentMoney,
  879. Count = 1,
  880. Unit = $"元",
  881. ItemSumPrice = dto.PaymentMoney,
  882. Rate = 1.0000M,
  883. Currency = 836,
  884. AddingWay = 0,
  885. CreateUserId = dto.UserId,
  886. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  887. Remark = $"预付款"
  888. };
  889. if (ffrInfo == null) //Add
  890. {
  891. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  892. }
  893. else //修改
  894. {
  895. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  896. .UpdateColumns(x => new
  897. {
  898. x.PriceName,
  899. x.Price,
  900. x.ItemSumPrice,
  901. x.CreateTime,
  902. x.CreateUserId
  903. })
  904. .WhereColumns(x => x.Id)
  905. .ExecuteCommandAsync();
  906. }
  907. }
  908. #endregion
  909. #region 签证人员团组时间通知
  910. #region 计算出访起止时间
  911. var startTime = new DateTime();
  912. var endTime = new DateTime();
  913. if (DateTime.TryParse(dto.VisitDate, out startTime))
  914. {
  915. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  916. }
  917. #endregion
  918. if (diId > 0)
  919. {
  920. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  921. }
  922. #endregion
  923. //_sqlSugar.CommitTran();
  924. return Ok(JsonView(true, "添加成功"));
  925. }
  926. catch (Exception ex)
  927. {
  928. _sqlSugar.RollbackTran();
  929. return Ok(JsonView(false, ex.Message));
  930. }
  931. }
  932. /// <summary>
  933. /// 接团流程操作(增改)
  934. /// 安卓端使用 建团时添加客户名单
  935. /// </summary>
  936. /// <param name="dto"></param>
  937. /// <returns></returns>
  938. [HttpPost]
  939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  940. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  941. {
  942. #region 参数验证
  943. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  944. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  945. #region 页面操作权限验证
  946. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  947. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  948. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  949. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  950. #endregion
  951. #endregion
  952. _sqlSugar.BeginTran();
  953. decimal ffrPrice = 0.00M;
  954. DateTime? visitDt = null;
  955. if (dto.Status == 2)
  956. {
  957. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  958. if (groupInfo != null)
  959. {
  960. ffrPrice = groupInfo.PaymentMoney;
  961. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  962. }
  963. }
  964. var _dto = new GroupOperationDto();
  965. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  966. var groupData = await _groupRepository.GroupOperation(_dto);
  967. if (groupData.Code != 0)
  968. {
  969. _sqlSugar.RollbackTran();
  970. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  971. }
  972. try
  973. {
  974. int diId = 0;
  975. //添加时 默认加入团组汇率
  976. if (dto.Status == 1) //添加
  977. {
  978. diId = groupData.Data;
  979. //添加默认币种
  980. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  981. //默认分配权限
  982. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  983. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  984. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  985. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  986. if (userIds.Count > 0)
  987. {
  988. userIds.Add(208);
  989. //创建团组管控
  990. GroupStepForDelegation.CreateWorkStep(diId);
  991. //发送消息
  992. string groupName = dto.TeamName;
  993. string createGroupUser = string.Empty;
  994. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  995. if (userInfo != null) createGroupUser = userInfo.CnName;
  996. string title = $"系统通知";
  997. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  998. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  999. }
  1000. #region 应用推送
  1001. try
  1002. {
  1003. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1004. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1005. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1006. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1007. {
  1008. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1009. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1010. }
  1011. }
  1012. catch (Exception ex)
  1013. {
  1014. _sqlSugar.CommitTran();
  1015. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1016. }
  1017. #endregion
  1018. //默认创建倒推表
  1019. await _invertedListRep._Create(dto.UserId, diId);
  1020. }
  1021. else if (dto.Status == 2)
  1022. {
  1023. diId = dto.Id;
  1024. if (diId == 0)
  1025. {
  1026. _sqlSugar.RollbackTran();
  1027. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1028. }
  1029. }
  1030. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1031. if (viewData.Code != 0)
  1032. {
  1033. _sqlSugar.RollbackTran();
  1034. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1035. }
  1036. #region 团组操作默认添加/修改收款账单
  1037. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1038. {
  1039. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1040. .Where(x => x.IsDel == 0 &&
  1041. x.Diid == diId &&
  1042. x.Remark.Equals("预付款")
  1043. )
  1044. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1045. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1046. .FirstAsync();
  1047. ffrInfo = new Fin_ForeignReceivables()
  1048. {
  1049. Diid = diId,
  1050. PriceName = dto.ClientUnit,
  1051. Price = dto.PaymentMoney,
  1052. Count = 1,
  1053. Unit = $"元",
  1054. ItemSumPrice = dto.PaymentMoney,
  1055. Rate = 1.0000M,
  1056. Currency = 836,
  1057. AddingWay = 0,
  1058. CreateUserId = dto.UserId,
  1059. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1060. Remark = $"预付款"
  1061. };
  1062. if (ffrInfo == null) //Add
  1063. {
  1064. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1065. }
  1066. else //修改
  1067. {
  1068. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1069. .UpdateColumns(x => new
  1070. {
  1071. x.PriceName,
  1072. x.Price,
  1073. x.ItemSumPrice,
  1074. x.CreateTime,
  1075. x.CreateUserId
  1076. })
  1077. .WhereColumns(x => x.Id)
  1078. .ExecuteCommandAsync();
  1079. }
  1080. }
  1081. #endregion
  1082. #region 签证人员团组时间通知
  1083. #region 计算出访起止时间
  1084. var startTime = new DateTime();
  1085. var endTime = new DateTime();
  1086. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1087. {
  1088. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1089. }
  1090. #endregion
  1091. if (diId > 0)
  1092. {
  1093. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1094. }
  1095. #endregion
  1096. _sqlSugar.CommitTran();
  1097. return Ok(JsonView(true));
  1098. }
  1099. catch (Exception ex)
  1100. {
  1101. _sqlSugar.RollbackTran();
  1102. return Ok(JsonView(false, ex.Message));
  1103. }
  1104. }
  1105. /// <summary>
  1106. /// 接团信息 操作(删除)
  1107. /// </summary>
  1108. /// <param name="dto"></param>
  1109. /// <returns></returns>
  1110. [HttpPost]
  1111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1112. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1113. {
  1114. var diId = dto.Id;
  1115. if (diId < 1) return Ok(JsonView(false,MsgTips.Id));
  1116. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1117. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1118. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1119. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1120. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1121. #endregion
  1122. var groupData = await _groupRepository.GroupDel(dto);
  1123. if (groupData.Code != 0)
  1124. {
  1125. return Ok(JsonView(false, groupData.Msg));
  1126. }
  1127. return Ok(JsonView(true));
  1128. }
  1129. /// <summary>
  1130. /// 获取团组销售报价号
  1131. /// 团组添加时 使用
  1132. /// </summary>
  1133. /// <returns></returns>
  1134. [HttpPost]
  1135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1136. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1137. {
  1138. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1139. if (groupData.Code != 0)
  1140. {
  1141. return Ok(JsonView(false, groupData.Msg));
  1142. }
  1143. object salesQuoteNo = new
  1144. {
  1145. SalesQuoteNo = groupData.Data
  1146. };
  1147. return Ok(JsonView(salesQuoteNo));
  1148. }
  1149. /// <summary>
  1150. /// 设置确认出团
  1151. /// </summary>
  1152. /// <param name="dto"></param>
  1153. /// <returns></returns>
  1154. [HttpPost]
  1155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1156. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1157. {
  1158. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1159. if (groupData.Code != 0)
  1160. {
  1161. return Ok(JsonView(false, groupData.Msg));
  1162. }
  1163. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1164. #region OA消息推送
  1165. try
  1166. {
  1167. string groupName = groupInfo.TeamName;
  1168. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1169. string title = $"系统通知";
  1170. string content = $"团组[{groupName}]已确认出团!";
  1171. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1172. }
  1173. catch (Exception ex)
  1174. {
  1175. }
  1176. #endregion
  1177. #region 应用推送
  1178. try
  1179. {
  1180. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1181. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1182. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1183. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1184. {
  1185. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1186. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1187. }
  1188. }
  1189. catch (Exception ex)
  1190. {
  1191. }
  1192. #endregion
  1193. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1194. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1195. }
  1196. /// <summary>
  1197. /// 获取团组名称data And 签证国别Data
  1198. /// </summary>
  1199. /// <param name="dto"></param>
  1200. /// <returns></returns>
  1201. [HttpPost]
  1202. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1203. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1204. {
  1205. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1206. if (groupData.Code != 0)
  1207. {
  1208. return Ok(JsonView(false, groupData.Msg));
  1209. }
  1210. return Ok(JsonView(groupData.Data));
  1211. }
  1212. /// <summary>
  1213. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1214. /// </summary>
  1215. /// <returns></returns>
  1216. [HttpPost]
  1217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1218. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1219. {
  1220. try
  1221. {
  1222. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1223. if (groupData.Code != 0)
  1224. {
  1225. return Ok(JsonView(false, groupData.Msg));
  1226. }
  1227. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1228. }
  1229. catch (Exception ex)
  1230. {
  1231. return Ok(JsonView(false, "程序错误!"));
  1232. throw;
  1233. }
  1234. }
  1235. /// <summary>
  1236. /// 团组清单 Excel
  1237. /// </summary>
  1238. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1239. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1240. /// <returns></returns>
  1241. [HttpGet]
  1242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1243. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1244. {
  1245. DateTime _beginDt, _endDt;
  1246. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1247. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1248. if (!beginBool && !endBool)
  1249. {
  1250. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1251. }
  1252. string sql = string.Format(@"
  1253. SELECT
  1254. ROW_NUMBER,
  1255. Id,
  1256. SalesQuoteNo,
  1257. TourCode,
  1258. TeamTypeId,
  1259. TeamType,
  1260. TeamLevId,
  1261. TeamLev,
  1262. TeamName,
  1263. ClientName,
  1264. ClientUnit,
  1265. VisitDate,
  1266. VisitDays,
  1267. VisitPNumber,
  1268. JietuanOperatorId,
  1269. JietuanOperator,
  1270. IsSure,
  1271. CreateUserName,
  1272. IsBid
  1273. FROM
  1274. (
  1275. SELECT
  1276. ROW_NUMBER() OVER(
  1277. ORDER BY
  1278. gdi.CreateTime Desc
  1279. ) AS ROW_NUMBER,
  1280. gdi.Id,
  1281. SalesQuoteNo,
  1282. TourCode,
  1283. ssd.Id TeamTypeId,
  1284. ssd.Name TeamType,
  1285. ssd1.Id TeamLevId,
  1286. ssd1.Name TeamLev,
  1287. TeamName,
  1288. ClientName,
  1289. ClientUnit,
  1290. VisitDate,
  1291. VisitDays,
  1292. VisitPNumber,
  1293. JietuanOperator JietuanOperatorId,
  1294. su.CnName JietuanOperator,
  1295. IsSure,
  1296. gdi.CreateTime,
  1297. su1.CnName As CreateUserName,
  1298. gdi.IsBid
  1299. FROM
  1300. Grp_DelegationInfo gdi
  1301. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1302. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1303. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1304. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1305. WHERE
  1306. gdi.IsDel = 0
  1307. AND gdi.IsBid = 0
  1308. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1309. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1310. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1311. #region 处理所属部门
  1312. /*
  1313. * 1.sq 和 gyy 等显示 市场部
  1314. * 2.王鸽和主管及张总还有管理员号统一国交部
  1315. * 2-1. 4 管理员 ,21 张海麟
  1316. */
  1317. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1318. List<int> userIds1 = new List<int>() { 4, 21 };
  1319. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1320. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1321. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1322. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1323. .ToListAsync();
  1324. var droupIds = groupList.Select(it => it.Id).ToList();
  1325. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1326. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1327. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1328. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1329. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1330. {
  1331. DiId = tcl.DiId,
  1332. LastName = dc.LastName,
  1333. FirstName = dc.FirstName,
  1334. Sex = dc.Sex,
  1335. Birthday = dc.BirthDay,
  1336. Company = cc.CompanyFullName,
  1337. Job = dc.Job,
  1338. CreateTime = tcl.CreateTime,
  1339. })
  1340. .ToList();
  1341. foreach (var item in groupList)
  1342. {
  1343. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1344. string groupFirstName = "";
  1345. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1346. if (currDatas.Any())
  1347. {
  1348. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1349. }
  1350. item.GroupFirst = groupFirstName;
  1351. }
  1352. #endregion
  1353. #region Excel
  1354. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1355. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1356. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1357. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1358. var fileName = $"团组清单({beginDt}{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1359. //载入模板
  1360. WorkbookDesigner designer = new WorkbookDesigner();
  1361. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1362. designer.SetDataSource("Titel", $"团组清单({beginDt}{endDt})");
  1363. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1364. dt.TableName = "GroupList";
  1365. designer.SetDataSource(dt);
  1366. designer.Process();
  1367. if (!Directory.Exists(savePath))
  1368. {
  1369. Directory.CreateDirectory(savePath);
  1370. }
  1371. string serverPath = $"{savePath}{fileName}";
  1372. designer.Workbook.Save(serverPath);
  1373. string rst = $"{servicePath}{ftpPath}{fileName}";
  1374. #endregion
  1375. return Ok(JsonView(true, "操作成功!", rst));
  1376. }
  1377. #endregion
  1378. #region 团组&签证
  1379. /// <summary>
  1380. /// 根据团组Id获取签证客户信息List
  1381. /// </summary>
  1382. /// <param name="dto">请求dto</param>
  1383. /// <returns></returns>
  1384. [HttpPost]
  1385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1386. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1387. {
  1388. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1389. if (groupData.Code != 0)
  1390. {
  1391. return Ok(JsonView(false, groupData.Msg));
  1392. }
  1393. return Ok(JsonView(groupData.Data));
  1394. }
  1395. /// <summary>
  1396. /// IOS获取团组签证拍照上传进度01(团组列表)
  1397. /// </summary>
  1398. /// <param name="dto">请求dto</param>
  1399. /// <returns></returns>
  1400. [HttpPost]
  1401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1402. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1403. {
  1404. if (dto == null)
  1405. {
  1406. return Ok(JsonView(false, "参数为空"));
  1407. }
  1408. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1409. return Ok(JsonView(visaList));
  1410. }
  1411. /// <summary>
  1412. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1413. /// </summary>
  1414. /// <returns></returns>
  1415. [HttpPost]
  1416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1417. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1418. {
  1419. if (dto == null)
  1420. {
  1421. return Ok(JsonView(false, "请求错误:"));
  1422. }
  1423. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1424. return Ok(JsonView(list));
  1425. }
  1426. /// <summary>
  1427. /// IOS获取团组签证拍照上传进度03(相册)
  1428. /// </summary>
  1429. /// <returns></returns>
  1430. [HttpPost]
  1431. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1432. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1433. {
  1434. if (dto == null)
  1435. {
  1436. return Ok(JsonView(false, "请求错误:"));
  1437. }
  1438. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1439. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1440. list.ForEach(s => s.url = url);
  1441. return Ok(JsonView(list));
  1442. }
  1443. /// <summary>
  1444. /// IOS获取团组签证拍照上传进度04(图片上传)
  1445. /// </summary>
  1446. /// <param name="dto"></param>
  1447. /// <returns></returns>
  1448. [HttpPost]
  1449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1450. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1451. {
  1452. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1453. //if (!string.IsNullOrEmpty(result))
  1454. //{
  1455. //}
  1456. //else {
  1457. // return Ok(JsonView(false, "上传失败"));
  1458. //}
  1459. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1460. int sucNum = 0;
  1461. try
  1462. {
  1463. foreach (var item in dto.base64DataList)
  1464. {
  1465. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1466. string result = decodeBase64ToImage(item, imageName);
  1467. if (!string.IsNullOrEmpty(result))
  1468. {
  1469. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1470. pic.CreateUserId = dto.CreateUserId;
  1471. pic.PicName = imageName;
  1472. pic.PicPath = result;
  1473. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1474. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1475. if (insertResult > 0)
  1476. {
  1477. sucNum++;
  1478. }
  1479. }
  1480. }
  1481. }
  1482. catch (Exception ex)
  1483. {
  1484. return Ok(JsonView(false, ex.Message));
  1485. }
  1486. string msg = string.Format(@"成功上传{0}张", sucNum);
  1487. return Ok(JsonView(true, msg));
  1488. }
  1489. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1490. {
  1491. string filename = "";//声明一个string类型的相对路径
  1492. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1493. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1494. try//会有异常抛出,try,catch一下
  1495. {
  1496. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1497. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1498. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1499. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1500. //文件名称
  1501. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1502. //上传的文件的路径
  1503. string filePath = "";
  1504. if (!Directory.Exists(fileDir))
  1505. {
  1506. Directory.CreateDirectory(fileDir);
  1507. }
  1508. //上传的文件的路径
  1509. filePath = fileDir + filename;
  1510. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1511. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1512. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1513. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1514. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1515. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1516. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1517. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1518. bitmap.Dispose();
  1519. }
  1520. catch (Exception e)
  1521. {
  1522. string massage = e.Message;
  1523. Logs("IOS图片上传Error:" + massage);
  1524. //filename = e.Message;
  1525. }
  1526. return filename;//返回相对路径
  1527. }
  1528. /// <summary>
  1529. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1530. /// </summary>
  1531. /// <param name="dto"></param>
  1532. /// <returns></returns>
  1533. [HttpPost]
  1534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1535. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1536. {
  1537. if (dto == null)
  1538. {
  1539. return Ok(JsonView(false, "请求错误:"));
  1540. }
  1541. string msg = "参数错误";
  1542. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1543. {
  1544. try
  1545. {
  1546. //_delegationVisaRep.BeginTran();
  1547. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1548. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1549. .Where(s => s.Id == dto.visaProgressCustomerId)
  1550. .ExecuteCommandAsync();
  1551. if (updCount > 0 && dto.publishCode == 1)
  1552. {
  1553. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1554. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1555. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1556. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1557. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1558. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1559. if (groupData == null)
  1560. {
  1561. _delegationVisaRep.RollbackTran();
  1562. }
  1563. string title = string.Format(@"[签证进度更新]");
  1564. string content = string.Format(@"测试文本");
  1565. bool rst = await _message.AddMsg(new MessageDto()
  1566. {
  1567. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1568. IssuerId = dto.publisher,
  1569. Title = title,
  1570. Content = content,
  1571. ReleaseTime = DateTime.Now,
  1572. UIdList = new List<int> {
  1573. 234
  1574. }
  1575. });
  1576. if (rst)
  1577. {
  1578. return Ok(JsonView(true, "发送通知成功"));
  1579. }
  1580. }
  1581. //_delegationVisaRep.CommitTran();
  1582. }
  1583. catch (Exception)
  1584. {
  1585. //_delegationVisaRep.RollbackTran();
  1586. }
  1587. }
  1588. return Ok(JsonView(true, msg));
  1589. }
  1590. #endregion
  1591. #region 团组任务分配
  1592. /// <summary>
  1593. /// 团组任务分配初始化
  1594. /// </summary>
  1595. /// <param name="dto"></param>
  1596. /// <returns></returns>
  1597. [HttpPost]
  1598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1599. public async Task<IActionResult> GetTaskAssignmen()
  1600. {
  1601. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1602. if (groupData.Code != 0)
  1603. {
  1604. return Ok(JsonView(false, groupData.Msg));
  1605. }
  1606. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1607. }
  1608. /// <summary>
  1609. /// 团组任务分配查询
  1610. /// </summary>
  1611. /// <param name="dto"></param>
  1612. /// <returns></returns>
  1613. [HttpPost]
  1614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1615. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1616. {
  1617. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1618. if (groupData.Code != 0)
  1619. {
  1620. return Ok(JsonView(false, groupData.Msg));
  1621. }
  1622. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1623. }
  1624. /// <summary>
  1625. /// 团组任务分配操作
  1626. /// </summary>
  1627. /// <param name="dto"></param>
  1628. /// <returns></returns>
  1629. [HttpPost]
  1630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1631. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1632. {
  1633. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1634. if (groupData.Code != 0)
  1635. {
  1636. return Ok(JsonView(false, groupData.Msg));
  1637. }
  1638. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1639. }
  1640. /// <summary>
  1641. /// 团组任务分配
  1642. /// 批量分配
  1643. /// 查询团组
  1644. /// </summary>
  1645. /// <param name="dto"></param>
  1646. /// <returns></returns>
  1647. [HttpPost]
  1648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1649. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1650. {
  1651. //参数验证
  1652. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1653. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1654. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1655. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1656. }
  1657. /// <summary>
  1658. /// 团组任务分配
  1659. /// 批量分配
  1660. /// </summary>
  1661. /// <param name="dto"></param>
  1662. /// <returns></returns>
  1663. [HttpPost]
  1664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1665. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1666. {
  1667. //参数验证
  1668. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1669. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1670. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1671. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1672. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1673. }
  1674. #endregion
  1675. #region 团组费用审核
  1676. /// <summary>
  1677. /// 费用审核
  1678. /// 团组列表 Page
  1679. /// </summary>
  1680. /// <param name="_dto">团组列表请求dto</param>
  1681. /// <returns></returns>
  1682. [HttpPost]
  1683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1684. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1685. {
  1686. #region 参数验证
  1687. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1688. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1689. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1690. #region 页面操作权限验证
  1691. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1692. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1693. #endregion
  1694. #endregion
  1695. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1696. {
  1697. string sqlWhere = string.Empty;
  1698. if (_dto.IsSure == 0) //未完成
  1699. {
  1700. sqlWhere += string.Format(@" And IsSure = 0");
  1701. }
  1702. else if (_dto.IsSure == 1) //已完成
  1703. {
  1704. sqlWhere += string.Format(@" And IsSure = 1");
  1705. }
  1706. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1707. {
  1708. string tj = _dto.SearchCriteria;
  1709. 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}%')",
  1710. tj, tj, tj, tj, tj);
  1711. }
  1712. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1713. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1714. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1715. From (
  1716. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1717. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1718. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1719. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1720. From Grp_DelegationInfo gdi
  1721. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1722. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1723. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1724. Where gdi.IsDel = 0 {0}
  1725. ) temp ", sqlWhere);
  1726. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1727. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1728. var _view = new
  1729. {
  1730. PageFuncAuth = pageFunAuthView,
  1731. Data = _DelegationList
  1732. };
  1733. return Ok(JsonView(true, "查询成功!", _view, total));
  1734. }
  1735. else
  1736. {
  1737. return Ok(JsonView(false, "查询失败"));
  1738. }
  1739. }
  1740. /// <summary>
  1741. /// 获取团组费用审核
  1742. /// </summary>
  1743. /// <param name="paras">参数Json字符串</param>
  1744. /// <returns></returns>
  1745. [HttpPost]
  1746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1747. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1748. {
  1749. try
  1750. {
  1751. #region 参数验证
  1752. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1753. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1754. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1755. #region 页面操作权限验证
  1756. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1757. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1758. #endregion
  1759. #endregion
  1760. var _view = new Grp_CreditCardPaymentView();
  1761. var clientNameList = getSimplClientList(_dto.DiId);
  1762. #region 费用清单
  1763. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1764. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1765. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1766. var entityList = _groupRepository .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1767. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1768. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1769. /*
  1770. * 76://酒店预订
  1771. */
  1772. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1773. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1774. /*
  1775. * 79://车/导游地接
  1776. */
  1777. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1778. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1779. /*
  1780. * 80: //签证
  1781. */
  1782. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1783. /*
  1784. *81: //邀请/公务活动
  1785. */
  1786. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1787. /*
  1788. * 82: //团组客户保险
  1789. */
  1790. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1791. /*
  1792. * Lable = 85 机票预订
  1793. */
  1794. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1795. /*
  1796. * 85 机票预定
  1797. */
  1798. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1799. /*
  1800. * 98 其他款项
  1801. */
  1802. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1803. /*
  1804. * 285:收款退还
  1805. */
  1806. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1807. /*
  1808. * 1015: //超支费用
  1809. */
  1810. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1811. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1812. /*
  1813. * 币种信息
  1814. */
  1815. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  1816. /*
  1817. * 车/导游地接 费用类型
  1818. */
  1819. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  1820. /*
  1821. * 车/导游地接 费用类型
  1822. */
  1823. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  1824. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1825. /*
  1826. * 用户信息
  1827. */
  1828. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  1829. /*
  1830. * 费用模块
  1831. */
  1832. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  1833. string priceModule = string.Empty;
  1834. if (sdPriceName != null)
  1835. {
  1836. priceModule = sdPriceName.Name;
  1837. }
  1838. /*
  1839. * 成本信息
  1840. */
  1841. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1842. decimal _groupRate = 0.0000M;
  1843. string _groupCurrencyCode = "-";
  1844. if (groupCost != null)
  1845. {
  1846. _groupRate = groupCost.Rate;
  1847. if (int.TryParse(groupCost.Currency, out int _currency))
  1848. {
  1849. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1850. }
  1851. else _groupCurrencyCode = groupCost.Currency;
  1852. }
  1853. string costContentSql = $"Select * From Grp_GroupCost";
  1854. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1855. //处理日期为空的天数
  1856. for (int i = 0; i < groupCostDetails.Count; i++)
  1857. if (i != 0)
  1858. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1859. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1860. /*
  1861. * 处理详情数据
  1862. */
  1863. foreach (var entity in entityList)
  1864. {
  1865. var _detail = new Grp_CreditCardPaymentDetailView();
  1866. _detail.Id = entity.Id;
  1867. _detail.PriceName = priceModule;
  1868. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1869. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1870. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1871. //处理金额
  1872. if (entity.CTable == 1015)
  1873. {
  1874. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1875. if (czInfo != null)
  1876. {
  1877. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1878. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1879. }
  1880. }
  1881. /*
  1882. * 应付款金额
  1883. */
  1884. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1885. string PaymentCurrency_WaitPay = "Unknown";
  1886. string hotelCurrncyCode = "Unknown";
  1887. string hotelCurrncyName = "Unknown";
  1888. if (sdPaymentCurrency_WaitPay != null)
  1889. {
  1890. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1891. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1892. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1893. if (hotelCurrncyCode.Equals("CNY"))
  1894. {
  1895. entity.DayRate = 1.0000M;
  1896. }
  1897. }
  1898. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1899. /*
  1900. * 此次付款金额
  1901. */
  1902. decimal CurrPayStr = 0.00M,
  1903. OriginalCurrPay = 0.00M;
  1904. if (entity.PayPercentage == 0)
  1905. {
  1906. if (entity.PayThenMoney != 0)
  1907. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1908. }
  1909. else
  1910. {
  1911. if (entity.PayMoney != 0)
  1912. {
  1913. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1914. }
  1915. }
  1916. //if (_dto.Label == 79)
  1917. //{
  1918. // string original = string.Empty;
  1919. // if (hotelCurrncyCode.Equals("CNY"))
  1920. // {
  1921. // OriginalCurrPay = CurrPayStr;
  1922. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1923. // }
  1924. // else
  1925. // {
  1926. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1927. // //760 EUR(7600.00 CNY)
  1928. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1929. // }
  1930. //}
  1931. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1932. string original = string.Empty;
  1933. if (hotelCurrncyCode.Equals("CNY"))
  1934. {
  1935. OriginalCurrPay = CurrPayStr;
  1936. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1937. }
  1938. else
  1939. {
  1940. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1941. //760 EUR(7600.00 CNY)
  1942. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1943. }
  1944. /*
  1945. * 剩余尾款
  1946. */
  1947. decimal BalanceStr = 0;
  1948. if (CurrPayStr != 0)
  1949. {
  1950. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1951. BalanceStr = 0;
  1952. else
  1953. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1954. }
  1955. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1956. /*
  1957. * Bus名称
  1958. */
  1959. _detail.BusName = "待增加";
  1960. /*
  1961. *费用所属
  1962. */
  1963. switch (entity.CTable)
  1964. {
  1965. case 76://酒店预订
  1966. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1967. if (hotelReservations != null)
  1968. {
  1969. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1970. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1971. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1972. string roomFeeStr = "", roomFeestr1 = "";
  1973. //是否比较房型价格
  1974. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1975. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1976. roomFeeStr += $"<br/>";
  1977. var roomTotal = 0.00M;
  1978. if (hotelReservations.SingleRoomPrice > 0)
  1979. {
  1980. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  1981. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1982. __isSingle = true;
  1983. roomTotal += fee;
  1984. }
  1985. if (hotelReservations.DoubleRoomPrice > 0)
  1986. {
  1987. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  1988. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1989. __isDouble = true;
  1990. roomTotal += fee;
  1991. }
  1992. if (hotelReservations.SuiteRoomPrice > 0)
  1993. {
  1994. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  1995. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1996. __isSuite = true;
  1997. roomTotal += fee;
  1998. }
  1999. if (hotelReservations.OtherRoomPrice > 0)
  2000. {
  2001. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2002. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2003. __isOther = true;
  2004. roomTotal += fee;
  2005. }
  2006. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2007. else roomFeeStr += " 0.00 * 0";
  2008. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2009. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2010. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2011. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2012. /*
  2013. * 费用类型
  2014. * 1:房费
  2015. * 2:早餐
  2016. * 3:地税
  2017. * 4:城市税
  2018. * </summary>
  2019. */
  2020. //地税
  2021. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2022. if (governmentRentData != null)
  2023. {
  2024. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2025. governmentRentFee = governmentRentData.Price;
  2026. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2027. if (governmentRentCurrData != null)
  2028. {
  2029. governmentRentCode = governmentRentCurrData.Name;
  2030. governmentRentName = $"({governmentRentCurrData.Remark})";
  2031. }
  2032. }
  2033. //城市税
  2034. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2035. if (cityTaxData != null)
  2036. {
  2037. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2038. cityTaxFee = cityTaxData.Price;
  2039. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2040. if (cityTaxCurrData != null)
  2041. {
  2042. cityTaxCode = cityTaxCurrData.Name;
  2043. cityTaxName = $"({cityTaxCurrData.Remark})";
  2044. }
  2045. }
  2046. //酒店早餐
  2047. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2048. if (breakfastData != null)
  2049. {
  2050. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2051. breakfastFee = breakfastData.Price;
  2052. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2053. if (breakfastCurrData != null)
  2054. {
  2055. breakfastCode = breakfastCurrData.Name;
  2056. breakfastName = $"({breakfastCurrData.Remark})";
  2057. }
  2058. }
  2059. //房间费用
  2060. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2061. if (roomData != null)
  2062. {
  2063. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2064. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2065. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2066. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2067. roomFee = roomData.Price;
  2068. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2069. if (roomCurrData != null)
  2070. {
  2071. roomCode = roomCurrData.Name;
  2072. roomName = $"({roomCurrData.Remark})";
  2073. }
  2074. }
  2075. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2076. string hotelCostStr = "";
  2077. decimal hotelCsotTotal = 0.00M;
  2078. if (groupCost != null)
  2079. {
  2080. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2081. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2082. }
  2083. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2084. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2085. string hotelCost_day = "";
  2086. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2087. foreach (var item in hotelCostDetails1)
  2088. {
  2089. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2090. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2091. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2092. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2093. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2094. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2095. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2096. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2097. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2098. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2099. hotelCost_day += @$"<br/>";
  2100. }
  2101. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2102. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2103. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2104. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2105. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2106. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2107. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2108. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2109. $"房间说明: {hotelReservations.Remark} <br/>" +
  2110. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2111. $"{hotelBreakfastStr}" +
  2112. $"{hotelGovernmentRentStr}" +
  2113. $"{hotelCityTaxStr}";
  2114. _detail.PriceNameContent = hotelReservations.HotelName;
  2115. }
  2116. break;
  2117. case 79://车/导游地接
  2118. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2119. if (touristGuideGroundReservations != null)
  2120. {
  2121. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2122. {
  2123. _detail.BusName = touristGuideGroundReservations.BusName;
  2124. }
  2125. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2126. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2127. //if (isInt)
  2128. //{
  2129. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2130. // if (cityInfo != null)
  2131. // {
  2132. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2133. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2134. // if (carFeeItem != null)
  2135. // {
  2136. // nameContent += $@"({carFeeItem.Name})";
  2137. // }
  2138. // _detail.PriceNameContent = nameContent;
  2139. // }
  2140. //}
  2141. //else
  2142. //{
  2143. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2144. //}
  2145. var touristGuideGroundReservationsContents =
  2146. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2147. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2148. foreach (var item in touristGuideGroundReservationsContents)
  2149. {
  2150. string typeName = "Unknown";
  2151. string carCurrencyCode = "Unknown";
  2152. string carCurrencyName = "Unknown";
  2153. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2154. if (carTypeData != null) typeName = carTypeData.Name;
  2155. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2156. if (currencyData != null)
  2157. {
  2158. carCurrencyCode = currencyData.Name;
  2159. carCurrencyName = currencyData.Remark;
  2160. }
  2161. //op、成本 币种是否一致
  2162. bool IsCurrencyAgreement = false;
  2163. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2164. string opCostStr = string.Empty;
  2165. decimal opCostTypePrice = 0.00M;
  2166. #region 处理成本各项费用
  2167. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2168. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2169. if (opCost.Count > 0)
  2170. {
  2171. switch (item.SId)
  2172. {
  2173. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2174. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2175. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2176. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2177. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2178. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2179. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2180. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2181. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2182. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2183. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2184. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2185. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2186. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2187. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2188. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2189. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2190. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2191. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2192. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2193. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2194. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2195. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2196. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2197. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2198. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2199. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2200. }
  2201. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2202. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2203. }
  2204. #endregion
  2205. string opTypeStr = $"{typeName}{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2206. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2207. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2208. $"{opTypeStr} {opCostStr}<br/>" +
  2209. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2210. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2211. }
  2212. _detail.PriceMsgContent = priceMsg;
  2213. }
  2214. break;
  2215. case 80: //签证
  2216. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2217. if (visaInfo != null)
  2218. {
  2219. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2220. _detail.PriceNameContent = visaInfo.VisaDescription;
  2221. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2222. }
  2223. break;
  2224. case 81: //邀请/公务活动
  2225. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2226. if (_ioa != null)
  2227. {
  2228. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2229. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2230. sendCurrName = "Unknown", //快递费用币种 Name
  2231. sendCurrCode = "Unknown", //快递费用币种 Code
  2232. eventsCurrName = "Unknown", //公务活动费币种 Name
  2233. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2234. translateCurrName = "Unknown", //公务翻译费 Name
  2235. translateCurrCode = "Unknown"; //公务翻译费 Code
  2236. #region 处理费用币种
  2237. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2238. if (inviteCurrData != null)
  2239. {
  2240. inviteCurrName = inviteCurrData.Remark;
  2241. inviteCurrCode = inviteCurrData.Name;
  2242. }
  2243. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2244. if (sendCurrData != null)
  2245. {
  2246. sendCurrName = sendCurrData.Remark;
  2247. sendCurrCode = sendCurrData.Name;
  2248. }
  2249. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2250. if (eventsCurrData != null)
  2251. {
  2252. eventsCurrName = eventsCurrData.Remark;
  2253. eventsCurrCode = eventsCurrData.Name;
  2254. }
  2255. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2256. if (translateCurrData != null)
  2257. {
  2258. translateCurrName = translateCurrData.Remark;
  2259. translateCurrCode = translateCurrData.Name;
  2260. }
  2261. #endregion
  2262. _detail.PriceNameContent = _ioa.InviterArea;
  2263. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2264. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2265. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2266. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2267. $@"备注:" + _ioa.Remark + "<br/>";
  2268. }
  2269. break;
  2270. case 82: //团组客户保险
  2271. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2272. if (customers != null)
  2273. {
  2274. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2275. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2276. }
  2277. break;
  2278. case 85: //机票预订
  2279. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2280. if (jpRes != null)
  2281. {
  2282. string FlightsDescription = jpRes.FlightsDescription;
  2283. string PriceDescription = jpRes.PriceDescription;
  2284. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2285. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2286. }
  2287. break;
  2288. case 98://其他款项
  2289. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2290. if (gdpRes != null)
  2291. {
  2292. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2293. _detail.PriceNameContent = gdpRes.PriceName;
  2294. }
  2295. break;
  2296. case 285://收款退还
  2297. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2298. if (refundAndOtherMoney != null)
  2299. {
  2300. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2301. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2302. }
  2303. break;
  2304. case 751://酒店早餐
  2305. break;
  2306. case 1015://超支费用
  2307. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2308. if (groupExtraCost != null)
  2309. {
  2310. _detail.PriceNameContent = groupExtraCost.PriceName;
  2311. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2312. }
  2313. break;
  2314. default:
  2315. break;
  2316. }
  2317. /*
  2318. * 申请人
  2319. */
  2320. string operatorName = " - ";
  2321. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2322. if (_opUser != null)
  2323. {
  2324. operatorName = _opUser.CnName;
  2325. }
  2326. _detail.OperatorName = operatorName;
  2327. /*
  2328. * 审核人
  2329. */
  2330. string auditOperatorName = "Unknown";
  2331. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2332. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2333. else
  2334. {
  2335. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2336. if (_adUser != null)
  2337. {
  2338. auditOperatorName = _adUser.CnName;
  2339. }
  2340. }
  2341. _detail.AuditOperatorName = auditOperatorName;
  2342. /*
  2343. * 超预算比例
  2344. */
  2345. string overBudgetStr = "";
  2346. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2347. else if (entity.ExceedBudget == 0)
  2348. {
  2349. if (entity.CTable == 76 || entity.CTable == 79)
  2350. {
  2351. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2352. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2353. }
  2354. else
  2355. {
  2356. overBudgetStr = "未超预算";
  2357. }
  2358. }
  2359. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2360. _detail.OverBudget = overBudgetStr;
  2361. decimal auditFee = 0.00M; //已审核金额 人名币
  2362. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2363. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2364. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2365. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2366. {
  2367. auditedFeeOriginal = entity.PayMoney;
  2368. auditFee = CurrPayStr;
  2369. }
  2370. else if (entity.IsAuditGM == 0)
  2371. {
  2372. unAuditFeeCNY = CurrPayStr;
  2373. unAuditFeeOriginal = OriginalCurrPay;
  2374. OriginalCurrPay = 0.00M;
  2375. }
  2376. /*
  2377. * 费用总计
  2378. */
  2379. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2380. {
  2381. CurrencyId = entity.PaymentCurrency,
  2382. CurrencyName = PaymentCurrency_WaitPay,
  2383. AmountPayable = entity.PayMoney,
  2384. ThisPayment = OriginalCurrPay,
  2385. BalancePayment = BalanceStr,
  2386. AuditedFunds = auditFee,
  2387. AuditedFundsOriginal = auditedFeeOriginal,
  2388. UnAuditFundsCNY = unAuditFeeCNY,
  2389. UnAuditFundsOriginal = unAuditFeeOriginal
  2390. });
  2391. _detail.IsAuditGM = entity.IsAuditGM;
  2392. detailList.Add(_detail);
  2393. }
  2394. #endregion
  2395. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2396. /*
  2397. * 下方描述处理
  2398. */
  2399. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2400. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2401. if (ccpCurrencyPrice != null)
  2402. {
  2403. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2404. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2405. }
  2406. else
  2407. {
  2408. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2409. }
  2410. string amountPayableStr = string.Format(@"应付款总金额: ");
  2411. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2412. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2413. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2414. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2415. foreach (var item in nonDuplicat)
  2416. {
  2417. var currencyName = item.CurrencyName;
  2418. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2419. if (strs.Count > 0)
  2420. {
  2421. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2422. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2423. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2424. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2425. //单独处理此次付款金额
  2426. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2427. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2428. //单独处理已审核费用
  2429. //if (item.CurrencyId == 836) //人民币
  2430. //{
  2431. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2432. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2433. //}
  2434. //else
  2435. //{
  2436. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2437. //}
  2438. if (currencyName.Equals("CNY"))
  2439. {
  2440. //已审核费用
  2441. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2442. //未审核费用
  2443. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2444. }
  2445. else
  2446. {
  2447. //已审核费用
  2448. 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"));
  2449. //未审核费用
  2450. 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"));
  2451. }
  2452. }
  2453. }
  2454. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2455. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2456. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2457. _view.TotalStr4 = $"{auditedFundsStr.Substring(0, auditedFundsStr.Length - 1)}<br/>{unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1)}";
  2458. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2459. var _view1 = new
  2460. {
  2461. PageFuncAuth = pageFunAuthView,
  2462. Data = _view
  2463. };
  2464. return Ok(JsonView(_view1));
  2465. }
  2466. catch (Exception ex)
  2467. {
  2468. return Ok(JsonView(false, ex.Message));
  2469. }
  2470. }
  2471. /// <summary>
  2472. /// 费用审核
  2473. /// 修改团组费用审核状态
  2474. /// </summary>
  2475. /// <param name="_dto">参数Json字符串</param>
  2476. /// <returns></returns>
  2477. [HttpPost]
  2478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2479. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2480. {
  2481. #region 参数验证
  2482. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2483. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2484. #endregion
  2485. #region 页面操作权限验证
  2486. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2487. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2488. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2489. #endregion
  2490. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2491. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2492. DateTime dtNow = DateTime.Now;
  2493. _groupRepository.BeginTran();
  2494. int rst = 0;
  2495. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2496. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2497. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2498. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2499. List<dynamic> msgDatas = new List<dynamic>();
  2500. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2501. foreach (var item in idList)
  2502. {
  2503. int CreditId = int.Parse(item);
  2504. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2505. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2506. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2507. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2508. .Where(s => s.Id == CreditId)
  2509. .ExecuteCommandAsync();
  2510. if (result < 1)
  2511. {
  2512. rst = -1;
  2513. _groupRepository.RollbackTran();
  2514. return Ok(JsonView(false, "操作失败并回滚!"));
  2515. }
  2516. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2517. if (creditData != null)
  2518. {
  2519. #region 应用通知配置
  2520. try
  2521. {
  2522. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2523. }
  2524. catch (Exception ex)
  2525. {
  2526. }
  2527. #endregion
  2528. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2529. string groupNameStr = string.Empty;
  2530. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2531. if (groupData != null) groupNameStr = groupData.TeamName;
  2532. string creditTypeStr = string.Empty;
  2533. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2534. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2535. string creditCurrency = string.Empty;
  2536. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2537. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2538. if (creditCurrency.Equals("CNY"))
  2539. {
  2540. creditData.DayRate = 1.0000M;
  2541. }
  2542. if (creditData.PayPercentage == 0.00M)
  2543. {
  2544. creditData.PayPercentage = 100M;
  2545. }
  2546. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2547. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2548. string msgContent = "";
  2549. if (creditCurrency.Equals("CNY"))
  2550. {
  2551. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2552. }
  2553. else
  2554. {
  2555. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2556. }
  2557. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2558. }
  2559. }
  2560. if (rst == 0)
  2561. {
  2562. _groupRepository.CommitTran();
  2563. foreach (var item in msgDatas)
  2564. {
  2565. //发送消息
  2566. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2567. }
  2568. #region 应用推送
  2569. try
  2570. {
  2571. foreach (var ccpId in dic_ccp_user.Keys)
  2572. {
  2573. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2574. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2575. }
  2576. }
  2577. catch (Exception)
  2578. {
  2579. }
  2580. #endregion
  2581. return Ok(JsonView(true, "操作成功!"));
  2582. }
  2583. return Ok(JsonView(false, "操作失败!"));
  2584. }
  2585. #endregion
  2586. #region 机票费用录入
  2587. /// <summary>
  2588. /// 机票录入当前登录人可操作团组
  2589. /// </summary>
  2590. /// <param name="dto"></param>
  2591. /// <returns></returns>
  2592. [HttpPost]
  2593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2594. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2595. {
  2596. try
  2597. {
  2598. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2599. if (groupData.Code != 0)
  2600. {
  2601. return Ok(JsonView(false, groupData.Msg));
  2602. }
  2603. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2604. }
  2605. catch (Exception ex)
  2606. {
  2607. return Ok(JsonView(false, "程序错误!"));
  2608. throw;
  2609. }
  2610. }
  2611. /// <summary>
  2612. /// 机票费用录入列表
  2613. /// </summary>
  2614. /// <param name="dto"></param>
  2615. /// <returns></returns>
  2616. [HttpPost]
  2617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2618. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2619. {
  2620. try
  2621. {
  2622. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2623. if (groupData.Code != 0)
  2624. {
  2625. return Ok(JsonView(false, groupData.Msg));
  2626. }
  2627. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2628. }
  2629. catch (Exception ex)
  2630. {
  2631. return Ok(JsonView(false, ex.Message));
  2632. throw;
  2633. }
  2634. }
  2635. /// <summary>
  2636. /// 根据id查询费用录入信息
  2637. /// </summary>
  2638. /// <param name="dto"></param>
  2639. /// <returns></returns>
  2640. [HttpPost]
  2641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2642. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2643. {
  2644. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2645. if (groupData.Code != 0)
  2646. {
  2647. return Ok(JsonView(false, groupData.Msg));
  2648. }
  2649. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2650. }
  2651. /// <summary>
  2652. /// 机票费用录入操作(Status:1.新增,2.修改)
  2653. /// </summary>
  2654. /// <param name="dto"></param>
  2655. /// <returns></returns>
  2656. [HttpPost]
  2657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2658. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2659. {
  2660. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2661. if (groupData.Code != 0)
  2662. {
  2663. return Ok(JsonView(false, groupData.Msg));
  2664. }
  2665. #region 应用推送
  2666. try
  2667. {
  2668. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2669. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2670. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2671. //2024-10-21 新增LZ UID
  2672. var userIds = new List<int>() { 21 };
  2673. string title = $"系统通知";
  2674. string content = "";
  2675. var diId = dto.AirTicketResOpData.DiId;
  2676. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2677. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2678. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2679. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2680. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2681. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2682. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2683. }
  2684. catch (Exception ex)
  2685. {
  2686. }
  2687. #endregion
  2688. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2689. }
  2690. /// <summary>
  2691. /// 根据舱位类型查询接团客户名单信息
  2692. /// </summary>
  2693. /// <param name="dto"></param>
  2694. /// <returns></returns>
  2695. [HttpPost]
  2696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2697. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2698. {
  2699. try
  2700. {
  2701. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2702. if (crm_Groups.Count != 0)
  2703. {
  2704. List<dynamic> Customer = new List<dynamic>();
  2705. foreach (var item in crm_Groups)
  2706. {
  2707. var data = new
  2708. {
  2709. Id = item.Id,
  2710. Pinyin = item.Pinyin,
  2711. Name = item.LastName + item.FirstName
  2712. };
  2713. Customer.Add(data);
  2714. }
  2715. return Ok(JsonView(true, "查询成功!", Customer));
  2716. }
  2717. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2718. }
  2719. catch (Exception ex)
  2720. {
  2721. return Ok(JsonView(false, "程序错误!"));
  2722. throw;
  2723. }
  2724. }
  2725. /// <summary>
  2726. /// 根据团号获取客户信息
  2727. /// </summary>
  2728. /// <param name="dto"></param>
  2729. /// <returns></returns>
  2730. [HttpPost]
  2731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2732. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2733. {
  2734. var jw = JsonView(false);
  2735. if (dto.DIID < 1)
  2736. {
  2737. jw.Msg += "请输入正确的diid";
  2738. return Ok(jw);
  2739. }
  2740. var arr = getSimplClientList(dto.DIID);
  2741. jw = JsonView(true, "获取成功!", arr);
  2742. return Ok(jw);
  2743. }
  2744. private List<SimplClientInfo> getSimplClientList(int diId)
  2745. {
  2746. 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);
  2747. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2748. foreach (var item in arr)
  2749. {
  2750. EncryptionProcessor.DecryptProperties(item);
  2751. }
  2752. return arr;
  2753. }
  2754. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2755. {
  2756. string result = origin;
  2757. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2758. {
  2759. string[] temparr = origin.Split(',');
  2760. string fistrStr = temparr[0];
  2761. int count = temparr.Count();
  2762. int tempId;
  2763. bool success = int.TryParse(fistrStr, out tempId);
  2764. if (success)
  2765. {
  2766. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2767. if (tempInfo != null)
  2768. {
  2769. if (count > 1)
  2770. {
  2771. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2772. }
  2773. else
  2774. {
  2775. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2776. }
  2777. }
  2778. }
  2779. }
  2780. return result;
  2781. }
  2782. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2783. {
  2784. string result = origin;
  2785. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2786. {
  2787. string[] temparr = origin.Split(',');
  2788. result = "";
  2789. foreach (var item in temparr)
  2790. {
  2791. int tempId;
  2792. bool success = int.TryParse(item, out tempId);
  2793. if (success)
  2794. {
  2795. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2796. if (tempInfo != null)
  2797. {
  2798. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2799. }
  2800. }
  2801. }
  2802. }
  2803. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2804. return result;
  2805. }
  2806. /// <summary>
  2807. /// 机票费用录入,删除
  2808. /// </summary>
  2809. /// <param name="dto"></param>
  2810. /// <returns></returns>
  2811. [HttpPost]
  2812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2813. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2814. {
  2815. try
  2816. {
  2817. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2818. if (res)
  2819. {
  2820. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2821. {
  2822. IsDel = 1,
  2823. DeleteUserId = dto.DeleteUserId,
  2824. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2825. }).ExecuteCommandAsync();
  2826. return Ok(JsonView(true, "删除成功!"));
  2827. }
  2828. return Ok(JsonView(false, "删除失败!"));
  2829. }
  2830. catch (Exception ex)
  2831. {
  2832. return Ok(JsonView(false, "程序错误!"));
  2833. throw;
  2834. }
  2835. }
  2836. /// <summary>
  2837. /// 导出机票录入报表
  2838. /// </summary>
  2839. /// <param name="dto"></param>
  2840. /// <returns></returns>
  2841. [HttpPost]
  2842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2843. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2844. {
  2845. try
  2846. {
  2847. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2848. if (groupData.Code != 0)
  2849. {
  2850. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2851. }
  2852. else
  2853. {
  2854. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2855. if (AirTicketReservations.Count != 0)
  2856. {
  2857. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2858. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2859. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2860. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2861. WorkbookDesigner designer = new WorkbookDesigner();
  2862. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2863. decimal countCost = 0;
  2864. foreach (var item in AirTicketReservations)
  2865. {
  2866. #region 处理客人姓名
  2867. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2868. item.ClientName = clientNames;
  2869. #endregion
  2870. if (item.BankType == "其他")
  2871. {
  2872. item.BankNo = "--";
  2873. }
  2874. else
  2875. {
  2876. if (!string.IsNullOrEmpty(item.BankType))
  2877. {
  2878. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2879. }
  2880. }
  2881. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2882. item.Price = System.Decimal.Round(item.Price, 2);
  2883. countCost += Convert.ToDecimal(item.Price);
  2884. }
  2885. designer.SetDataSource("Export", AirTicketReservations);
  2886. designer.SetDataSource("ExportDiCode", diCode);
  2887. designer.SetDataSource("ExportDiName", diName);
  2888. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2889. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2890. designer.Process();
  2891. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2892. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2893. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2894. return Ok(JsonView(true, "成功", url = rst));
  2895. }
  2896. else
  2897. {
  2898. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2899. }
  2900. }
  2901. }
  2902. catch (Exception ex)
  2903. {
  2904. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2905. throw;
  2906. }
  2907. }
  2908. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2909. /// <summary>
  2910. /// 行程单导出
  2911. /// </summary>
  2912. /// <param name="dto"></param>
  2913. /// <returns></returns>
  2914. [HttpPost]
  2915. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2916. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2917. {
  2918. try
  2919. {
  2920. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2921. if (groupData.Code != 0)
  2922. {
  2923. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2924. }
  2925. else
  2926. {
  2927. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2928. if (dto.Language == "CN")
  2929. {
  2930. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2931. DocumentBuilder builder = new DocumentBuilder(doc);
  2932. int tableIndex = 0;//表格索引
  2933. //得到文档中的第一个表格
  2934. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2935. foreach (var item in _AirTicketReservations)
  2936. {
  2937. #region 处理固定数据
  2938. string[] FlightsCode = item.FlightsCode.Split('/');
  2939. if (FlightsCode.Length != 0)
  2940. {
  2941. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2942. if (_AirCompany != null)
  2943. {
  2944. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2945. }
  2946. else
  2947. {
  2948. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2949. }
  2950. }
  2951. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2952. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2953. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2954. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2955. string name = "";
  2956. foreach (string clientName in nameArray)
  2957. {
  2958. if (!name.Contains(clientName))
  2959. {
  2960. name += clientName + ",";
  2961. }
  2962. }
  2963. if (!string.IsNullOrWhiteSpace(name))
  2964. {
  2965. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2966. }
  2967. else
  2968. {
  2969. table.Range.Bookmarks["ClientName"].Text = "--";
  2970. }
  2971. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2972. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2973. table.Range.Bookmarks["JointTicket"].Text = "--";
  2974. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2975. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2976. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2977. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2978. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2979. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2980. #endregion
  2981. #region 循环数据处理
  2982. List<AirInfo> airs = new List<AirInfo>();
  2983. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2984. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2985. for (int i = 0; i < FlightsCode.Length; i++)
  2986. {
  2987. AirInfo air = new AirInfo();
  2988. string[] tempstr = DayArray[i]
  2989. .Replace("\r\n", string.Empty)
  2990. .Replace("\\r\\n", string.Empty)
  2991. .TrimStart().TrimEnd()
  2992. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2993. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2994. string starCity = "";
  2995. if (star_Three != null)
  2996. {
  2997. starCity = star_Three.AirPort;
  2998. }
  2999. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3000. string EndCity = "";
  3001. if (End_Three != null)
  3002. {
  3003. EndCity = End_Three.AirPort;
  3004. }
  3005. air.Destination = starCity + "/" + EndCity;
  3006. air.Flight = FlightsCode[i];
  3007. air.SeatingClass = item.CTypeName;
  3008. string dateTime = tempstr[2];
  3009. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3010. air.FlightDate = DateTemp;
  3011. air.DepartureTime = tempstr[5];
  3012. air.LandingTime = tempstr[6];
  3013. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3014. air.TicketStatus = "--";
  3015. air.Luggage = "--";
  3016. air.DepartureTerminal = "--";
  3017. air.LandingTerminal = "--";
  3018. airs.Add(air);
  3019. }
  3020. int row = 13;
  3021. for (int i = 0; i < airs.Count; i++)
  3022. {
  3023. if (airs.Count > 2)
  3024. {
  3025. for (int j = 0; j < airs.Count - 2; j++)
  3026. {
  3027. var CopyRow = table.Rows[12].Clone(true);
  3028. table.Rows.Add(CopyRow);
  3029. }
  3030. }
  3031. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3032. int index = 0;
  3033. foreach (PropertyInfo property in properties)
  3034. {
  3035. string value = property.GetValue(airs[i]).ToString();
  3036. Cell ishcel0 = table.Rows[row].Cells[index];
  3037. Paragraph p = new Paragraph(doc);
  3038. string s = value;
  3039. p.AppendChild(new Run(doc, s));
  3040. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3041. ishcel0.AppendChild(p);
  3042. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3043. index++;
  3044. }
  3045. row++;
  3046. }
  3047. #endregion
  3048. Paragraph lastParagraph = new Paragraph(doc);
  3049. //第一个表格末尾加段落
  3050. table.ParentNode.InsertAfter(lastParagraph, table);
  3051. //复制第一个表格
  3052. Table cloneTable = (Table)table.Clone(true);
  3053. //在文档末尾段落后面加入复制的表格
  3054. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3055. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3056. {
  3057. int rownewsIndex = 13;
  3058. for (int i = 0; i < 2; i++)
  3059. {
  3060. var CopyRow = table.Rows[12].Clone(true);
  3061. table.Rows.RemoveAt(13);
  3062. table.Rows.Add(CopyRow);
  3063. rownewsIndex++;
  3064. }
  3065. }
  3066. else
  3067. {
  3068. table.Rows.RemoveAt(12);
  3069. }
  3070. cloneTable.Rows.RemoveAt(12);
  3071. }
  3072. if (_AirTicketReservations.Count != 0)
  3073. {
  3074. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3075. if (FlightsCode.Length != 0)
  3076. {
  3077. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3078. if (_AirCompany != null)
  3079. {
  3080. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3081. }
  3082. else
  3083. {
  3084. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3085. }
  3086. }
  3087. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3088. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3089. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3090. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3091. string name = "";
  3092. foreach (string clientName in nameArray)
  3093. {
  3094. if (!name.Contains(clientName))
  3095. {
  3096. name += clientName + ",";
  3097. }
  3098. }
  3099. if (!string.IsNullOrWhiteSpace(name))
  3100. {
  3101. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3102. }
  3103. else
  3104. {
  3105. table.Range.Bookmarks["ClientName"].Text = "--";
  3106. }
  3107. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3108. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3109. table.Range.Bookmarks["JointTicket"].Text = "--";
  3110. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3111. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3112. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3113. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3114. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3115. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3116. }
  3117. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3118. //保存合并后的文档
  3119. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3120. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3121. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3122. return Ok(JsonView(true, "成功!", rst));
  3123. }
  3124. else
  3125. {
  3126. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3127. DocumentBuilder builder = new DocumentBuilder(doc);
  3128. int tableIndex = 0;//表格索引
  3129. //得到文档中的第一个表格
  3130. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3131. List<string> texts = new List<string>();
  3132. foreach (var item in _AirTicketReservations)
  3133. {
  3134. string[] FlightsCode = item.FlightsCode.Split('/');
  3135. if (FlightsCode.Length != 0)
  3136. {
  3137. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3138. if (_AirCompany != null)
  3139. {
  3140. if (!transDic.ContainsKey(_AirCompany.CnName))
  3141. {
  3142. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3143. }
  3144. }
  3145. else
  3146. {
  3147. if (!transDic.ContainsKey("--"))
  3148. {
  3149. transDic.Add("--", "--");
  3150. }
  3151. }
  3152. }
  3153. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3154. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3155. string name = "";
  3156. foreach (string clientName in nameArray)
  3157. {
  3158. name += clientName + ",";
  3159. }
  3160. if (!texts.Contains(name))
  3161. {
  3162. texts.Add(name);
  3163. }
  3164. List<AirInfo> airs = new List<AirInfo>();
  3165. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3166. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3167. for (int i = 0; i < FlightsCode.Length; i++)
  3168. {
  3169. AirInfo air = new AirInfo();
  3170. string[] tempstr = DayArray[i]
  3171. .Replace("\r\n", string.Empty)
  3172. .Replace("\\r\\n", string.Empty)
  3173. .TrimStart().TrimEnd()
  3174. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3175. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3176. if (star_Three != null)
  3177. {
  3178. if (!transDic.ContainsKey(star_Three.AirPort))
  3179. {
  3180. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3181. }
  3182. }
  3183. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3184. if (End_Three != null)
  3185. {
  3186. if (!transDic.ContainsKey(End_Three.AirPort))
  3187. {
  3188. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3189. }
  3190. }
  3191. if (!texts.Contains(item.CTypeName))
  3192. {
  3193. texts.Add(item.CTypeName);
  3194. }
  3195. }
  3196. }
  3197. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3198. if (transData.Count > 0)
  3199. {
  3200. foreach (TranslateResult item in transData)
  3201. {
  3202. if (!transDic.ContainsKey(item.Query))
  3203. {
  3204. transDic.Add(item.Query, item.Translation);
  3205. }
  3206. }
  3207. }
  3208. foreach (var item in _AirTicketReservations)
  3209. {
  3210. #region 处理固定数据
  3211. string[] FlightsCode = item.FlightsCode.Split('/');
  3212. if (FlightsCode.Length != 0)
  3213. {
  3214. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3215. if (_AirCompany != null)
  3216. {
  3217. string str = "--";
  3218. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3219. if (!string.IsNullOrEmpty(translateResult))
  3220. {
  3221. str = translateResult;
  3222. str = _airTicketResRep.Processing(str);
  3223. }
  3224. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3225. }
  3226. else
  3227. {
  3228. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3229. }
  3230. }
  3231. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3232. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3233. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3234. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3235. string names = "";
  3236. foreach (string clientName in nameArray)
  3237. {
  3238. names += clientName + ",";
  3239. }
  3240. if (!string.IsNullOrWhiteSpace(names))
  3241. {
  3242. string str = "--";
  3243. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3244. if (!string.IsNullOrEmpty(translateResult))
  3245. {
  3246. str = translateResult;
  3247. str = _airTicketResRep.Processing(str);
  3248. }
  3249. table.Range.Bookmarks["ClientName"].Text = str;
  3250. }
  3251. else
  3252. {
  3253. table.Range.Bookmarks["ClientName"].Text = "--";
  3254. }
  3255. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3256. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3257. table.Range.Bookmarks["JointTicket"].Text = "--";
  3258. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3259. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3260. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3261. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3262. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3263. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3264. #endregion
  3265. #region 循环数据处理
  3266. List<AirInfo> airs = new List<AirInfo>();
  3267. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3268. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3269. for (int i = 0; i < FlightsCode.Length; i++)
  3270. {
  3271. AirInfo air = new AirInfo();
  3272. string[] tempstr = DayArray[i]
  3273. .Replace("\r\n", string.Empty)
  3274. .Replace("\\r\\n", string.Empty)
  3275. .TrimStart().TrimEnd()
  3276. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3277. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3278. string starCity = "";
  3279. if (star_Three != null)
  3280. {
  3281. string str2 = "--";
  3282. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3283. if (!string.IsNullOrEmpty(translateResult2))
  3284. {
  3285. str2 = translateResult2;
  3286. str2 = _airTicketResRep.Processing(str2);
  3287. }
  3288. starCity = str2;
  3289. }
  3290. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3291. string EndCity = "";
  3292. if (End_Three != null)
  3293. {
  3294. string str1 = "--";
  3295. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3296. if (!string.IsNullOrEmpty(translateResult1))
  3297. {
  3298. str1 = translateResult1;
  3299. str1 = _airTicketResRep.Processing(str1);
  3300. }
  3301. EndCity = str1;
  3302. }
  3303. air.Destination = starCity + "/" + EndCity;
  3304. air.Flight = FlightsCode[i];
  3305. string str = "--";
  3306. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3307. if (!string.IsNullOrEmpty(translateResult))
  3308. {
  3309. str = translateResult;
  3310. str = _airTicketResRep.Processing(str);
  3311. }
  3312. air.SeatingClass = str;
  3313. string dateTime = tempstr[2];
  3314. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3315. air.FlightDate = DateTemp;
  3316. air.DepartureTime = tempstr[5];
  3317. air.LandingTime = tempstr[6];
  3318. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3319. air.TicketStatus = "--";
  3320. air.Luggage = "--";
  3321. air.DepartureTerminal = "--";
  3322. air.LandingTerminal = "--";
  3323. airs.Add(air);
  3324. }
  3325. int row = 13;
  3326. for (int i = 0; i < airs.Count; i++)
  3327. {
  3328. if (airs.Count > 2)
  3329. {
  3330. for (int j = 0; j < airs.Count - 2; j++)
  3331. {
  3332. var CopyRow = table.Rows[12].Clone(true);
  3333. table.Rows.Add(CopyRow);
  3334. }
  3335. }
  3336. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3337. int index = 0;
  3338. foreach (PropertyInfo property in properties)
  3339. {
  3340. string value = property.GetValue(airs[i]).ToString();
  3341. Cell ishcel0 = table.Rows[row].Cells[index];
  3342. Paragraph p = new Paragraph(doc);
  3343. string s = value;
  3344. p.AppendChild(new Run(doc, s));
  3345. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3346. ishcel0.AppendChild(p);
  3347. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3348. //ishcel0.CellFormat.VerticalAlignment=
  3349. index++;
  3350. }
  3351. row++;
  3352. }
  3353. #endregion
  3354. Paragraph lastParagraph = new Paragraph(doc);
  3355. //第一个表格末尾加段落
  3356. table.ParentNode.InsertAfter(lastParagraph, table);
  3357. //复制第一个表格
  3358. Table cloneTable = (Table)table.Clone(true);
  3359. //在文档末尾段落后面加入复制的表格
  3360. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3361. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3362. {
  3363. int rownewsIndex = 13;
  3364. for (int i = 0; i < 2; i++)
  3365. {
  3366. var CopyRow = table.Rows[12].Clone(true);
  3367. table.Rows.RemoveAt(13);
  3368. table.Rows.Add(CopyRow);
  3369. rownewsIndex++;
  3370. }
  3371. }
  3372. else
  3373. {
  3374. table.Rows.RemoveAt(12);
  3375. }
  3376. cloneTable.Rows.RemoveAt(12);
  3377. }
  3378. if (_AirTicketReservations.Count != 0)
  3379. {
  3380. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3381. if (FlightsCode.Length != 0)
  3382. {
  3383. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3384. if (_AirCompany != null)
  3385. {
  3386. string str = "--";
  3387. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3388. if (!string.IsNullOrEmpty(translateResult))
  3389. {
  3390. str = translateResult;
  3391. str = _airTicketResRep.Processing(str);
  3392. }
  3393. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3394. }
  3395. else
  3396. {
  3397. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3398. }
  3399. }
  3400. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3401. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3402. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3403. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3404. string names = "";
  3405. foreach (string clientName in nameArray)
  3406. {
  3407. names += clientName + ",";
  3408. }
  3409. if (!string.IsNullOrWhiteSpace(names))
  3410. {
  3411. string str = "--";
  3412. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3413. if (!string.IsNullOrEmpty(translateResult))
  3414. {
  3415. str = translateResult;
  3416. str = _airTicketResRep.Processing(str);
  3417. }
  3418. table.Range.Bookmarks["ClientName"].Text = str;
  3419. }
  3420. else
  3421. {
  3422. table.Range.Bookmarks["ClientName"].Text = "--";
  3423. }
  3424. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3425. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3426. table.Range.Bookmarks["JointTicket"].Text = "--";
  3427. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3428. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3429. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3430. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3431. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3432. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3433. }
  3434. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3435. //保存合并后的文档
  3436. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3437. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3438. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3439. return Ok(JsonView(true, "成功!", rst));
  3440. }
  3441. }
  3442. }
  3443. catch (Exception ex)
  3444. {
  3445. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3446. throw;
  3447. }
  3448. }
  3449. #endregion
  3450. #region 团组增减款项 --> 其他款项
  3451. /// <summary>
  3452. /// 团组增减款项下拉框绑定
  3453. /// </summary>
  3454. /// <param name="dto"></param>
  3455. /// <returns></returns>
  3456. [HttpPost]
  3457. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3458. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3459. {
  3460. #region 参数验证
  3461. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3462. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3463. #endregion
  3464. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3465. }
  3466. /// <summary>
  3467. /// 根据团组Id查询团组增减款项
  3468. /// </summary>
  3469. /// <param name="dto"></param>
  3470. /// <returns></returns>
  3471. [HttpPost]
  3472. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3473. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3474. {
  3475. #region 参数验证
  3476. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3477. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3478. #endregion
  3479. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3480. }
  3481. /// <summary>
  3482. /// 团组增减款项操作(Status:1.新增,2.修改)
  3483. /// </summary>
  3484. /// <param name="dto"></param>
  3485. /// <returns></returns>
  3486. [HttpPost]
  3487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3488. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3489. {
  3490. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3491. if (groupData.Code != 200)
  3492. {
  3493. return Ok(JsonView(false, groupData.Msg));
  3494. }
  3495. #region 应用推送
  3496. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3497. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3498. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3499. //自动审核
  3500. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3501. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3502. //2024-10-21 新增LZ UID
  3503. var userIds = new List<int>() { 21 };
  3504. string title = $"系统通知";
  3505. string content = "";
  3506. var diId = dto.DiId;
  3507. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3508. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3509. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3510. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3511. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3512. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3513. #endregion
  3514. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3515. }
  3516. /// <summary>
  3517. /// 团组增减款项操作 删除
  3518. /// </summary>
  3519. /// <param name="dto"></param>
  3520. /// <returns></returns>
  3521. [HttpPost]
  3522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3523. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3524. {
  3525. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3526. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3527. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3528. if (res.Code == 0)
  3529. {
  3530. return Ok(JsonView(true, "删除成功!"));
  3531. }
  3532. return Ok(JsonView(false, "删除失败!"));
  3533. }
  3534. /// <summary>
  3535. /// 根据团组增减款项Id查询
  3536. /// </summary>
  3537. /// <param name="dto"></param>
  3538. /// <returns></returns>
  3539. [HttpPost]
  3540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3541. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3542. {
  3543. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3544. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3545. }
  3546. /// <summary>
  3547. /// 查询供应商名称
  3548. /// </summary>
  3549. /// <param name="dto"></param>
  3550. /// <returns></returns>
  3551. [HttpPost]
  3552. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3553. {
  3554. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3555. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3556. ?? new List<Grp_DecreasePayments>();
  3557. dbResult = dbResult.Distinct(new
  3558. ProductComparer()).ToList();
  3559. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3560. {
  3561. x.Id,
  3562. x.SupplierAddress,
  3563. x.SupplierArea,
  3564. x.SupplierContact,
  3565. x.SupplierContactNumber,
  3566. x.SupplierEmail,
  3567. x.SupplierName,
  3568. x.SupplierSocialAccount,
  3569. x.SupplierTypeId,
  3570. }).ToList());
  3571. return Ok(jw);
  3572. }
  3573. /// <summary>
  3574. /// 团组增减款项 OTA匹配
  3575. /// </summary>
  3576. /// <param name="file"></param>
  3577. /// <returns></returns>
  3578. [HttpPost]
  3579. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3580. {
  3581. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3582. string fileName = file.FileName;
  3583. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3584. {
  3585. return Ok(JsonView(false, "请上传Excel文件!"));
  3586. }
  3587. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3588. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3589. if (!Directory.Exists(path))
  3590. {
  3591. Directory.CreateDirectory(path);
  3592. }
  3593. var filePath = @$"{path}/{fileName}";
  3594. //保存文件
  3595. using (FileStream fs = System.IO.File.Create(filePath))
  3596. {
  3597. file.CopyTo(fs);
  3598. fs.Flush();
  3599. }
  3600. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3601. //读取ExcelFile
  3602. DataTable dt = ConvertExcelToDataTable(filePath);
  3603. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3604. dt.TableName = "TB";
  3605. //修改table列名
  3606. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3607. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3608. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3609. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3610. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3611. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3612. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3613. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3614. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3615. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3616. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3617. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3618. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3619. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3620. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3621. var otaOrderNos = new List<string>();
  3622. foreach (DataRow item in dt.Rows)
  3623. {
  3624. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3625. }
  3626. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3627. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3628. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3629. .Select((dp, di) => new
  3630. {
  3631. dp.PriceName,
  3632. dp.OTAOrderNo,
  3633. dp.FeeTotal,
  3634. di.TeamName,
  3635. })
  3636. .ToListAsync();
  3637. foreach (DataRow item in dt.Rows)
  3638. {
  3639. var otaOrderNo = item["OTAOrderNo"].ToString();
  3640. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3641. if (oaData == null) continue;
  3642. item["GroupName"] = oaData.TeamName;
  3643. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3644. }
  3645. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3646. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3647. List<DataTable> datas = new List<DataTable>();
  3648. datas.Add(dt);
  3649. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3650. return Ok(JsonView(true, "操作成功", new { url = url }));
  3651. }
  3652. #region
  3653. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3654. {
  3655. // 创建Workbook对象
  3656. Workbook workbook = new Workbook(excelFilePath);
  3657. // 获取第一个工作表
  3658. Worksheet worksheet = workbook.Worksheets[0];
  3659. // 将工作表转换为DataTable
  3660. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3661. return dataTable;
  3662. }
  3663. #endregion
  3664. #endregion
  3665. #region 文件上传、删除
  3666. /// <summary>
  3667. /// region 文件上传 可以带参数
  3668. /// </summary>
  3669. /// <param name="file"></param>
  3670. /// <returns></returns>
  3671. [HttpPost]
  3672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3673. public async Task<IActionResult> UploadProject(IFormFile file)
  3674. {
  3675. //var TypeName = Request.Headers["TypeName"].ToString();
  3676. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3677. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3678. ////文件名称
  3679. //string projectFileName = file.FileName;
  3680. ////上传的文件的路径
  3681. //string filePath = $"{fileDir}/{projectFileName}";
  3682. //if (TypeName == "A")//A代表团组增减款项
  3683. //{
  3684. // filePath = fileDir + $@"\团组增减款项相关文件";
  3685. // if (!Directory.Exists(filePath))
  3686. // {
  3687. // Directory.CreateDirectory(filePath);
  3688. // }
  3689. // //上传的文件的路径
  3690. // filePath += $@"\{projectFileName}";
  3691. //}
  3692. //else if (TypeName == "B")//B代表商邀相关文件
  3693. //{
  3694. // //上传的文件的路径
  3695. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3696. // if (!Directory.Exists(filePath))
  3697. // {
  3698. // Directory.CreateDirectory(filePath);
  3699. // }
  3700. // //上传的文件的路径
  3701. // filePath = $@"\{projectFileName}";
  3702. //}
  3703. //try
  3704. //{
  3705. // using (FileStream fs = System.IO.File.Create(filePath))
  3706. // {
  3707. // file.CopyTo(fs);
  3708. // fs.Flush();
  3709. // }
  3710. //}
  3711. //catch (Exception ex)
  3712. //{
  3713. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3714. //}
  3715. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3716. try
  3717. {
  3718. var TypeName = Request.Headers["TypeName"].ToString();
  3719. if (file != null)
  3720. {
  3721. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3722. //文件名称
  3723. string projectFileName = file.FileName;
  3724. //上传的文件的路径
  3725. string filePath = $"{fileDir}/{projectFileName}";
  3726. if (TypeName == "A")//A代表团组增减款项
  3727. {
  3728. if (!Directory.Exists(fileDir))
  3729. {
  3730. Directory.CreateDirectory(fileDir);
  3731. }
  3732. //上传的文件的路径
  3733. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3734. }
  3735. else if (TypeName == "B")//B代表商邀相关文件
  3736. {
  3737. if (!Directory.Exists(fileDir))
  3738. {
  3739. Directory.CreateDirectory(fileDir);
  3740. }
  3741. //上传的文件的路径
  3742. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3743. }
  3744. using (FileStream fs = System.IO.File.Create(filePath))
  3745. {
  3746. file.CopyTo(fs);
  3747. fs.Flush();
  3748. }
  3749. return Ok(JsonView(true, "上传成功!", projectFileName));
  3750. }
  3751. else
  3752. {
  3753. return Ok(JsonView(false, "上传失败!"));
  3754. }
  3755. }
  3756. catch (Exception ex)
  3757. {
  3758. return Ok(JsonView(false, "程序错误!"));
  3759. }
  3760. }
  3761. /// <summary>
  3762. /// 删除指定文件
  3763. /// </summary>
  3764. /// <param name="dto"></param>
  3765. /// <returns></returns>
  3766. [HttpPost]
  3767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3768. public async Task<IActionResult> DelFile(DelFileDto dto)
  3769. {
  3770. try
  3771. {
  3772. var TypeName = Request.Headers["TypeName"].ToString();
  3773. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3774. string filePath = "";
  3775. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3776. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3777. int id = 0;
  3778. if (TypeName == "A")
  3779. {
  3780. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3781. // 删除该文件
  3782. System.IO.File.Delete(filePath);
  3783. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3784. .Where(a => a.Id == dto.Id)
  3785. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3786. .ExecuteCommandAsync();
  3787. }
  3788. else if (TypeName == "B")
  3789. {
  3790. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3791. // 删除该文件
  3792. System.IO.File.Delete(filePath);
  3793. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3794. if (info != null)
  3795. {
  3796. string[] files = new string[] { };
  3797. if (!string.IsNullOrEmpty(info.Attachment))
  3798. {
  3799. try
  3800. {
  3801. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3802. }
  3803. catch (Exception)
  3804. {
  3805. files = new List<string>() { info.Attachment }.ToArray();
  3806. }
  3807. }
  3808. if (files.Length > 0)
  3809. {
  3810. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3811. string filePath2 = string.Empty;
  3812. if (files1.Length > 0)
  3813. {
  3814. filePath2 = JsonConvert.SerializeObject(files1);
  3815. }
  3816. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3817. .Where(a => a.Id == dto.Id)
  3818. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3819. .ExecuteCommandAsync();
  3820. }
  3821. }
  3822. }
  3823. if (id != 0)
  3824. {
  3825. return Ok(JsonView(true, "成功!"));
  3826. }
  3827. else
  3828. {
  3829. return Ok(JsonView(false, "失败!"));
  3830. }
  3831. }
  3832. catch (Exception ex)
  3833. {
  3834. return Ok(JsonView(false, "程序错误!"));
  3835. throw;
  3836. }
  3837. }
  3838. /// <summary>
  3839. /// 文件上传多个文件 可以带参数
  3840. /// </summary>
  3841. /// <param name="file"></param>
  3842. /// <returns></returns>
  3843. [HttpPost]
  3844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3845. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3846. {
  3847. try
  3848. {
  3849. var TypeName = Request.Headers["TypeName"].ToString();
  3850. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3851. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3852. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3853. var filePahts = new List<string>();
  3854. foreach (var file in files)
  3855. {
  3856. //文件名称
  3857. string projectFileName = file.FileName;
  3858. //上传的文件的路径
  3859. string filePath = $"{fileDir}/{projectFileName}";
  3860. if (TypeName == "A")//A代表团组增减款项
  3861. {
  3862. if (!Directory.Exists(fileDir))
  3863. {
  3864. Directory.CreateDirectory(fileDir);
  3865. }
  3866. //上传的文件的路径
  3867. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3868. }
  3869. else if (TypeName == "B")//B代表商邀相关文件
  3870. {
  3871. if (!Directory.Exists(fileDir))
  3872. {
  3873. Directory.CreateDirectory(fileDir);
  3874. }
  3875. //上传的文件的路径
  3876. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3877. }
  3878. using (FileStream fs = System.IO.File.Create(filePath))
  3879. {
  3880. file.CopyTo(fs);
  3881. fs.Flush();
  3882. }
  3883. filePahts.Add(projectFileName);
  3884. }
  3885. return Ok(JsonView(true, "上传成功!", filePahts));
  3886. }
  3887. catch (Exception ex)
  3888. {
  3889. return Ok(JsonView(false, "程序错误!"));
  3890. }
  3891. }
  3892. #endregion
  3893. #region 商邀费用录入
  3894. /// <summary>
  3895. /// 根据团组Id查询商邀费用列表
  3896. /// </summary>
  3897. /// <param name="dto"></param>
  3898. /// <returns></returns>
  3899. [HttpPost]
  3900. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3901. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3902. {
  3903. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3904. if (groupData.Code != 0)
  3905. {
  3906. return Ok(JsonView(false, groupData.Msg));
  3907. }
  3908. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3909. }
  3910. /// <summary>
  3911. /// 商邀费用列表
  3912. /// 下载文件
  3913. /// </summary>
  3914. /// <param name="dto"></param>
  3915. /// <returns></returns>
  3916. [HttpGet("{id}")]
  3917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3918. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3919. {
  3920. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3921. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3922. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3923. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3924. var filePaths = new List<string>();
  3925. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3926. try
  3927. {
  3928. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3929. }
  3930. catch (Exception ex)
  3931. {
  3932. filePaths.Add(info.Attachment);
  3933. }
  3934. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3935. for (int i = 0; i < filePaths.Count; i++)
  3936. {
  3937. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3938. }
  3939. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3940. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3941. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3942. {
  3943. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3944. {
  3945. foreach (string filePath in filePaths)
  3946. {
  3947. if (System.IO.File.Exists(filePath))
  3948. {
  3949. // 获取文件名
  3950. string fileName = Path.GetFileName(filePath);
  3951. // 将文件添加到ZIP归档中
  3952. zipArchive.CreateEntryFromFile(filePath, fileName);
  3953. }
  3954. }
  3955. }
  3956. }
  3957. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3958. }
  3959. /// <summary>
  3960. /// 商邀费用 Info Page 基础数据源
  3961. /// </summary>
  3962. /// <param name="dto"></param>
  3963. /// <returns></returns>
  3964. [HttpPost]
  3965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3966. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3967. {
  3968. try
  3969. {
  3970. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3971. if (groupData.Code != 0)
  3972. {
  3973. return Ok(JsonView(false, groupData.Msg));
  3974. }
  3975. return Ok(JsonView(true, "操作成功", groupData.Data));
  3976. }
  3977. catch (Exception ex)
  3978. {
  3979. return Ok(JsonView(false, ex.Message));
  3980. throw;
  3981. }
  3982. }
  3983. /// <summary>
  3984. /// 根据商邀费用ID查询C表和商邀费用数据
  3985. /// </summary>
  3986. /// <param name="dto"></param>
  3987. /// <returns></returns>
  3988. [HttpPost]
  3989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3990. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3991. {
  3992. try
  3993. {
  3994. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3995. if (groupData.Code != 0)
  3996. {
  3997. return Ok(JsonView(false, groupData.Msg));
  3998. }
  3999. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4000. }
  4001. catch (Exception ex)
  4002. {
  4003. return Ok(JsonView(false, ex.Message));
  4004. throw;
  4005. }
  4006. }
  4007. /// <summary>
  4008. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4009. /// </summary>
  4010. /// <param name="dto"></param>
  4011. /// <returns></returns>
  4012. [HttpPost]
  4013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4014. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4015. {
  4016. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4017. if (groupData.Code != 0)
  4018. {
  4019. return Ok(JsonView(false, groupData.Msg));
  4020. }
  4021. #region 应用推送
  4022. try
  4023. {
  4024. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4025. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4026. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4027. //2024-10-21 新增LZ UID
  4028. var userIds = new List<int>() { 21 };
  4029. string title = $"系统通知";
  4030. string content = "";
  4031. var diId = dto.DiId;
  4032. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4033. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4034. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4035. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4036. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4037. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4038. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4039. }
  4040. catch (Exception ex)
  4041. {
  4042. }
  4043. #endregion
  4044. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4045. }
  4046. /// <summary>
  4047. /// 商邀删除
  4048. /// </summary>
  4049. /// <param name="dto"></param>
  4050. /// <returns></returns>
  4051. [HttpPost]
  4052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4053. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4054. {
  4055. try
  4056. {
  4057. _sqlSugar.BeginTran();
  4058. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4059. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4060. {
  4061. IsDel = 1,
  4062. DeleteUserId = dto.DeleteUserId,
  4063. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4064. })
  4065. .Where(it => it.Id == dto.Id)
  4066. .ExecuteCommand();
  4067. if (res1 > 0)
  4068. {
  4069. int _diId = 0;
  4070. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4071. if (_ioaInfo != null)
  4072. {
  4073. _diId = _ioaInfo.DiId;
  4074. }
  4075. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4076. .SetColumns(a => new Grp_CreditCardPayment()
  4077. {
  4078. IsDel = 1,
  4079. DeleteUserId = dto.DeleteUserId,
  4080. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4081. })
  4082. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4083. .ExecuteCommand();
  4084. if (res2 > 0)
  4085. {
  4086. _sqlSugar.CommitTran();
  4087. return Ok(JsonView(true, "删除成功!"));
  4088. }
  4089. }
  4090. _sqlSugar.RollbackTran();
  4091. return Ok(JsonView(false, "删除失败"));
  4092. }
  4093. catch (Exception ex)
  4094. {
  4095. _sqlSugar.RollbackTran();
  4096. return Ok(JsonView(false, ex.Message));
  4097. }
  4098. }
  4099. /// <summary>
  4100. /// 团组模块文件上传
  4101. /// </summary>
  4102. /// <param name="dto"></param>
  4103. /// <returns></returns>
  4104. [HttpPost]
  4105. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4106. {
  4107. var jw = JsonView(false);
  4108. long M = 1024 * 1024;
  4109. if (dto.Files == null || dto.Files.Count == 0)
  4110. {
  4111. jw.Msg = "无文件信息!";
  4112. return Ok(jw);
  4113. }
  4114. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4115. {
  4116. jw.Msg = "文件大小超过20M!";
  4117. return Ok(jw);
  4118. }
  4119. //var nameSp = dto.File.FileName.Split(".");
  4120. //if (nameSp.Length < 2)
  4121. //{
  4122. // jw.Msg = "拓展名称有误!";
  4123. // return Ok(jw);
  4124. //}
  4125. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4126. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4127. //{
  4128. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4129. // return Ok(jw);
  4130. //}
  4131. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4132. if (Ctable == null)
  4133. {
  4134. jw.Msg = "Ctable指向有误!";
  4135. return Ok(jw);
  4136. }
  4137. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4138. if (groupInfo == null)
  4139. {
  4140. jw.Msg = "团组信息不存在!";
  4141. return Ok(jw);
  4142. }
  4143. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4144. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4145. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4146. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4147. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4148. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4149. try
  4150. {
  4151. if (!Directory.Exists(fileBase))
  4152. {
  4153. Directory.CreateDirectory(fileBase);
  4154. }
  4155. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4156. foreach (var fileStream in dto.Files)
  4157. {
  4158. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4159. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4160. {
  4161. Cid = dto.Cid,
  4162. CreateTime = DateTime.Now,
  4163. CreateUserId = dto.Userid,
  4164. Ctable = dto.Ctable,
  4165. Diid = dto.Diid,
  4166. IsDel = 0,
  4167. FilePath = saveFilePath,
  4168. FileName = fileStream.FileName
  4169. };
  4170. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4171. {
  4172. fileStream.CopyTo(fs);
  4173. fs.Flush();
  4174. }
  4175. saveArr.Add(file);
  4176. }
  4177. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4178. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4179. jw = JsonView(true, "保存成功!", new
  4180. {
  4181. count = addResult,
  4182. filesName = saveArr.Select(x => x.FileName)
  4183. });
  4184. }
  4185. catch (Exception ex)
  4186. {
  4187. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4188. {
  4189. count = 0,
  4190. filesName = new string[0],
  4191. });
  4192. }
  4193. return Ok(jw);
  4194. }
  4195. /// <summary>
  4196. /// 查询各模块已保存文件
  4197. /// </summary>
  4198. /// <param name="dto"></param>
  4199. /// <returns></returns>
  4200. [HttpPost]
  4201. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4202. {
  4203. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4204. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4205. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4206. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4207. {
  4208. expression = Expressionable.Create<Grp_GroupModelFile>()
  4209. .And(x => visaIds.Contains(x.CreateUserId));
  4210. }
  4211. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4212. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4213. .Where(expression.ToExpression())
  4214. .ToList();
  4215. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4216. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4217. {
  4218. x.FileName,
  4219. x.Id,
  4220. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4221. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4222. })));
  4223. }
  4224. /// <summary>
  4225. /// 下载该团组下的所有文件
  4226. /// </summary>
  4227. /// <param name="dto"></param>
  4228. /// <returns></returns>
  4229. [HttpPost]
  4230. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4231. {
  4232. var jw = JsonView(false);
  4233. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4234. if (groupInfo == null)
  4235. {
  4236. jw.Msg = "团组信息不存在!";
  4237. return Ok(jw);
  4238. }
  4239. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4240. var isModule = Convert.ToBoolean(dto.isModule);
  4241. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4242. IOOperatorHelper io = new IOOperatorHelper();
  4243. if (isModule)
  4244. {
  4245. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4246. foreach (var moduleArr in moduleGroup)
  4247. {
  4248. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4249. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4250. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4251. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4252. foreach (var item in moduleArr)
  4253. {
  4254. if (System.IO.File.Exists(item.FilePath))
  4255. {
  4256. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4257. {
  4258. byte[] bytes = new byte[fileStream.Length];
  4259. fileStream.Read(bytes, 0, bytes.Length);
  4260. fileStream.Close();
  4261. Stream stream = new MemoryStream(bytes);
  4262. chiZips.Add(item.FileName, stream);
  4263. }
  4264. }
  4265. }
  4266. if (chiZips.Count > 0)
  4267. {
  4268. var byts = io.ConvertZipStream(chiZips);
  4269. Stream stream = new MemoryStream(byts);
  4270. Zips.Add(key.Name + "_.zip", stream);
  4271. }
  4272. }
  4273. }
  4274. else
  4275. {
  4276. foreach (var item in dbQuery)
  4277. {
  4278. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4279. {
  4280. byte[] bytes = new byte[fileStream.Length];
  4281. fileStream.Read(bytes, 0, bytes.Length);
  4282. fileStream.Close();
  4283. Stream stream = new MemoryStream(bytes);
  4284. while (Zips.Keys.Contains(item.FileName))
  4285. {
  4286. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4287. }
  4288. Zips.Add(item.FileName, stream);
  4289. }
  4290. }
  4291. }
  4292. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4293. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4294. if (Zips.Count > 0)
  4295. {
  4296. var byts = io.ConvertZipStream(Zips);
  4297. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4298. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4299. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4300. }
  4301. else
  4302. {
  4303. jw.Msg = "暂无生成文件!";
  4304. }
  4305. return Ok(jw);
  4306. }
  4307. /// <summary>
  4308. /// 下载该团组下此模块的所有文件
  4309. /// </summary>
  4310. /// <param name="dto"></param>
  4311. /// <returns></returns>
  4312. [HttpPost]
  4313. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4314. {
  4315. var jw = JsonView(false);
  4316. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4317. if (groupInfo == null)
  4318. {
  4319. jw.Msg = "团组信息不存在!";
  4320. return Ok(jw);
  4321. }
  4322. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4323. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4324. && x.IsDel == 0);
  4325. if (key == null)
  4326. {
  4327. jw.Msg = "Ctable指向错误!";
  4328. return Ok(jw);
  4329. }
  4330. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4331. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4332. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4333. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4334. IOOperatorHelper io = new IOOperatorHelper();
  4335. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4336. foreach (var item in dbQuery)
  4337. {
  4338. if (System.IO.File.Exists(item.FilePath))
  4339. {
  4340. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4341. {
  4342. byte[] bytes = new byte[fileStream.Length];
  4343. fileStream.Read(bytes, 0, bytes.Length);
  4344. fileStream.Close();
  4345. Stream stream = new MemoryStream(bytes);
  4346. while (Zips.Keys.Contains(item.FileName))
  4347. {
  4348. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4349. }
  4350. Zips.Add(item.FileName, stream);
  4351. }
  4352. }
  4353. }
  4354. if (Zips.Count > 0)
  4355. {
  4356. var byts = io.ConvertZipStream(Zips);
  4357. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4358. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4359. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4360. }
  4361. else
  4362. {
  4363. jw.Msg = "暂无生成文件!";
  4364. }
  4365. return Ok(jw);
  4366. }
  4367. /// <summary>
  4368. /// 删除该团组下的指定文件
  4369. /// </summary>
  4370. /// <param name="dto"></param>
  4371. /// <returns></returns>
  4372. [HttpPost]
  4373. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4374. {
  4375. var jw = JsonView(false);
  4376. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4377. if (sing == null)
  4378. {
  4379. jw.Msg = "暂无";
  4380. return Ok(jw);
  4381. }
  4382. if (System.IO.File.Exists(sing.FilePath))
  4383. {
  4384. try
  4385. {
  4386. System.IO.File.Delete(sing.FilePath);
  4387. }
  4388. catch (Exception ex)
  4389. {
  4390. jw.Msg = "删除失败!" + ex.Message;
  4391. return Ok(jw);
  4392. }
  4393. }
  4394. sing.IsDel = 1;
  4395. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4396. sing.DeleteUserId = dto.UserId;
  4397. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4398. jw = JsonView(true, "删除成功!");
  4399. return Ok(jw);
  4400. }
  4401. #endregion
  4402. #region 团组英文资料
  4403. /// <summary>
  4404. /// 查询团组英文所有资料
  4405. /// </summary>
  4406. /// <param name="dto"></param>
  4407. /// <returns></returns>
  4408. [HttpPost]
  4409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4410. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4411. {
  4412. try
  4413. {
  4414. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4415. if (groupData.Code != 0)
  4416. {
  4417. return Ok(JsonView(false, groupData.Msg));
  4418. }
  4419. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4420. }
  4421. catch (Exception ex)
  4422. {
  4423. return Ok(JsonView(false, "程序错误!"));
  4424. throw;
  4425. }
  4426. }
  4427. /// <summary>
  4428. /// 团组英文资料操作(Status:1.新增,2.修改)
  4429. /// </summary>
  4430. /// <param name="dto"></param>
  4431. /// <returns></returns>
  4432. [HttpPost]
  4433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4434. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4435. {
  4436. try
  4437. {
  4438. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4439. if (groupData.Code != 0)
  4440. {
  4441. return Ok(JsonView(false, groupData.Msg));
  4442. }
  4443. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4444. }
  4445. catch (Exception ex)
  4446. {
  4447. return Ok(JsonView(false, "程序错误!"));
  4448. throw;
  4449. }
  4450. }
  4451. /// <summary>
  4452. /// 团组英文资料Id查询数据
  4453. /// </summary>
  4454. /// <param name="dto"></param>
  4455. /// <returns></returns>
  4456. [HttpPost]
  4457. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4458. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4459. {
  4460. try
  4461. {
  4462. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4463. if (_DelegationEnData != null)
  4464. {
  4465. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4466. }
  4467. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4468. }
  4469. catch (Exception ex)
  4470. {
  4471. return Ok(JsonView(false, "程序错误!"));
  4472. throw;
  4473. }
  4474. }
  4475. /// <summary>
  4476. /// 团组英文资料删除
  4477. /// </summary>
  4478. /// <param name="dto"></param>
  4479. /// <returns></returns>
  4480. [HttpPost]
  4481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4482. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4483. {
  4484. try
  4485. {
  4486. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4487. if (!res)
  4488. {
  4489. return Ok(JsonView(false, "删除失败"));
  4490. }
  4491. return Ok(JsonView(true, "删除成功!"));
  4492. }
  4493. catch (Exception ex)
  4494. {
  4495. return Ok(JsonView(false, "程序错误!"));
  4496. throw;
  4497. }
  4498. }
  4499. #endregion
  4500. #region 导出邀请函
  4501. /// <summary>
  4502. /// 导出邀请函页面初始化
  4503. /// </summary>
  4504. /// <param name="dto"></param>
  4505. /// <returns></returns>
  4506. [HttpPost]
  4507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4508. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4509. {
  4510. try
  4511. {
  4512. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4513. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4514. if (dto.DiId == 0)
  4515. {
  4516. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4517. }
  4518. else
  4519. {
  4520. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4521. }
  4522. return Ok(JsonView(true, "查询成功!", new
  4523. {
  4524. deleClient = crm_Deles,
  4525. delegations = grp_Delegations
  4526. }));
  4527. }
  4528. catch (Exception ex)
  4529. {
  4530. return Ok(JsonView(false, "程序错误!"));
  4531. throw;
  4532. }
  4533. }
  4534. /// <summary>
  4535. /// 导出邀请函
  4536. /// </summary>
  4537. /// <param name="dto"></param>
  4538. /// <returns></returns>
  4539. [HttpPost]
  4540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4541. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4542. {
  4543. #region 参数验证
  4544. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4545. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4546. #endregion
  4547. try
  4548. {
  4549. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4550. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4551. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4552. From Grp_TourClientList tcl
  4553. Left Join
  4554. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4555. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4556. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4557. From Crm_DeleClient dc
  4558. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4559. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4560. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4561. Where dc.IsDel = 0) temp
  4562. On temp.DcId =tcl.ClientId
  4563. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4564. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4565. List<string> texts = new List<string>();
  4566. if (datas.Count != 0)
  4567. {
  4568. foreach (TourClientListDetailsView item in datas)
  4569. {
  4570. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4571. {
  4572. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4573. }
  4574. else
  4575. {
  4576. string name = item.LastName + item.FirstName;
  4577. texts.Add(name);
  4578. }
  4579. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4580. {
  4581. if (!transDic.ContainsKey(item.Job))
  4582. {
  4583. texts.Add(item.Job);
  4584. }
  4585. }
  4586. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4587. {
  4588. texts.Add(item.CompanyFullName);
  4589. }
  4590. }
  4591. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4592. if (transData.Count > 0)
  4593. {
  4594. foreach (TranslateResult item in transData)
  4595. {
  4596. if (!transDic.ContainsKey(item.Query))
  4597. {
  4598. transDic.Add(item.Query, item.Translation);
  4599. }
  4600. }
  4601. }
  4602. List<GuestList> list = new List<GuestList>();
  4603. foreach (TourClientListDetailsView dele in datas)
  4604. {
  4605. GuestList guestList = new GuestList();
  4606. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4607. {
  4608. guestList.Name = dele.Pinyin;
  4609. }
  4610. else
  4611. {
  4612. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4613. guestList.Name = Name;
  4614. }
  4615. if (dele.Sex == 0)
  4616. {
  4617. guestList.Sex = "Male";
  4618. }
  4619. else if (dele.Sex == 1)
  4620. {
  4621. guestList.Sex = "Female";
  4622. }
  4623. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4624. if (!string.IsNullOrEmpty(dele.Job))
  4625. {
  4626. guestList.Job = dele.Job;
  4627. }
  4628. list.Add(guestList);
  4629. }
  4630. //载入模板
  4631. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4632. DocumentBuilder builder = new DocumentBuilder(doc);
  4633. //获取word里所有表格
  4634. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4635. //获取所填表格的序数
  4636. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4637. var rowStart = tableOne.Rows[0]; //获取第1行
  4638. //循环赋值
  4639. for (int i = 0; i < list.Count; i++)
  4640. {
  4641. builder.MoveToCell(0, i + 1, 0, 0);
  4642. builder.Write(list[i].Name.ToString());
  4643. builder.MoveToCell(0, i + 1, 1, 0);
  4644. builder.Write(list[i].Sex.ToString());
  4645. builder.MoveToCell(0, i + 1, 2, 0);
  4646. builder.Write(list[i].DOB.ToString());
  4647. builder.MoveToCell(0, i + 1, 3, 0);
  4648. builder.Write(list[i].Job.ToString());
  4649. }
  4650. //删除多余行
  4651. while (tableOne.Rows.Count > list.Count + 1)
  4652. {
  4653. tableOne.Rows.RemoveAt(list.Count + 1);
  4654. }
  4655. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4656. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4657. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4658. doc.Save(filePath);
  4659. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4660. return Ok(JsonView(true, "操作成功!", Url));
  4661. }
  4662. else
  4663. {
  4664. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4665. }
  4666. }
  4667. catch (Exception ex)
  4668. {
  4669. return Ok(JsonView(false, ex.Message));
  4670. throw;
  4671. }
  4672. }
  4673. #endregion
  4674. #region 团组经理模块 出入境费用
  4675. /// <summary>
  4676. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4677. /// </summary>
  4678. /// <returns></returns>
  4679. [HttpPost]
  4680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4681. public async Task<IActionResult> SetDayAndCostAreaChange()
  4682. {
  4683. try
  4684. {
  4685. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4686. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4687. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4688. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4689. foreach (var item in unite) //处理交集数据
  4690. {
  4691. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4692. }
  4693. foreach (var item in merge) //处理差集数据
  4694. {
  4695. int nationalTravelFeeId = 0;
  4696. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4697. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4698. else
  4699. {
  4700. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4701. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4702. }
  4703. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4704. }
  4705. //只更新dayAndCost 的 nationalTravelFeeId;
  4706. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4707. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4708. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4709. }
  4710. catch (Exception ex)
  4711. {
  4712. return Ok(JsonView(false, ex.Message));
  4713. throw;
  4714. }
  4715. }
  4716. /// <summary>
  4717. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4718. /// </summary>
  4719. /// <returns></returns>
  4720. [HttpPost]
  4721. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4722. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4723. {
  4724. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4725. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4726. //SetDataInfoView
  4727. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4728. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4729. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4730. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4731. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4732. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4733. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4734. //默认币种显示
  4735. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4736. {
  4737. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4738. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4739. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4740. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4741. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4742. };
  4743. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4744. if (_currencyRate.Count > 0)
  4745. {
  4746. foreach (var item in _currencyInfos)
  4747. {
  4748. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4749. if (rateInfo != null)
  4750. {
  4751. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4752. rate1 *= 1.035M;
  4753. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4754. }
  4755. }
  4756. }
  4757. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4758. return Ok(JsonView(true, "查询成功!", new
  4759. {
  4760. GroupNameData = groupNameData.Data,
  4761. CurrencyData = _CurrencyData,
  4762. WordTypeData = _WordTypeData,
  4763. ExcelTypeData = _ExcelTypeData,
  4764. CurrencyInit = _currencyInfos,
  4765. ViewPermissionData = viewPermissionData
  4766. }));
  4767. }
  4768. /// <summary>
  4769. /// 团组模块 - 出入境费用
  4770. /// 实时汇率 tips
  4771. /// 签证费用 tips
  4772. /// 机票费用 tips
  4773. /// </summary>
  4774. /// <returns></returns>
  4775. [HttpPost]
  4776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4777. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4778. {
  4779. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4780. //默认币种显示
  4781. var _currencyInfos = _currencyInit;
  4782. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4783. List<dynamic> reteInfos = new List<dynamic>();
  4784. if (_currencyRate.Count > 0)
  4785. {
  4786. foreach (var item in _currencyInfos)
  4787. {
  4788. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4789. if (rateInfo != null)
  4790. {
  4791. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4792. decimal rate1 = item.Rate;
  4793. rate1 *= 1.03M;
  4794. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4795. reteInfos.Add(new
  4796. {
  4797. currCode = item.CurrencyCode,
  4798. currName = item.CurrencyName,
  4799. rate = rate2,
  4800. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4801. });
  4802. }
  4803. }
  4804. }
  4805. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4806. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4807. return Ok(JsonView(true, "查询成功!", new
  4808. {
  4809. //GroupNameData = groupNameData.Data,
  4810. visaData = visaData.Data,
  4811. airData = airData.Data,
  4812. reteInfos = reteInfos
  4813. }));
  4814. }
  4815. /// <summary>
  4816. /// 团组模块 - 出入境费用 - Info
  4817. /// </summary>
  4818. /// <returns></returns>
  4819. [HttpPost]
  4820. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4821. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4822. {
  4823. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4824. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4825. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4826. }
  4827. /// <summary>
  4828. /// 团组模块 - 出入境费用 - 设置view权限
  4829. /// </summary>
  4830. /// <returns></returns>
  4831. [HttpPost]
  4832. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4833. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4834. {
  4835. if (dto.CurrUserId < 1) return Ok(JsonView(false,MsgTips.UserId));
  4836. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4837. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4838. var permissions = new List<Grp_EnterExitCostPermission>();
  4839. foreach (var userId in dto.UserIds)
  4840. {
  4841. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  4842. }
  4843. if (permissions.Any())
  4844. {
  4845. _sqlSugar.BeginTran();
  4846. try
  4847. {
  4848. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  4849. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  4850. if (result < 1)
  4851. {
  4852. _sqlSugar.RollbackTran();
  4853. return Ok(JsonView(false));
  4854. }
  4855. }
  4856. catch (Exception ex)
  4857. {
  4858. _sqlSugar.RollbackTran();
  4859. return Ok(JsonView(false, ex.Message));
  4860. }
  4861. _sqlSugar.CommitTran();
  4862. return Ok(JsonView(true));
  4863. }
  4864. return Ok(JsonView(false));
  4865. }
  4866. /// <summary>
  4867. /// 团组模块 - 出入境费用 - Add And Update
  4868. /// </summary>
  4869. /// <returns></returns>
  4870. [HttpPost]
  4871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4872. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4873. {
  4874. try
  4875. {
  4876. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4877. if (dto.DayOtherPriceData.Any())
  4878. {
  4879. var inserList = dto.DayOtherPriceData
  4880. .Where(x => x.Id == 0)
  4881. .Select(x => new Grp_DayOtherPrice
  4882. {
  4883. Cost = x.Cost,
  4884. Id = x.Id,
  4885. CreateTime = DateTime.Now,
  4886. CreateUserId = dto.UserId,
  4887. Currency = x.Currency,
  4888. Diid = x.DiId,
  4889. Index = x.Index,
  4890. IsDel = 0,
  4891. SetDataId = x.SetDataId,
  4892. SubTotal = x.SubTotal,
  4893. Remark = x.Remark
  4894. })
  4895. .ToList();
  4896. var updateList = dto.DayOtherPriceData
  4897. .Where(x => x.Id != 0)
  4898. .Select(x => new Grp_DayOtherPrice
  4899. {
  4900. Cost = x.Cost,
  4901. Id = x.Id,
  4902. CreateTime = DateTime.Now,
  4903. CreateUserId = dto.UserId,
  4904. Currency = x.Currency,
  4905. Diid = x.DiId,
  4906. Index = x.Index,
  4907. IsDel = 0,
  4908. SetDataId = x.SetDataId,
  4909. SubTotal = x.SubTotal,
  4910. Remark = x.Remark
  4911. })
  4912. .ToList();
  4913. //添加
  4914. _sqlSugar.BeginTran();
  4915. if (inserList.Any())
  4916. {
  4917. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4918. }
  4919. if (updateList.Any())
  4920. {
  4921. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4922. }
  4923. _sqlSugar.CommitTran();
  4924. }
  4925. if (data.Code != 0)
  4926. {
  4927. return Ok(JsonView(false, data.Msg));
  4928. }
  4929. //生成默认文件pdf并且通知人员
  4930. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4931. {
  4932. DiId = dto.DiId,
  4933. ExportType = 1,
  4934. SubTypeId = 1005
  4935. }, "pdf");
  4936. //发送通知
  4937. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4938. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4939. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4940. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4941. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4942. //汇率信息记录
  4943. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4944. return Ok(JsonView(true, data.Msg, data.Data));
  4945. }
  4946. catch (Exception ex)
  4947. {
  4948. return Ok(JsonView(false, ex.Message));
  4949. }
  4950. }
  4951. /// <summary>
  4952. /// 团组模块 - 出入境费用 - Confirm 费用
  4953. /// </summary>
  4954. /// <returns></returns>
  4955. [HttpPost]
  4956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4957. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4958. {
  4959. //TODO:测试完毕需把对应的用户ID更改
  4960. //1、数据表添加字段
  4961. //2、更改字段接口()
  4962. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4963. //3、确认成功 给财务发送消息
  4964. if (_view.Code == 200)
  4965. {
  4966. if (dto.Type == 1)
  4967. {
  4968. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4969. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4970. }
  4971. }
  4972. return Ok(_view);
  4973. }
  4974. /// <summary>
  4975. /// 团组模块 - 出入境费用 - File download
  4976. /// </summary>
  4977. /// <param name="dto"></param>
  4978. /// <returns></returns>
  4979. [HttpPost]
  4980. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4981. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4982. {
  4983. try
  4984. {
  4985. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4986. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4987. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4988. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4989. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4990. 3 团组成员名单 1 团组成员名单", ""));
  4991. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  4992. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4993. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4994. //数据源
  4995. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4996. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4997. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4998. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4999. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  5000. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  5001. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  5002. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  5003. .Select((x, a, b) => new
  5004. {
  5005. x.Index,
  5006. itemName = a.Name,
  5007. CurrencyStr = b.Name,
  5008. x.Cost,
  5009. x.SubTotal,
  5010. x.Remark
  5011. })
  5012. .OrderBy((x) => x.Index)
  5013. .ToList(); //其他款项费用
  5014. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5015. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5016. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5017. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5018. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5019. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5020. .Select((tcl, dc, cc) => new ClientInfo
  5021. {
  5022. LastName = dc.LastName,
  5023. FirstName = dc.FirstName,
  5024. Sex = dc.Sex,
  5025. Birthday = dc.BirthDay,
  5026. Company = cc.CompanyFullName,
  5027. Job = dc.Job
  5028. })
  5029. .ToList();
  5030. foreach (var item in DeleClientList)
  5031. {
  5032. EncryptionProcessor.DecryptProperties(item);
  5033. }
  5034. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5035. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5036. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5037. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5038. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5039. if (dto.ExportType == 1) //明细表
  5040. {
  5041. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5042. {
  5043. //获取模板
  5044. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5045. //载入模板
  5046. Document doc = new Document(tempPath);
  5047. DocumentBuilder builder = new DocumentBuilder(doc);
  5048. //利用键值对存放数据
  5049. Dictionary<string, string> dic = new Dictionary<string, string>();
  5050. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5051. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5052. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5053. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5054. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5055. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5056. //境内费用(其他费用)
  5057. if (_EnterExitCosts.ChoiceOne == 1)
  5058. {
  5059. string row1_1 = "";
  5060. if (_EnterExitCosts.Visa > 0)
  5061. {
  5062. //insidePayTotal += _EnterExitCosts.Visa;
  5063. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5064. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5065. {
  5066. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5067. }
  5068. }
  5069. string row1_2 = "";
  5070. if (_EnterExitCosts.YiMiao > 0)
  5071. {
  5072. //insidePayTotal += _EnterExitCosts.YiMiao;
  5073. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5074. }
  5075. if (_EnterExitCosts.HeSuan > 0)
  5076. {
  5077. //insidePayTotal += _EnterExitCosts.HeSuan;
  5078. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5079. }
  5080. if (_EnterExitCosts.Service > 0)
  5081. {
  5082. //insidePayTotal += _EnterExitCosts.Service;
  5083. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5084. }
  5085. string row1_3 = "";
  5086. if (_EnterExitCosts.Safe > 0)
  5087. {
  5088. //insidePayTotal += _EnterExitCosts.Safe;
  5089. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5090. }
  5091. if (_EnterExitCosts.Ticket > 0)
  5092. {
  5093. //insidePayTotal += _EnterExitCosts.Ticket;
  5094. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5095. }
  5096. string row1 = "";
  5097. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5098. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5099. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5100. row1 += $"备注:{_EnterExitCosts.Remark}";
  5101. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5102. dic.Add("Row1Str", row1);
  5103. }
  5104. string airTotalStr = string.Empty,
  5105. airPriceStr = string.Empty;
  5106. //经济舱
  5107. if (_EnterExitCosts.SumJJC == 1)
  5108. {
  5109. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5110. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5111. }
  5112. //公务舱
  5113. if (_EnterExitCosts.SumGWC == 1)
  5114. {
  5115. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5116. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5117. }
  5118. //头等舱
  5119. if (_EnterExitCosts.SumTDC == 1)
  5120. {
  5121. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5122. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5123. }
  5124. string twoItemRemark = "备注:";
  5125. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark))
  5126. {
  5127. twoItemRemark = _EnterExitCosts.TwoItemRemark;
  5128. }
  5129. dic.Add("AirTotalStr", airTotalStr);
  5130. dic.Add("AirPriceStr", airPriceStr);
  5131. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5132. dic.Add("TwoItemRemark", twoItemRemark);
  5133. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5134. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5135. int table1Row = 0,
  5136. table2Row = 0,
  5137. table3Row = 0,
  5138. table4Row = 0,
  5139. table5Row = 0;
  5140. //住宿费
  5141. if (_EnterExitCosts.ChoiceThree == 1)
  5142. {
  5143. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5144. table1Row = dac1.Count;
  5145. #region 填充word表格内容
  5146. for (int i = 0; i < dac1.Count; i++)
  5147. {
  5148. Grp_DayAndCost dac = dac1[i];
  5149. if (dac == null) continue;
  5150. builder.MoveToCell(0, i, 0, 0);
  5151. builder.Write("第" + dac.Days.ToString() + "晚:");
  5152. builder.MoveToCell(0, i, 1, 0);
  5153. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5154. //builder.Write(dac.Place == null ? "" : dac.Place);
  5155. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5156. builder.MoveToCell(0, i, 2, 0);
  5157. builder.Write("费用标准:");
  5158. string curr = "";
  5159. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5160. if (currData != null)
  5161. {
  5162. curr = currData.Name;
  5163. }
  5164. builder.MoveToCell(0, i, 3, 0);
  5165. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5166. builder.MoveToCell(0, i, 4, 0);
  5167. builder.Write("费用小计:");
  5168. builder.MoveToCell(0, i, 5, 0);
  5169. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5170. }
  5171. #endregion
  5172. }
  5173. else dic.Add("SubZS", "0.00");
  5174. //删除多余行
  5175. while (table1.Rows.Count > table1Row)
  5176. {
  5177. table1.Rows.RemoveAt(table1Row);
  5178. }
  5179. //伙食费
  5180. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5181. if (_EnterExitCosts.ChoiceFour == 1)
  5182. {
  5183. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5184. table2Row = dac2.Count;
  5185. #region 填充word表格内容
  5186. for (int i = 0; i < dac2.Count; i++)
  5187. {
  5188. Grp_DayAndCost dac = dac2[i];
  5189. if (dac == null) continue;
  5190. builder.MoveToCell(1, i, 0, 0);
  5191. builder.Write("第" + dac.Days.ToString() + "天:");
  5192. builder.MoveToCell(1, i, 1, 0);
  5193. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5194. builder.MoveToCell(1, i, 2, 0);
  5195. builder.Write("费用标准:");
  5196. string curr = "";
  5197. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5198. if (currData != null)
  5199. {
  5200. curr = currData.Name;
  5201. }
  5202. builder.MoveToCell(1, i, 3, 0);
  5203. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5204. builder.MoveToCell(1, i, 4, 0);
  5205. builder.Write("费用小计:");
  5206. builder.MoveToCell(1, i, 5, 0);
  5207. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5208. }
  5209. #endregion
  5210. }
  5211. else dic.Add("SubHS", "0.00");
  5212. //删除多余行
  5213. while (table2.Rows.Count > table2Row)
  5214. {
  5215. table2.Rows.RemoveAt(table2Row);
  5216. }
  5217. //公杂费
  5218. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5219. if (_EnterExitCosts.ChoiceFive == 1)
  5220. {
  5221. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5222. table3Row = dac3.Count;
  5223. #region 填充word表格内容
  5224. for (int i = 0; i < dac3.Count; i++)
  5225. {
  5226. Grp_DayAndCost dac = dac3[i];
  5227. if (dac == null) continue;
  5228. builder.MoveToCell(2, i, 0, 0);
  5229. builder.Write("第" + dac.Days.ToString() + "天:");
  5230. builder.MoveToCell(2, i, 1, 0);
  5231. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5232. builder.MoveToCell(2, i, 2, 0);
  5233. builder.Write("费用标准:");
  5234. string curr = "";
  5235. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5236. if (currData != null)
  5237. {
  5238. curr = currData.Name;
  5239. }
  5240. builder.MoveToCell(2, i, 3, 0);
  5241. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5242. builder.MoveToCell(2, i, 4, 0);
  5243. builder.Write("费用小计:");
  5244. builder.MoveToCell(2, i, 5, 0);
  5245. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5246. }
  5247. //删除多余行
  5248. while (table3.Rows.Count > table3Row)
  5249. {
  5250. table3.Rows.RemoveAt(table3Row);
  5251. }
  5252. #endregion
  5253. }
  5254. else dic.Add("SubGZF", "0.00");
  5255. //删除多余行
  5256. while (table3.Rows.Count > table3Row)
  5257. {
  5258. table3.Rows.RemoveAt(table3Row);
  5259. }
  5260. //培训费
  5261. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5262. if (_EnterExitCosts.ChoiceSix == 1)
  5263. {
  5264. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5265. dic.Add("SubPX", pxStr);
  5266. table4Row = dac4.Count;
  5267. #region 填充word表格内容
  5268. for (int i = 0; i < dac4.Count; i++)
  5269. {
  5270. Grp_DayAndCost dac = dac4[i];
  5271. if (dac == null) continue;
  5272. builder.MoveToCell(3, i, 0, 0);
  5273. builder.Write("第" + dac.Days.ToString() + "天:");
  5274. builder.MoveToCell(3, i, 1, 0);
  5275. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5276. builder.MoveToCell(3, i, 2, 0);
  5277. builder.Write("费用标准:");
  5278. string curr = "";
  5279. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5280. if (currData != null)
  5281. {
  5282. curr = currData.Name;
  5283. }
  5284. builder.MoveToCell(3, i, 3, 0);
  5285. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5286. builder.MoveToCell(3, i, 4, 0);
  5287. builder.Write("费用小计:");
  5288. builder.MoveToCell(3, i, 5, 0);
  5289. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5290. }
  5291. #endregion
  5292. }
  5293. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  5294. //删除多余行
  5295. while (table4.Rows.Count > table4Row)
  5296. {
  5297. table4.Rows.RemoveAt(table4Row);
  5298. }
  5299. //其他费用
  5300. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5301. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5302. {
  5303. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5304. dic.Add("titleQi", qtStr);
  5305. table5Row = dac5.Count;
  5306. #region 填充word表格内容
  5307. for (int i = 0; i < dac5.Count; i++)
  5308. {
  5309. var dac = dac5[i];
  5310. if (dac == null) continue;
  5311. builder.MoveToCell(4, i, 0, 0);
  5312. builder.Write("第" + dac.Index.ToString() + "项:");
  5313. builder.MoveToCell(4, i, 1, 0);
  5314. builder.Write(dac.itemName);
  5315. builder.MoveToCell(4, i, 2, 0);
  5316. builder.Write("费用标准:");
  5317. builder.MoveToCell(4, i, 3, 0);
  5318. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5319. builder.MoveToCell(4, i, 4, 0);
  5320. builder.Write("费用小计:");
  5321. builder.MoveToCell(4, i, 5, 0);
  5322. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5323. builder.MoveToCell(4, i, 6, 0);
  5324. builder.Write("备注:");
  5325. builder.MoveToCell(4, i, 7, 0);
  5326. builder.Write(dac.Remark);
  5327. }
  5328. #endregion
  5329. }
  5330. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5331. //删除多余行
  5332. while (table5.Rows.Count > table5Row)
  5333. {
  5334. table5.Rows.RemoveAt(table5Row);
  5335. }
  5336. //加上其他费用
  5337. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5338. decimal subJJC = 0.00M,
  5339. subGWC = 0.00M,
  5340. subTDC = 0.00M;
  5341. //经济舱
  5342. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5343. //公务舱
  5344. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5345. //头等舱
  5346. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5347. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5348. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5349. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5350. #region 填充word模板书签内容
  5351. foreach (var key in dic.Keys)
  5352. {
  5353. Bookmark bookmark = doc.Range.Bookmarks[key];
  5354. if (bookmark != null)
  5355. {
  5356. builder.MoveToBookmark(key);
  5357. builder.Write(dic[key]);
  5358. }
  5359. }
  5360. #endregion
  5361. #region 设置页眉
  5362. string userLabel = string.Empty;
  5363. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5364. if (currUserInfo != null)
  5365. {
  5366. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5367. if (userInfo != null)
  5368. {
  5369. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5370. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5371. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5372. }
  5373. }
  5374. //设置页脚
  5375. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5376. #endregion
  5377. //文件名
  5378. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5379. AsposeHelper.removewatermark_v2180();
  5380. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5381. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5382. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5383. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5384. }
  5385. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5386. {
  5387. //获取模板
  5388. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5389. //载入模板
  5390. Document doc = new Document(tempPath);
  5391. DocumentBuilder builder = new DocumentBuilder(doc);
  5392. Dictionary<string, string> dic = new Dictionary<string, string>();
  5393. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5394. {
  5395. List<string> list = new List<string>();
  5396. try
  5397. {
  5398. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5399. foreach (var item in spilitArr)
  5400. {
  5401. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5402. var depCode = spDotandEmpty[2].Substring(0, 3);
  5403. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5404. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5405. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5406. list.Add(depName);
  5407. list.Add(arrName);
  5408. }
  5409. list = list.Distinct().ToList();
  5410. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5411. }
  5412. catch (Exception)
  5413. {
  5414. dic.Add("ReturnCode", "行程录入不正确!");
  5415. }
  5416. }
  5417. else
  5418. {
  5419. dic.Add("ReturnCode", "未录入行程!");
  5420. }
  5421. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5422. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5423. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5424. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5425. {
  5426. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5427. dic.Add("Day", sp.Days.ToString());
  5428. }
  5429. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5430. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5431. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5432. //dic.Add("Names", Names);
  5433. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5434. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5435. decimal dac1totalPrice = 0.00M;
  5436. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5437. foreach (var dac in dac1)
  5438. {
  5439. if (dac.SubTotal == 0.00M)
  5440. {
  5441. continue;
  5442. }
  5443. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5444. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5445. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5446. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5447. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5448. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5449. builder.Write(currency);//币种
  5450. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5451. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5452. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5453. builder.Write("");//人数
  5454. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5455. builder.Write("");//天数
  5456. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5457. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5458. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5459. decimal rate = 0.00M;
  5460. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5461. builder.Write(rate.ToString("#0.0000"));//汇率
  5462. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5463. decimal rbmPrice = dac.SubTotal;
  5464. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5465. accommodationStartIndex++;
  5466. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5467. }
  5468. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5469. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5470. {
  5471. table1.Rows.RemoveAt(i - 1);
  5472. foodandotherStartIndex--;
  5473. }
  5474. if (dac2.Count == dac3.Count)//国家 币种 金额
  5475. {
  5476. for (int i = 0; i < dac2.Count; i++)
  5477. {
  5478. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5479. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5480. }
  5481. }
  5482. decimal dac2totalPrice = 0.00M;
  5483. foreach (var dac in dac2)
  5484. {
  5485. if (dac.SubTotal == 0)
  5486. {
  5487. continue;
  5488. }
  5489. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5490. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5491. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5492. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5493. builder.Write(currency);//币种
  5494. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5495. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5496. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5497. builder.Write("");//人数
  5498. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5499. builder.Write("");//天数
  5500. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5501. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5502. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5503. decimal rate = 0.00M;
  5504. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5505. builder.Write(rate.ToString("#0.0000"));//汇率
  5506. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5507. decimal rbmPrice = dac.SubTotal;
  5508. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5509. foodandotherStartIndex++;
  5510. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5511. }
  5512. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5513. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5514. {
  5515. table1.Rows.RemoveAt(i - 1);
  5516. }
  5517. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5518. string otherFeeStr = "";
  5519. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5520. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5521. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5522. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5523. foreach (var otherInfo in dac5)
  5524. {
  5525. otherFeeStr += $"{otherInfo.itemName}{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5526. }
  5527. #endregion
  5528. if (otherFeeStr.Length > 0)
  5529. {
  5530. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5531. otherFeeStr = $"({otherFeeStr})";
  5532. dic.Add("OtherFeeStr", otherFeeStr);
  5533. }
  5534. //总计
  5535. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5536. //国际旅费
  5537. string outsideAir = string.Empty;
  5538. string allPriceAir = string.Empty;
  5539. if (_EnterExitCosts.SumJJC == 1)
  5540. {
  5541. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5542. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5543. }
  5544. if (_EnterExitCosts.SumGWC == 1)
  5545. {
  5546. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5547. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5548. }
  5549. if (_EnterExitCosts.SumTDC == 1)
  5550. {
  5551. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5552. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5553. }
  5554. dic.Add("InTravelPrice", $"({outsideAir})");
  5555. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5556. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5557. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5558. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5559. foreach (var key in dic.Keys)
  5560. {
  5561. builder.MoveToBookmark(key);
  5562. builder.Write(dic[key]);
  5563. }
  5564. //模板文件名
  5565. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5566. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5567. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5568. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5569. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5570. }
  5571. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5572. {
  5573. //获取模板
  5574. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5575. //载入模板
  5576. WorkbookDesigner designer = new WorkbookDesigner();
  5577. designer.Workbook = new Workbook(tempPath);
  5578. Dictionary<string, string> dic = new Dictionary<string, string>();
  5579. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5580. {
  5581. List<string> list = new List<string>();
  5582. try
  5583. {
  5584. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5585. foreach (var item in spilitArr)
  5586. {
  5587. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5588. var depCode = spDotandEmpty[2].Substring(0, 3);
  5589. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5590. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5591. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5592. list.Add(depName);
  5593. list.Add(arrName);
  5594. }
  5595. list = list.Distinct().ToList();
  5596. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5597. }
  5598. catch (Exception)
  5599. {
  5600. dic.Add("ReturnCode", "行程录入不正确!");
  5601. }
  5602. }
  5603. else
  5604. {
  5605. dic.Add("ReturnCode", "未录入行程!");
  5606. }
  5607. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5608. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5609. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5610. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5611. {
  5612. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5613. dic.Add("Day", sp.Days.ToString());
  5614. }
  5615. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5616. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5617. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5618. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5619. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5620. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5621. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5622. designer.SetDataSource("Name", Names);
  5623. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5624. designer.SetDataSource("Day", dic["Day"] + "天");
  5625. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5626. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5627. int startIndex = 10;
  5628. const int startIndexcopy = 10;
  5629. if (dac2.Count == dac3.Count)//国家 币种 金额
  5630. {
  5631. for (int i = 0; i < dac2.Count; i++)
  5632. {
  5633. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5634. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5635. }
  5636. }
  5637. DataTable dtdac1 = new DataTable();
  5638. List<string> place = new List<string>();
  5639. dtdac1.Columns.AddRange(new DataColumn[] {
  5640. new DataColumn(){ ColumnName = "city"},
  5641. new DataColumn(){ ColumnName = "curr"},
  5642. new DataColumn(){ ColumnName = "criterion"},
  5643. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5644. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5645. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5646. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5647. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5648. });
  5649. DataTable dtdac2 = new DataTable();
  5650. dtdac2.Columns.AddRange(new DataColumn[] {
  5651. new DataColumn(){ ColumnName = "city"},
  5652. new DataColumn(){ ColumnName = "curr"},
  5653. new DataColumn(){ ColumnName = "criterion"},
  5654. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5655. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5656. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5657. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5658. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5659. });
  5660. dtdac1.TableName = "tb1";
  5661. dtdac2.TableName = "tb2";
  5662. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5663. foreach (var item in dac1)
  5664. {
  5665. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5666. if (place.Contains(item.Place))
  5667. {
  5668. continue;
  5669. }
  5670. DataRow row = dtdac1.NewRow();
  5671. row["city"] = item.Place;
  5672. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5673. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5674. row["curr"] = currency;
  5675. row["rate"] = rate.ToString("#0.0000");
  5676. row["criterion"] = item.Cost.ToString("#0.00");
  5677. row["number"] = 1;
  5678. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5679. //row["costRMB"] = rbmPrice;
  5680. dtdac1.Rows.Add(row);
  5681. place.Add(item.Place);
  5682. }
  5683. place = new List<string>();
  5684. foreach (var item in dac2)
  5685. {
  5686. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5687. if (place.Contains(item.Place))
  5688. {
  5689. continue;
  5690. }
  5691. DataRow row = dtdac2.NewRow();
  5692. row["city"] = item.Place;
  5693. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5694. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5695. row["curr"] = currency;
  5696. row["rate"] = rate.ToString("#0.0000");
  5697. row["criterion"] = item.Cost.ToString("#0.00");
  5698. row["number"] = 1;
  5699. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5700. //row["cost"] = item.SubTotal;
  5701. //row["costRMB"] = rbmPrice;
  5702. dtdac2.Rows.Add(row);
  5703. place.Add(item.Place);
  5704. //dac2totalPrice += rbmPrice;
  5705. }
  5706. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5707. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5708. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5709. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5710. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5711. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5712. string cell4Str1 = string.Empty;
  5713. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5714. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5715. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5716. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5717. string cellStr = $" 5.其他费用(";
  5718. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5719. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5720. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5721. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5722. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5723. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5724. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5725. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5726. foreach (var otherInfo in dac5)
  5727. {
  5728. cellStr += $"{otherInfo.itemName}{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5729. }
  5730. #endregion
  5731. if (cellStr.Length > 8)
  5732. {
  5733. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5734. }
  5735. cellStr += ")";
  5736. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5737. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5738. decimal pxFee = dac4.Sum(it => it.Cost);
  5739. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5740. string celllastStr1 = "";
  5741. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5742. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5743. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5744. celllastStr1 += $",国际旅费 元";
  5745. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5746. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5747. designer.SetDataSource("cell4Str", cell4Str);
  5748. designer.SetDataSource("cellStr", cellStr);
  5749. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5750. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5751. designer.SetDataSource("celllastStr", celllastStr);
  5752. Workbook wb = designer.Workbook;
  5753. var sheet = wb.Worksheets[0];
  5754. //绑定datatable数据集
  5755. designer.SetDataSource(dtdac1);
  5756. designer.SetDataSource(dtdac2);
  5757. designer.Process();
  5758. var rowStart = dtdac1.Rows.Count;
  5759. while (rowStart > 0)
  5760. {
  5761. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5762. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5763. startIndex++;
  5764. rowStart--;
  5765. }
  5766. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5767. startIndex += 1; //总计行
  5768. rowStart = dtdac2.Rows.Count;
  5769. while (rowStart > 0)
  5770. {
  5771. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5772. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5773. startIndex++;
  5774. rowStart--;
  5775. }
  5776. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5777. wb.CalculateFormula(true);
  5778. //模板文件名
  5779. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5780. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5781. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5782. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5783. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5784. }
  5785. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5786. {
  5787. //获取模板
  5788. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5789. //载入模板
  5790. Document doc = new Document(tempPath);
  5791. DocumentBuilder builder = new DocumentBuilder(doc);
  5792. Dictionary<string, string> dic = new Dictionary<string, string>();
  5793. dic.Add("GroupName", _DelegationInfo.TeamName);
  5794. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5795. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5796. string missionLeaderJob = "";//负责人job
  5797. int groupNumber = 0; //团人数
  5798. if (DeleClientList.Count > 0)
  5799. {
  5800. missionLeader = DeleClientList[0]?.Name ?? "";
  5801. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5802. }
  5803. dic.Add("MissionLeader", missionLeader); //团负责人
  5804. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5805. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5806. #region MyRegion
  5807. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5808. //{
  5809. // List<string> list = new List<string>();
  5810. // try
  5811. // {
  5812. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5813. // foreach (var item in spilitArr)
  5814. // {
  5815. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5816. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5817. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5818. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5819. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5820. // list.Add(depName);
  5821. // list.Add(arrName);
  5822. // }
  5823. // list = list.Distinct().ToList();
  5824. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5825. // }
  5826. // catch (Exception)
  5827. // {
  5828. // dic.Add("ReturnCode", "行程录入不正确!");
  5829. // }
  5830. //}
  5831. //else
  5832. //{
  5833. // dic.Add("ReturnCode", "未录入行程!");
  5834. //}
  5835. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5836. dic.Add("ReturnCode", string.Join("、", countrys));
  5837. #endregion
  5838. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5839. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5840. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5841. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5842. //{
  5843. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5844. // dic.Add("Day", sp.Days.ToString());
  5845. //}
  5846. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5847. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5848. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5849. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5850. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5851. //培训人员名单
  5852. int cultivateRowIndex = 7;
  5853. foreach (var item in DeleClientList)
  5854. {
  5855. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5856. builder.Write(item.Name);
  5857. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5858. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5859. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5860. string birthDay = "";
  5861. if (item.Birthday != null)
  5862. {
  5863. DateTime dt = Convert.ToDateTime(item.Birthday);
  5864. birthDay = $"{dt.Year}.{dt.Month}";
  5865. }
  5866. builder.Write(birthDay);
  5867. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5868. builder.Write(item.Company);
  5869. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5870. builder.Write(item.Job);
  5871. cultivateRowIndex++;
  5872. }
  5873. //删除多余行
  5874. //cultivateRowIndex -= 2;
  5875. int delRows = 10 + 7 - cultivateRowIndex;
  5876. if (delRows > 0)
  5877. {
  5878. for (int i = 0; i < delRows; i++)
  5879. {
  5880. table1.Rows.RemoveAt(cultivateRowIndex);
  5881. //cultivateRowIndex++;
  5882. }
  5883. }
  5884. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5885. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5886. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5887. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5888. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5889. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5890. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5891. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5892. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5893. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5894. //其他费用
  5895. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5896. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5897. //其他费用合计
  5898. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5899. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5900. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5901. //公务舱合计
  5902. //国际旅费
  5903. string outsideJJ = "";
  5904. string allPriceJJ = "";
  5905. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5906. {
  5907. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5908. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5909. }
  5910. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5911. {
  5912. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5913. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5914. }
  5915. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5916. {
  5917. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5918. dic.Add("AirFeeTotal", airFeeTotalStr);
  5919. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5920. dic.Add("FeeTotal", feeTotalStr);
  5921. }
  5922. foreach (var key in dic.Keys)
  5923. {
  5924. builder.MoveToBookmark(key);
  5925. builder.Write(dic[key]);
  5926. }
  5927. //模板文件名
  5928. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5929. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5930. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5931. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5932. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5933. }
  5934. }
  5935. else if (dto.ExportType == 2) //表格
  5936. {
  5937. //利用键值对存放数据
  5938. Dictionary<string, string> dic = new Dictionary<string, string>();
  5939. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5940. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5941. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5942. dic.Add("Day", sp.Days.ToString());
  5943. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5944. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5945. {
  5946. //获取模板
  5947. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5948. //载入模板
  5949. Document doc = new Document(tempPath);
  5950. DocumentBuilder builder = new DocumentBuilder(doc);
  5951. dic.Add("TeamName", _DelegationInfo.TeamName);
  5952. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5953. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5954. string missionLeaderName = "",
  5955. missionLeaderJob = "";
  5956. if (DeleClientList.Count > 0)
  5957. {
  5958. missionLeaderName = DeleClientList[0].Name;
  5959. missionLeaderJob = DeleClientList[0].Job;
  5960. }
  5961. dic.Add("MissionLeaderName", missionLeaderName);
  5962. dic.Add("MissionLeaderJob", missionLeaderJob);
  5963. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5964. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5965. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5966. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5967. int rowCount = 10;//总人数行
  5968. int startRowIndex = 7; //起始行
  5969. for (int i = 0; i < DeleClientList.Count; i++)
  5970. {
  5971. builder.MoveToCell(0, startRowIndex, 0, 0);
  5972. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5973. builder.MoveToCell(0, startRowIndex, 1, 0);
  5974. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5975. builder.Write(sex);//性别
  5976. builder.MoveToCell(0, startRowIndex, 2, 0);
  5977. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5978. builder.MoveToCell(0, startRowIndex, 3, 0);
  5979. builder.Write(DeleClientList[i].Company);//工作单位
  5980. builder.MoveToCell(0, startRowIndex, 4, 0);
  5981. builder.Write(DeleClientList[i].Job);//职务及级别
  5982. builder.MoveToCell(0, startRowIndex, 5, 0);
  5983. builder.Write("");//人员属性
  5984. builder.MoveToCell(0, startRowIndex, 6, 0);
  5985. builder.Write("");//上次出国时间
  5986. startRowIndex++;
  5987. }
  5988. int nullRow = rowCount - DeleClientList.Count;//空行
  5989. for (int i = 0; i < nullRow; i++)
  5990. {
  5991. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5992. }
  5993. foreach (var key in dic.Keys)
  5994. {
  5995. builder.MoveToBookmark(key);
  5996. builder.Write(dic[key]);
  5997. }
  5998. //模板文件名
  5999. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  6000. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6001. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6002. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  6003. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  6004. }
  6005. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  6006. {
  6007. //获取模板
  6008. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  6009. //载入模板
  6010. Document doc = new Document(tempPath);
  6011. DocumentBuilder builder = new DocumentBuilder(doc);
  6012. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6013. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6014. dic.Add("Names", Names);
  6015. int accommodationRows = 12, foodandotherRows = 12;
  6016. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6017. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6018. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6019. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6020. int accommodationStartIndex = 6;
  6021. decimal dac1totalPrice = 0.00M;
  6022. foreach (var dac in dac1)
  6023. {
  6024. if (dac.SubTotal == 0)
  6025. {
  6026. continue;
  6027. }
  6028. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6029. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6030. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6031. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6032. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6033. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6034. builder.Write(currency);//币种
  6035. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6036. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6037. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6038. builder.Write("");//人数
  6039. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6040. builder.Write("");//天数
  6041. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6042. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6043. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6044. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6045. builder.Write(rate.ToString("#0.0000"));//汇率
  6046. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6047. decimal rbmPrice = rate * dac.SubTotal;
  6048. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6049. accommodationStartIndex++;
  6050. dac1totalPrice += rbmPrice;
  6051. }
  6052. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6053. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6054. builder.Write("小计");
  6055. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6056. builder.Write(dac1totalPrice.ToString("#0.00"));
  6057. accommodationStartIndex++;
  6058. int nullRow = accommodationRows - dac1.Count;
  6059. //删除空行
  6060. //if (nullRow > 0)
  6061. //{
  6062. // int rowIndex = accommodationStartIndex;
  6063. // for (int i = 0; i < nullRow; i++)
  6064. // {
  6065. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6066. // row.Remove();
  6067. // rowIndex++;
  6068. // }
  6069. //}
  6070. if (dac2.Count == dac3.Count)//国家 币种 金额
  6071. {
  6072. for (int i = 0; i < dac2.Count; i++)
  6073. {
  6074. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6075. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6076. }
  6077. }
  6078. int foodandotherStartIndex = 19;//
  6079. decimal dac2totalPrice = 0.00M;
  6080. foreach (var dac in dac2)
  6081. {
  6082. if (dac.SubTotal == 0)
  6083. {
  6084. continue;
  6085. }
  6086. //foodandotherStartIndex = 12;
  6087. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6088. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6089. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6090. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6091. builder.Write(currency);//币种
  6092. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6093. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6094. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6095. builder.Write("");//人数
  6096. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6097. builder.Write("");//天数
  6098. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6099. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6100. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6101. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6102. builder.Write(rate.ToString("#0.0000"));//汇率
  6103. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6104. decimal rbmPrice = rate * dac.SubTotal;
  6105. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6106. foodandotherStartIndex++;
  6107. dac2totalPrice += rbmPrice;
  6108. }
  6109. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6110. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6111. //删除空行
  6112. //if (dac2.Count < foodandotherRows)
  6113. //{
  6114. // while (table2.Rows.Count > dac2.Count)
  6115. // {
  6116. // table2.Rows.RemoveAt(dac2.Count);
  6117. // }
  6118. //}
  6119. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6120. string otherFeeStr = "";
  6121. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6122. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6123. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6124. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6125. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6126. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6127. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6128. foreach (var otherInfo in dac5)
  6129. {
  6130. otherFeeStr += $"{otherInfo.itemName}{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6131. }
  6132. #endregion
  6133. if (otherFeeStr.Length > 0)
  6134. {
  6135. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6136. otherFeeStr = $"({otherFeeStr})";
  6137. dic.Add("OtherFeeStr", otherFeeStr);
  6138. }
  6139. foreach (var key in dic.Keys)
  6140. {
  6141. builder.MoveToBookmark(key);
  6142. builder.Write(dic[key]);
  6143. }
  6144. //模板文件名
  6145. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6146. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6147. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6148. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6149. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6150. }
  6151. }
  6152. else if (dto.ExportType == 3)
  6153. {
  6154. if (dto.SubTypeId == 1) //团组成员名单
  6155. {
  6156. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6157. //获取模板
  6158. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6159. //载入模板
  6160. Document doc = new Document(tempPath);
  6161. DocumentBuilder builder = new DocumentBuilder(doc);
  6162. //获取word里所有表格
  6163. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6164. //获取所填表格的序数
  6165. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6166. var rowStart = tableOne.Rows[0]; //获取第1行
  6167. //循环赋值
  6168. for (int i = 0; i < DeleClientList.Count; i++)
  6169. {
  6170. builder.MoveToCell(0, i + 1, 0, 0);
  6171. builder.Write(DeleClientList[i].Name);
  6172. builder.MoveToCell(0, i + 1, 1, 0);
  6173. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6174. builder.Write(sex);
  6175. builder.MoveToCell(0, i + 1, 2, 0);
  6176. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6177. builder.MoveToCell(0, i + 1, 3, 0);
  6178. builder.Write(DeleClientList[i].Company);
  6179. builder.MoveToCell(0, i + 1, 4, 0);
  6180. builder.Write(DeleClientList[i].Job);
  6181. }
  6182. //删除多余行
  6183. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6184. {
  6185. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6186. }
  6187. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6188. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6189. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6190. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6191. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6192. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6193. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6194. }
  6195. }
  6196. return Ok(JsonView(400, "操作失败!", ""));
  6197. }
  6198. catch (Exception ex)
  6199. {
  6200. return Ok(JsonView(400, ex.Message, ""));
  6201. }
  6202. }
  6203. /// <summary>
  6204. /// 获取三公费用标准city
  6205. /// </summary>
  6206. /// <param name="placeData"></param>
  6207. /// <param name="nationalTravelFeeId"></param>
  6208. /// <returns></returns>
  6209. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6210. {
  6211. string _city = string.Empty;
  6212. if (placeData.Count < 1) return _city;
  6213. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6214. if (data == null) return _city;
  6215. string country = data.Country;
  6216. string city = data.City;
  6217. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6218. else _city = city;
  6219. return _city;
  6220. }
  6221. /// <summary>
  6222. /// 团组模块 - 出入境费用 - 明细表导出
  6223. /// </summary>
  6224. /// <returns></returns>
  6225. [HttpPost]
  6226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6227. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6228. {
  6229. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6230. if (data.Code != 0)
  6231. {
  6232. return Ok(JsonView(false, data.Msg));
  6233. }
  6234. return Ok(JsonView(true, data.Msg, data.Data));
  6235. }
  6236. /// <summary>
  6237. /// 团组模块 - 出入境费用 - 一键清空
  6238. /// </summary>
  6239. /// <returns></returns>
  6240. [HttpPost]
  6241. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6242. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6243. {
  6244. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6245. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6246. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6247. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6248. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6249. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6250. .SetColumns(x => new Grp_DayOtherPrice
  6251. {
  6252. IsDel = 1,
  6253. DeleteUserId = dto.UserId,
  6254. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6255. })
  6256. .ExecuteCommandAsync();
  6257. if (_view.Code == 0)
  6258. {
  6259. return Ok(JsonView(true, "操作成功"));
  6260. }
  6261. return Ok(JsonView(false, "操作失败"));
  6262. }
  6263. /// <summary>
  6264. /// 团组模块 - 出入境费用 - 子项删除
  6265. /// </summary>
  6266. /// <returns></returns>
  6267. [HttpPost]
  6268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6269. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6270. {
  6271. try
  6272. {
  6273. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6274. if (data.Code != 0)
  6275. {
  6276. return Ok(JsonView(false, data.Msg));
  6277. }
  6278. return Ok(JsonView(true, "操作成功!", data.Data));
  6279. }
  6280. catch (Exception ex)
  6281. {
  6282. return Ok(JsonView(false, ex.Message));
  6283. }
  6284. }
  6285. /// <summary>
  6286. /// 删除三公其他费用
  6287. /// </summary>
  6288. /// <param name="dto"></param>
  6289. /// <returns></returns>
  6290. [HttpPost]
  6291. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6292. {
  6293. var jw = JsonView(false,"删除失败!");
  6294. var data = new Grp_DayOtherPrice()
  6295. {
  6296. Id = dto.Id,
  6297. IsDel = 1,
  6298. DeleteUserId = dto.DeleteUserId,
  6299. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6300. };
  6301. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6302. if (del > 0)
  6303. {
  6304. jw.Code = 200;
  6305. jw.Msg = "删除成功!";
  6306. }
  6307. return Ok(jw);
  6308. }
  6309. /// <summary>
  6310. /// 团组模块 - 出入境国家费用标准 List
  6311. /// </summary>
  6312. /// <returns></returns>
  6313. [HttpPost]
  6314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6315. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6316. {
  6317. try
  6318. {
  6319. Stopwatch sw = new Stopwatch();
  6320. sw.Start();
  6321. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6322. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6323. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6324. Where gntf.Isdel = 0");
  6325. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6326. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6327. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6328. //foreach (var item in nationalTravel)
  6329. //{
  6330. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6331. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6332. // if (otherData != null)
  6333. // {
  6334. // cityData.Remove(otherData);
  6335. // cityData.Add(otherData);
  6336. // }
  6337. // nationalTravelFeeData1.Add(new
  6338. // {
  6339. // Country = item.Country,
  6340. // CityData = cityData
  6341. // });
  6342. //}
  6343. sw.Stop();
  6344. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6345. }
  6346. catch (Exception ex)
  6347. {
  6348. return Ok(JsonView(false, ex.Message));
  6349. throw;
  6350. }
  6351. }
  6352. /// <summary>
  6353. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6354. /// </summary>
  6355. /// <returns></returns>
  6356. [HttpPost]
  6357. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6358. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6359. {
  6360. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6361. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6362. List<string> countryData = new List<string>();
  6363. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6364. countryData = countryData.Distinct().ToList();
  6365. List<dynamic> dataSource = new List<dynamic>();
  6366. foreach (var item in countryData)
  6367. {
  6368. List<string> cityData1 = new List<string>();
  6369. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6370. var countryData2 = new
  6371. {
  6372. CountryName = item,
  6373. CityData = cityData1
  6374. };
  6375. dataSource.Add(countryData2);
  6376. }
  6377. return Ok(JsonView(true, "查询成功!", dataSource));
  6378. }
  6379. /// <summary>
  6380. /// 团组模块 - 出入境国家费用标准 Page List
  6381. /// </summary>
  6382. /// <returns></returns>
  6383. [HttpPost]
  6384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6385. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6386. {
  6387. int portId = dto.PortType;
  6388. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6389. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6390. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6391. string whereSql = string.Empty;
  6392. if (!string.IsNullOrEmpty(dto.Country))
  6393. {
  6394. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6395. }
  6396. if (!string.IsNullOrEmpty(dto.City))
  6397. {
  6398. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6399. }
  6400. string pageSql = string.Format(@"Select * From (
  6401. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6402. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6403. From Grp_NationalTravelFee gntf
  6404. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6405. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6406. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6407. RefAsync<int> total = 0;
  6408. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6409. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6410. }
  6411. /// <summary>
  6412. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6413. /// </summary>
  6414. /// <returns></returns>
  6415. [HttpPost]
  6416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6417. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6418. {
  6419. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6420. int portId = dto.PortType;
  6421. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6422. string whereSql = string.Empty;
  6423. if (!string.IsNullOrEmpty(dto.Country))
  6424. {
  6425. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6426. }
  6427. if (!string.IsNullOrEmpty(dto.City))
  6428. {
  6429. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6430. }
  6431. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6432. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6433. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6434. From Grp_NationalTravelFee gntf
  6435. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6436. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6437. Where gntf.Isdel = 0 {0} ", whereSql);
  6438. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6439. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6440. }
  6441. /// <summary>
  6442. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6443. /// </summary>
  6444. /// <returns></returns>
  6445. [HttpPost]
  6446. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6447. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6448. {
  6449. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6450. if (data.Code != 0)
  6451. {
  6452. return Ok(JsonView(false, data.Msg));
  6453. }
  6454. return Ok(JsonView(true, "操作成功!", data.Data));
  6455. }
  6456. /// <summary>
  6457. /// 团组模块 - 出入境国家费用标准 - Del
  6458. /// </summary>
  6459. /// <returns></returns>
  6460. [HttpPost]
  6461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6462. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6463. {
  6464. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6465. {
  6466. Id = dto.Id,
  6467. DeleteUserId = dto.DeleteUserId,
  6468. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6469. IsDel = 1
  6470. };
  6471. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6472. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6473. .WhereColumns(it => new { it.Id })
  6474. .ExecuteCommandAsync();
  6475. if (delStatus <= 0)
  6476. {
  6477. return Ok(JsonView(false, "删除失败!"));
  6478. }
  6479. return Ok(JsonView(true, "操作成功!"));
  6480. }
  6481. /// <summary>
  6482. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6483. /// 注:Get 请求Headers 加 Token
  6484. /// </summary>
  6485. /// <param name="groupId"></param>
  6486. /// <returns></returns>
  6487. [HttpGet("{groupId}")]
  6488. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6489. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6490. {
  6491. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6492. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6493. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6494. data.ForEach(x =>
  6495. {
  6496. x.CreateUserId = _currUserInfo.UserId;
  6497. });
  6498. if (data.Any())
  6499. {
  6500. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6501. if (add > 0)
  6502. {
  6503. return Ok(JsonView(true, "操作成功!"));
  6504. }
  6505. }
  6506. return Ok(JsonView(false, "未操作!"));
  6507. }
  6508. #endregion
  6509. #region 团组经理模块 出入境费用-草稿
  6510. /// <summary>
  6511. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6512. /// </summary>
  6513. /// <returns></returns>
  6514. [HttpPost]
  6515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6516. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6517. {
  6518. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6519. .Where(x => x.IsDel == 0)
  6520. .OrderByDescending(x => x.CreateTime)
  6521. .Select(x => new { x.Id, x.DraftName })
  6522. .ToListAsync();
  6523. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6524. //SetDataInfoView
  6525. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6526. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6527. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6528. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6529. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6530. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6531. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6532. //默认币种显示
  6533. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  6534. {
  6535. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  6536. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  6537. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  6538. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  6539. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  6540. };
  6541. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6542. if (_currencyRate.Count > 0)
  6543. {
  6544. foreach (var item in _currencyInfos)
  6545. {
  6546. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6547. if (rateInfo != null)
  6548. {
  6549. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6550. rate1 *= 1.035M;
  6551. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6552. }
  6553. }
  6554. }
  6555. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6556. return Ok(JsonView(true, "查询成功!", new
  6557. {
  6558. DraftNameDatas = draftNameDatas,
  6559. CurrencyData = _CurrencyData,
  6560. WordTypeData = _WordTypeData,
  6561. ExcelTypeData = _ExcelTypeData,
  6562. CurrencyInit = _currencyInfos,
  6563. ViewPermissionData = viewPermissionData
  6564. }));
  6565. }
  6566. /// <summary>
  6567. /// 团组模块 - 出入境费用-草稿
  6568. /// 实时汇率 tips
  6569. /// 签证费用 tips
  6570. /// 机票费用 tips
  6571. /// </summary>
  6572. /// <returns></returns>
  6573. [HttpPost]
  6574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6575. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6576. {
  6577. //var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6578. //默认币种显示
  6579. var _currencyInfos = _currencyInit;
  6580. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6581. List<dynamic> reteInfos = new List<dynamic>();
  6582. if (_currencyRate.Count > 0)
  6583. {
  6584. foreach (var item in _currencyInfos)
  6585. {
  6586. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6587. if (rateInfo != null)
  6588. {
  6589. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6590. decimal rate1 = item.Rate;
  6591. rate1 *= 1.03M;
  6592. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6593. reteInfos.Add(new
  6594. {
  6595. currCode = item.CurrencyCode,
  6596. currName = item.CurrencyName,
  6597. rate = rate2,
  6598. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6599. });
  6600. }
  6601. }
  6602. }
  6603. //var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  6604. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6605. return Ok(JsonView(true, "查询成功!", new
  6606. {
  6607. //GroupNameData = groupNameData.Data,
  6608. //visaData = visaData.Data,
  6609. //airData = airData.Data,
  6610. reteInfos = reteInfos
  6611. }));
  6612. }
  6613. /// <summary>
  6614. /// 团组模块 - 出入境费用-草稿 - Info
  6615. /// </summary>
  6616. /// <returns></returns>
  6617. [HttpPost]
  6618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6619. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6620. {
  6621. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6622. }
  6623. /// <summary>
  6624. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6625. /// </summary>
  6626. /// <returns></returns>
  6627. [HttpPost]
  6628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6629. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6630. {
  6631. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6632. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6633. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6634. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6635. foreach (var userId in dto.UserIds)
  6636. {
  6637. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6638. }
  6639. if (permissions.Any())
  6640. {
  6641. _sqlSugar.BeginTran();
  6642. try
  6643. {
  6644. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6645. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6646. if (result < 1)
  6647. {
  6648. _sqlSugar.RollbackTran();
  6649. return Ok(JsonView(false));
  6650. }
  6651. }
  6652. catch (Exception ex)
  6653. {
  6654. _sqlSugar.RollbackTran();
  6655. return Ok(JsonView(false, ex.Message));
  6656. }
  6657. _sqlSugar.CommitTran();
  6658. return Ok(JsonView(true));
  6659. }
  6660. return Ok(JsonView(false));
  6661. }
  6662. /// <summary>
  6663. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6664. /// </summary>
  6665. /// <returns></returns>
  6666. [HttpPost]
  6667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6668. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6669. {
  6670. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6671. if (data.Code != 0)
  6672. {
  6673. return Ok(JsonView(false, data.Msg));
  6674. }
  6675. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6676. //汇率信息记录
  6677. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6678. return Ok(JsonView(true, data.Msg, data.Data));
  6679. }
  6680. /// <summary>
  6681. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6682. /// </summary>
  6683. /// <param name="dto"></param>
  6684. /// <returns></returns>
  6685. [HttpPost]
  6686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6687. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6688. {
  6689. try
  6690. {
  6691. var id = dto.Id;
  6692. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6693. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6694. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6695. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6696. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6697. 3 团组成员名单 1 团组成员名单", ""));
  6698. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6699. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6700. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6701. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6702. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6703. //数据源
  6704. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6705. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6706. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6707. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6708. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6709. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6710. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6711. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6712. .Select((x, a, b) => new
  6713. {
  6714. x.Index,
  6715. itemName = a.Name,
  6716. CurrencyStr = b.Name,
  6717. x.Cost,
  6718. x.SubTotal,
  6719. x.Remark
  6720. })
  6721. .OrderBy((x) => x.Index)
  6722. .ToList(); //其他款项费用
  6723. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6724. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6725. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6726. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6727. if (dto.ExportType == 1) //明细表
  6728. {
  6729. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6730. {
  6731. //获取模板
  6732. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6733. //载入模板
  6734. Document doc = new Document(tempPath);
  6735. DocumentBuilder builder = new DocumentBuilder(doc);
  6736. //利用键值对存放数据
  6737. Dictionary<string, string> dic = new Dictionary<string, string>();
  6738. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6739. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6740. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6741. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6742. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6743. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6744. //境内费用(其他费用)
  6745. if (_EnterExitCosts.ChoiceOne == 1)
  6746. {
  6747. string row1_1 = "";
  6748. if (_EnterExitCosts.Visa > 0)
  6749. {
  6750. //insidePayTotal += _EnterExitCosts.Visa;
  6751. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6752. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6753. {
  6754. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6755. }
  6756. }
  6757. string row1_2 = "";
  6758. if (_EnterExitCosts.YiMiao > 0)
  6759. {
  6760. //insidePayTotal += _EnterExitCosts.YiMiao;
  6761. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6762. }
  6763. if (_EnterExitCosts.HeSuan > 0)
  6764. {
  6765. //insidePayTotal += _EnterExitCosts.HeSuan;
  6766. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6767. }
  6768. if (_EnterExitCosts.Service > 0)
  6769. {
  6770. //insidePayTotal += _EnterExitCosts.Service;
  6771. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6772. }
  6773. string row1_3 = "";
  6774. if (_EnterExitCosts.Safe > 0)
  6775. {
  6776. //insidePayTotal += _EnterExitCosts.Safe;
  6777. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6778. }
  6779. if (_EnterExitCosts.Ticket > 0)
  6780. {
  6781. //insidePayTotal += _EnterExitCosts.Ticket;
  6782. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6783. }
  6784. string row1 = "";
  6785. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6786. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6787. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6788. row1 += $"备注:{_EnterExitCosts.Remark}";
  6789. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6790. dic.Add("Row1Str", row1);
  6791. }
  6792. string airTotalStr = string.Empty,
  6793. airPriceStr = string.Empty;
  6794. //经济舱
  6795. if (_EnterExitCosts.SumJJC == 1)
  6796. {
  6797. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6798. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6799. }
  6800. //公务舱
  6801. if (_EnterExitCosts.SumGWC == 1)
  6802. {
  6803. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6804. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6805. }
  6806. //头等舱
  6807. if (_EnterExitCosts.SumTDC == 1)
  6808. {
  6809. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6810. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6811. }
  6812. string twoItemRemark = "备注:";
  6813. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark))
  6814. {
  6815. twoItemRemark = _EnterExitCosts.TwoItemRemark;
  6816. }
  6817. dic.Add("AirTotalStr", airTotalStr);
  6818. dic.Add("AirPriceStr", airPriceStr);
  6819. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6820. dic.Add("TwoItemRemark", twoItemRemark);
  6821. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6822. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6823. int table1Row = 0,
  6824. table2Row = 0,
  6825. table3Row = 0,
  6826. table4Row = 0,
  6827. table5Row = 0;
  6828. //住宿费
  6829. if (_EnterExitCosts.ChoiceThree == 1)
  6830. {
  6831. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6832. table1Row = dac1.Count;
  6833. #region 填充word表格内容
  6834. for (int i = 0; i < dac1.Count; i++)
  6835. {
  6836. var dac = dac1[i];
  6837. if (dac == null) continue;
  6838. builder.MoveToCell(0, i, 0, 0);
  6839. builder.Write("第" + dac.Days.ToString() + "晚:");
  6840. builder.MoveToCell(0, i, 1, 0);
  6841. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6842. //builder.Write(dac.Place == null ? "" : dac.Place);
  6843. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6844. builder.MoveToCell(0, i, 2, 0);
  6845. builder.Write("费用标准:");
  6846. string curr = "";
  6847. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6848. if (currData != null)
  6849. {
  6850. curr = currData.Name;
  6851. }
  6852. builder.MoveToCell(0, i, 3, 0);
  6853. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6854. builder.MoveToCell(0, i, 4, 0);
  6855. builder.Write("费用小计:");
  6856. builder.MoveToCell(0, i, 5, 0);
  6857. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6858. }
  6859. #endregion
  6860. }
  6861. else dic.Add("SubZS", "0.00");
  6862. //删除多余行
  6863. while (table1.Rows.Count > table1Row)
  6864. {
  6865. table1.Rows.RemoveAt(table1Row);
  6866. }
  6867. //伙食费
  6868. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6869. if (_EnterExitCosts.ChoiceFour == 1)
  6870. {
  6871. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6872. table2Row = dac2.Count;
  6873. #region 填充word表格内容
  6874. for (int i = 0; i < dac2.Count; i++)
  6875. {
  6876. var dac = dac2[i];
  6877. if (dac == null) continue;
  6878. builder.MoveToCell(1, i, 0, 0);
  6879. builder.Write("第" + dac.Days.ToString() + "天:");
  6880. builder.MoveToCell(1, i, 1, 0);
  6881. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6882. builder.MoveToCell(1, i, 2, 0);
  6883. builder.Write("费用标准:");
  6884. string curr = "";
  6885. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6886. if (currData != null)
  6887. {
  6888. curr = currData.Name;
  6889. }
  6890. builder.MoveToCell(1, i, 3, 0);
  6891. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6892. builder.MoveToCell(1, i, 4, 0);
  6893. builder.Write("费用小计:");
  6894. builder.MoveToCell(1, i, 5, 0);
  6895. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6896. }
  6897. #endregion
  6898. }
  6899. else dic.Add("SubHS", "0.00");
  6900. //删除多余行
  6901. while (table2.Rows.Count > table2Row)
  6902. {
  6903. table2.Rows.RemoveAt(table2Row);
  6904. }
  6905. //公杂费
  6906. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6907. if (_EnterExitCosts.ChoiceFive == 1)
  6908. {
  6909. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6910. table3Row = dac3.Count;
  6911. #region 填充word表格内容
  6912. for (int i = 0; i < dac3.Count; i++)
  6913. {
  6914. var dac = dac3[i];
  6915. if (dac == null) continue;
  6916. builder.MoveToCell(2, i, 0, 0);
  6917. builder.Write("第" + dac.Days.ToString() + "天:");
  6918. builder.MoveToCell(2, i, 1, 0);
  6919. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6920. builder.MoveToCell(2, i, 2, 0);
  6921. builder.Write("费用标准:");
  6922. string curr = "";
  6923. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6924. if (currData != null)
  6925. {
  6926. curr = currData.Name;
  6927. }
  6928. builder.MoveToCell(2, i, 3, 0);
  6929. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6930. builder.MoveToCell(2, i, 4, 0);
  6931. builder.Write("费用小计:");
  6932. builder.MoveToCell(2, i, 5, 0);
  6933. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6934. }
  6935. //删除多余行
  6936. while (table3.Rows.Count > table3Row)
  6937. {
  6938. table3.Rows.RemoveAt(table3Row);
  6939. }
  6940. #endregion
  6941. }
  6942. else dic.Add("SubGZF", "0.00");
  6943. //删除多余行
  6944. while (table3.Rows.Count > table3Row)
  6945. {
  6946. table3.Rows.RemoveAt(table3Row);
  6947. }
  6948. //培训费
  6949. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6950. if (_EnterExitCosts.ChoiceSix == 1)
  6951. {
  6952. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6953. dic.Add("SubPX", pxStr);
  6954. table4Row = dac4.Count;
  6955. #region 填充word表格内容
  6956. for (int i = 0; i < dac4.Count; i++)
  6957. {
  6958. var dac = dac4[i];
  6959. if (dac == null) continue;
  6960. builder.MoveToCell(3, i, 0, 0);
  6961. builder.Write("第" + dac.Days.ToString() + "天:");
  6962. builder.MoveToCell(3, i, 1, 0);
  6963. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6964. builder.MoveToCell(3, i, 2, 0);
  6965. builder.Write("费用标准:");
  6966. string curr = "";
  6967. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6968. if (currData != null)
  6969. {
  6970. curr = currData.Name;
  6971. }
  6972. builder.MoveToCell(3, i, 3, 0);
  6973. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6974. builder.MoveToCell(3, i, 4, 0);
  6975. builder.Write("费用小计:");
  6976. builder.MoveToCell(3, i, 5, 0);
  6977. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6978. }
  6979. #endregion
  6980. }
  6981. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  6982. //删除多余行
  6983. while (table4.Rows.Count > table4Row)
  6984. {
  6985. table4.Rows.RemoveAt(table4Row);
  6986. }
  6987. //其他费用
  6988. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6989. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6990. {
  6991. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6992. dic.Add("titleQi", qtStr);
  6993. table5Row = dac5.Count;
  6994. #region 填充word表格内容
  6995. for (int i = 0; i < dac5.Count; i++)
  6996. {
  6997. var dac = dac5[i];
  6998. if (dac == null) continue;
  6999. builder.MoveToCell(4, i, 0, 0);
  7000. builder.Write("第" + dac.Index.ToString() + "项:");
  7001. builder.MoveToCell(4, i, 1, 0);
  7002. builder.Write(dac.itemName);
  7003. builder.MoveToCell(4, i, 2, 0);
  7004. builder.Write("费用标准:");
  7005. builder.MoveToCell(4, i, 3, 0);
  7006. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7007. builder.MoveToCell(4, i, 4, 0);
  7008. builder.Write("费用小计:");
  7009. builder.MoveToCell(4, i, 5, 0);
  7010. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7011. builder.MoveToCell(4, i, 6, 0);
  7012. builder.Write("备注:");
  7013. builder.MoveToCell(4, i, 7, 0);
  7014. builder.Write(dac.Remark);
  7015. }
  7016. #endregion
  7017. }
  7018. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7019. //删除多余行
  7020. while (table5.Rows.Count > table5Row)
  7021. {
  7022. table5.Rows.RemoveAt(table5Row);
  7023. }
  7024. //加上其他费用
  7025. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7026. decimal subJJC = 0.00M,
  7027. subGWC = 0.00M,
  7028. subTDC = 0.00M;
  7029. //经济舱
  7030. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7031. //公务舱
  7032. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7033. //头等舱
  7034. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7035. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7036. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7037. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7038. #region 填充word模板书签内容
  7039. foreach (var key in dic.Keys)
  7040. {
  7041. Bookmark bookmark = doc.Range.Bookmarks[key];
  7042. if (bookmark != null)
  7043. {
  7044. builder.MoveToBookmark(key);
  7045. builder.Write(dic[key]);
  7046. }
  7047. }
  7048. #endregion
  7049. //文件名
  7050. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7051. strFileName = CommonFun.ValidFileName(strFileName);
  7052. AsposeHelper.removewatermark_v2180();
  7053. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7054. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7055. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7056. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7057. }
  7058. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7059. {
  7060. //获取模板
  7061. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7062. //载入模板
  7063. Document doc = new Document(tempPath);
  7064. DocumentBuilder builder = new DocumentBuilder(doc);
  7065. Dictionary<string, string> dic = new Dictionary<string, string>();
  7066. string returnCodeLabel = string.Empty;
  7067. if (nationalTravelFeeData.Any())
  7068. {
  7069. List<string> list = new List<string>();
  7070. foreach (var item in nationalTravelFeeData)
  7071. {
  7072. list.Add($"{item.Country}({item.City})");
  7073. }
  7074. list = list.Distinct().ToList();
  7075. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7076. }
  7077. var countryLabel = string.Empty;
  7078. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7079. if (countryData.Any())
  7080. {
  7081. countryLabel = string.Join("、", countryData);
  7082. }
  7083. dic.Add("ReturnCodeAir", returnCodeLabel);
  7084. dic.Add("VisitStartDate", "-");
  7085. dic.Add("VisitEndDate", "-");
  7086. dic.Add("Day", "-");
  7087. dic.Add("VisitCountry", countryLabel);
  7088. dic.Add("ClientUnit", "-");
  7089. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7090. //dic.Add("Names", Names);
  7091. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7092. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7093. decimal dac1totalPrice = 0.00M;
  7094. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7095. foreach (var dac in dac1)
  7096. {
  7097. if (dac.SubTotal == 0.00M)
  7098. {
  7099. continue;
  7100. }
  7101. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7102. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7103. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7104. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7105. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7106. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7107. builder.Write(currency);//币种
  7108. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7109. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7110. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7111. builder.Write("");//人数
  7112. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7113. builder.Write("");//天数
  7114. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7115. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7116. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7117. decimal rate = 0.00M;
  7118. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7119. builder.Write(rate.ToString("#0.0000"));//汇率
  7120. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7121. decimal rbmPrice = dac.SubTotal;
  7122. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7123. accommodationStartIndex++;
  7124. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7125. }
  7126. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7127. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7128. {
  7129. table1.Rows.RemoveAt(i - 1);
  7130. foodandotherStartIndex--;
  7131. }
  7132. if (dac2.Count == dac3.Count)//国家 币种 金额
  7133. {
  7134. for (int i = 0; i < dac2.Count; i++)
  7135. {
  7136. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7137. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7138. }
  7139. }
  7140. decimal dac2totalPrice = 0.00M;
  7141. foreach (var dac in dac2)
  7142. {
  7143. if (dac.SubTotal == 0)
  7144. {
  7145. continue;
  7146. }
  7147. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7148. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7149. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7150. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7151. builder.Write(currency);//币种
  7152. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7153. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7154. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7155. builder.Write("");//人数
  7156. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7157. builder.Write("");//天数
  7158. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7159. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7160. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7161. decimal rate = 0.00M;
  7162. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7163. builder.Write(rate.ToString("#0.0000"));//汇率
  7164. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7165. decimal rbmPrice = dac.SubTotal;
  7166. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7167. foodandotherStartIndex++;
  7168. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7169. }
  7170. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7171. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7172. {
  7173. table1.Rows.RemoveAt(i - 1);
  7174. }
  7175. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7176. string otherFeeStr = "";
  7177. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7178. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7179. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7180. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7181. foreach (var otherInfo in dac5)
  7182. {
  7183. otherFeeStr += $"{otherInfo.itemName}{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7184. }
  7185. #endregion
  7186. if (otherFeeStr.Length > 0)
  7187. {
  7188. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7189. otherFeeStr = $"({otherFeeStr})";
  7190. dic.Add("OtherFeeStr", otherFeeStr);
  7191. }
  7192. //总计
  7193. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7194. //国际旅费
  7195. string outsideAir = string.Empty;
  7196. string allPriceAir = string.Empty;
  7197. if (_EnterExitCosts.SumJJC == 1)
  7198. {
  7199. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7200. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7201. }
  7202. if (_EnterExitCosts.SumGWC == 1)
  7203. {
  7204. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7205. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7206. }
  7207. if (_EnterExitCosts.SumTDC == 1)
  7208. {
  7209. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7210. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7211. }
  7212. dic.Add("InTravelPrice", $"({outsideAir})");
  7213. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7214. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7215. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7216. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7217. foreach (var key in dic.Keys)
  7218. {
  7219. builder.MoveToBookmark(key);
  7220. builder.Write(dic[key]);
  7221. }
  7222. //模板文件名
  7223. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7224. strFileName = CommonFun.ValidFileName(strFileName);
  7225. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7226. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7227. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7228. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7229. }
  7230. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7231. {
  7232. //获取模板
  7233. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7234. //载入模板
  7235. WorkbookDesigner designer = new WorkbookDesigner();
  7236. designer.Workbook = new Workbook(tempPath);
  7237. Dictionary<string, string> dic = new Dictionary<string, string>();
  7238. string returnCodeLabel = string.Empty;
  7239. if (nationalTravelFeeData.Any())
  7240. {
  7241. List<string> list = new List<string>();
  7242. foreach (var item in nationalTravelFeeData)
  7243. {
  7244. list.Add($"{item.Country}({item.City})");
  7245. }
  7246. list = list.Distinct().ToList();
  7247. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7248. }
  7249. var countryLabel = string.Empty;
  7250. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7251. if (countryData.Any())
  7252. {
  7253. countryLabel = string.Join("、", countryData);
  7254. }
  7255. dic.Add("ReturnCodeAir", returnCodeLabel);
  7256. dic.Add("VisitStartDate", "-");
  7257. dic.Add("VisitEndDate", "-");
  7258. dic.Add("Day", "0");
  7259. dic.Add("VisitCountry", countryLabel);
  7260. dic.Add("ClientUnit", "-");
  7261. designer.SetDataSource("ClientUnit", "-");
  7262. designer.SetDataSource("VisitCountry", countryLabel);
  7263. designer.SetDataSource("Group", "-");
  7264. designer.SetDataSource("ClientUnitTitle", "-");
  7265. designer.SetDataSource("Name", "-");
  7266. designer.SetDataSource("VisitStartDate", "-" );
  7267. designer.SetDataSource("Day", "0");
  7268. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7269. designer.SetDataSource("ReturnCodeAir", "-");
  7270. int startIndex = 10;
  7271. const int startIndexcopy = 10;
  7272. if (dac2.Count == dac3.Count)//国家 币种 金额
  7273. {
  7274. for (int i = 0; i < dac2.Count; i++)
  7275. {
  7276. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7277. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7278. }
  7279. }
  7280. DataTable dtdac1 = new DataTable();
  7281. List<string> place = new List<string>();
  7282. dtdac1.Columns.AddRange(new DataColumn[] {
  7283. new DataColumn(){ ColumnName = "city"},
  7284. new DataColumn(){ ColumnName = "curr"},
  7285. new DataColumn(){ ColumnName = "criterion"},
  7286. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7287. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7288. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7289. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7290. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7291. });
  7292. DataTable dtdac2 = new DataTable();
  7293. dtdac2.Columns.AddRange(new DataColumn[] {
  7294. new DataColumn(){ ColumnName = "city"},
  7295. new DataColumn(){ ColumnName = "curr"},
  7296. new DataColumn(){ ColumnName = "criterion"},
  7297. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7298. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7299. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7300. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7301. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7302. });
  7303. dtdac1.TableName = "tb1";
  7304. dtdac2.TableName = "tb2";
  7305. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7306. foreach (var item in dac1)
  7307. {
  7308. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7309. if (place.Contains(item.Place))
  7310. {
  7311. continue;
  7312. }
  7313. DataRow row = dtdac1.NewRow();
  7314. row["city"] = item.Place;
  7315. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7316. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7317. row["curr"] = currency;
  7318. row["rate"] = rate.ToString("#0.0000");
  7319. row["criterion"] = item.Cost.ToString("#0.00");
  7320. row["number"] = 1;
  7321. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7322. //row["costRMB"] = rbmPrice;
  7323. dtdac1.Rows.Add(row);
  7324. place.Add(item.Place);
  7325. }
  7326. place = new List<string>();
  7327. foreach (var item in dac2)
  7328. {
  7329. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7330. if (place.Contains(item.Place))
  7331. {
  7332. continue;
  7333. }
  7334. DataRow row = dtdac2.NewRow();
  7335. row["city"] = item.Place;
  7336. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7337. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7338. row["curr"] = currency;
  7339. row["rate"] = rate.ToString("#0.0000");
  7340. row["criterion"] = item.Cost.ToString("#0.00");
  7341. row["number"] = 1;
  7342. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7343. //row["cost"] = item.SubTotal;
  7344. //row["costRMB"] = rbmPrice;
  7345. dtdac2.Rows.Add(row);
  7346. place.Add(item.Place);
  7347. //dac2totalPrice += rbmPrice;
  7348. }
  7349. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7350. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7351. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7352. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7353. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  7354. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  7355. string cell4Str1 = string.Empty;
  7356. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  7357. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  7358. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  7359. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7360. string cellStr = $" 5.其他费用(";
  7361. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7362. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7363. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7364. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7365. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7366. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7367. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7368. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7369. foreach (var otherInfo in dac5)
  7370. {
  7371. cellStr += $"{otherInfo.itemName}{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7372. }
  7373. #endregion
  7374. if (cellStr.Length > 8)
  7375. {
  7376. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7377. }
  7378. cellStr += ")";
  7379. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7380. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7381. decimal pxFee = dac4.Sum(it => it.Cost);
  7382. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7383. string celllastStr1 = "";
  7384. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  7385. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  7386. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  7387. celllastStr1 += $",国际旅费 元";
  7388. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  7389. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7390. designer.SetDataSource("cell4Str", cell4Str);
  7391. designer.SetDataSource("cellStr", cellStr);
  7392. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7393. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7394. designer.SetDataSource("celllastStr", celllastStr);
  7395. Workbook wb = designer.Workbook;
  7396. var sheet = wb.Worksheets[0];
  7397. //绑定datatable数据集
  7398. designer.SetDataSource(dtdac1);
  7399. designer.SetDataSource(dtdac2);
  7400. designer.Process();
  7401. var rowStart = dtdac1.Rows.Count;
  7402. while (rowStart > 0)
  7403. {
  7404. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7405. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7406. startIndex++;
  7407. rowStart--;
  7408. }
  7409. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7410. startIndex += 1; //总计行
  7411. rowStart = dtdac2.Rows.Count;
  7412. while (rowStart > 0)
  7413. {
  7414. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7415. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7416. startIndex++;
  7417. rowStart--;
  7418. }
  7419. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7420. wb.CalculateFormula(true);
  7421. //模板文件名
  7422. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7423. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7424. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7425. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7426. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7427. }
  7428. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7429. {
  7430. //获取模板
  7431. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7432. //载入模板
  7433. Document doc = new Document(tempPath);
  7434. DocumentBuilder builder = new DocumentBuilder(doc);
  7435. Dictionary<string, string> dic = new Dictionary<string, string>();
  7436. dic.Add("GroupName", "-");
  7437. dic.Add("ClientUnit", "-");
  7438. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7439. string missionLeaderJob = "";//负责人job
  7440. int groupNumber = 0; //团人数
  7441. dic.Add("MissionLeader", "-"); //团负责人
  7442. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7443. dic.Add("GroupNumber", "0"); //团人数
  7444. dic.Add("Day", "0");
  7445. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7446. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7447. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7448. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7449. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7450. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7451. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7452. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7453. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7454. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7455. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7456. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7457. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7458. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7459. //其他费用
  7460. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7461. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7462. //其他费用合计
  7463. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7464. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7465. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7466. //公务舱合计
  7467. //国际旅费
  7468. string outsideJJ = "";
  7469. string allPriceJJ = "";
  7470. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7471. {
  7472. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7473. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7474. }
  7475. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7476. {
  7477. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7478. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7479. }
  7480. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7481. {
  7482. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7483. dic.Add("AirFeeTotal", airFeeTotalStr);
  7484. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7485. dic.Add("FeeTotal", feeTotalStr);
  7486. }
  7487. foreach (var key in dic.Keys)
  7488. {
  7489. builder.MoveToBookmark(key);
  7490. builder.Write(dic[key]);
  7491. }
  7492. //模板文件名
  7493. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7494. strFileName = CommonFun.ValidFileName(strFileName);
  7495. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7496. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7497. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7498. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7499. }
  7500. }
  7501. else if (dto.ExportType == 2) //表格
  7502. {
  7503. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7504. }
  7505. else if (dto.ExportType == 3)
  7506. {
  7507. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7508. }
  7509. return Ok(JsonView(400, "只可导出明细表!", ""));
  7510. }
  7511. catch (Exception ex)
  7512. {
  7513. return Ok(JsonView(400, ex.Message, ""));
  7514. }
  7515. }
  7516. /// <summary>
  7517. /// 获取三公费用标准city
  7518. /// </summary>
  7519. /// <param name="placeData"></param>
  7520. /// <param name="nationalTravelFeeId"></param>
  7521. /// <returns></returns>
  7522. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7523. {
  7524. string _city = string.Empty;
  7525. if (!placeData.Any()) return _city;
  7526. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7527. if (data == null) return _city;
  7528. string country = data.Country;
  7529. string city = data.City;
  7530. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7531. else _city = city;
  7532. return _city;
  7533. }
  7534. /// <summary>
  7535. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7536. /// </summary>
  7537. /// <returns></returns>
  7538. [HttpPost]
  7539. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7540. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7541. {
  7542. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7543. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7544. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7545. if (_view.Code == 0)
  7546. {
  7547. return Ok(JsonView(true, "操作成功"));
  7548. }
  7549. return Ok(JsonView(false, "操作失败"));
  7550. }
  7551. /// <summary>
  7552. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7553. /// </summary>
  7554. /// <returns></returns>
  7555. [HttpPost]
  7556. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7557. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7558. {
  7559. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7560. if (data.Code != 0)
  7561. {
  7562. return Ok(JsonView(false, data.Msg));
  7563. }
  7564. return Ok(JsonView(true, "操作成功!", data.Data));
  7565. }
  7566. /// <summary>
  7567. /// 三公其他费用草稿 删除
  7568. /// </summary>
  7569. /// <param name="dto"></param>
  7570. /// <returns></returns>
  7571. [HttpPost]
  7572. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7573. {
  7574. var jw = JsonView(false, "删除失败!");
  7575. var data = new Grp_DayOtherPriceDraft()
  7576. {
  7577. Id = dto.Id,
  7578. IsDel = 1,
  7579. DeleteUserId = dto.DeleteUserId,
  7580. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7581. };
  7582. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7583. if (del > 0)
  7584. {
  7585. jw.Code = 200;
  7586. jw.Msg = "删除成功!";
  7587. }
  7588. return Ok(jw);
  7589. }
  7590. /// <summary>
  7591. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7592. /// </summary>
  7593. /// <param name="dto"></param>
  7594. /// <returns></returns>
  7595. [HttpPost]
  7596. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7597. {
  7598. var jw = JsonView(false);
  7599. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7600. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new {x.Id,x.DraftName }).ToListAsync();
  7601. jw.Code = StatusCodes.Status200OK;
  7602. jw.Msg = "操作成功!";
  7603. jw.Data = new { groupNameDatas= groupNameDatas.Data, draftNames = draftDatas };
  7604. return Ok(jw);
  7605. }
  7606. /// <summary>
  7607. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7608. /// </summary>
  7609. /// <param name="dto"></param>
  7610. /// <returns></returns>
  7611. [HttpPost]
  7612. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7613. {
  7614. int userId = dto.UserId,
  7615. portId = dto.PortType,
  7616. groupId = dto.GroupId,
  7617. draftId = dto.DraftId;
  7618. _portTypeData.Add(1);
  7619. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7620. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7621. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7622. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7623. _sqlSugar.BeginTran();
  7624. try
  7625. {
  7626. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7627. if (draftDatas == null)
  7628. {
  7629. _sqlSugar.RollbackTran();
  7630. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7631. }
  7632. //验证可覆盖已有数据 两边创建人需为同一人;
  7633. int draftCreateUserId = draftDatas.CreateUserId,
  7634. formalCreateUserId = 0;
  7635. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7636. if (formalData != null)
  7637. {
  7638. formalCreateUserId = formalData.CreateUserId;
  7639. if (draftCreateUserId != formalCreateUserId)
  7640. {
  7641. _sqlSugar.RollbackTran();
  7642. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7643. }
  7644. }
  7645. var permissionUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  7646. var userIds = permissionUsers.Select(x => x.Id).ToList();
  7647. var permissions = new List<Grp_EnterExitCostPermission>();
  7648. if (userIds.Any())
  7649. {
  7650. foreach (var userId1 in userIds)
  7651. {
  7652. permissions.Add(new Grp_EnterExitCostPermission() {
  7653. GroupId = groupId,
  7654. UserId = userId1,
  7655. CreateUserId = dto.UserId
  7656. });
  7657. }
  7658. }
  7659. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7660. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7661. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7662. newExterData.DiId = groupId;
  7663. newExterData.CreateUserId = userId;
  7664. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7665. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7666. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7667. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7668. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7669. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7670. //数据如果存在执行删除
  7671. if (enterExitCostInfo != null)
  7672. {
  7673. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7674. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7675. .Where(x => x.Id == enterExitCostInfo.Id)
  7676. .ExecuteCommand();
  7677. _sqlSugar.Updateable<Grp_DayAndCost>()
  7678. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7679. .Where(x => x.DiId == groupId)
  7680. .ExecuteCommand();
  7681. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7682. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7683. .Where(x => x.Diid == groupId)
  7684. .ExecuteCommand();
  7685. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7686. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7687. .Where(x => x.GroupId == groupId)
  7688. .ExecuteCommand();
  7689. }
  7690. //执行insert
  7691. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7692. if (insertId < 1)
  7693. {
  7694. _sqlSugar.RollbackTran();
  7695. return Ok(JsonView(false, "草稿数据导入失败!"));
  7696. }
  7697. if (permissions.Any()) _sqlSugar.Insertable(permissions).ExecuteCommand();
  7698. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7699. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7700. _sqlSugar.CommitTran();
  7701. //执行操作之后
  7702. //生成默认文件pdf并且通知人员
  7703. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7704. {
  7705. DiId = groupId,
  7706. ExportType = 1,
  7707. SubTypeId = 1005
  7708. }, "pdf");
  7709. //发送通知
  7710. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7711. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7712. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7713. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7714. //汇率信息记录
  7715. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7716. return Ok(JsonView(true));
  7717. }
  7718. catch (Exception ex)
  7719. {
  7720. _sqlSugar.RollbackTran();
  7721. return Ok(JsonView(false,ex.Message));
  7722. }
  7723. }
  7724. #endregion
  7725. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7726. /// <summary>
  7727. /// 获取币种基础数据(含逻辑处理)
  7728. /// </summary>
  7729. /// <returns></returns>
  7730. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7731. {
  7732. //默认币种显示
  7733. var _currencyInfos = _currencyInit;
  7734. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  7735. if (_currencyRate.Count > 0)
  7736. {
  7737. foreach (var item in _currencyInfos)
  7738. {
  7739. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7740. if (rateInfo != null)
  7741. {
  7742. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  7743. rate1 *= 1.035M;
  7744. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7745. }
  7746. }
  7747. }
  7748. return _currencyInfos;
  7749. }
  7750. /// <summary>
  7751. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7752. /// </summary>
  7753. /// <returns></returns>
  7754. [HttpPost]
  7755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7756. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7757. {
  7758. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7759. //SetDataInfoView
  7760. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7761. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7762. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7763. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7764. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7765. //默认币种显示
  7766. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7767. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7768. return Ok(JsonView(true, "查询成功!", new
  7769. {
  7770. WordTypeData = _WordTypeData,
  7771. ExcelTypeData = _ExcelTypeData,
  7772. CurrencyInit = _currencyInfos,
  7773. viewPermissionData = viewPermissionData
  7774. }));
  7775. }
  7776. /// <summary>
  7777. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7778. /// </summary>
  7779. /// <returns></returns>
  7780. [HttpPost]
  7781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7782. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7783. {
  7784. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7785. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7786. RefAsync<int> total = 0;
  7787. int diId = 0;
  7788. var status = int.TryParse(dto.GroupName, out diId);
  7789. string sql = string.Format(@"SELECT
  7790. Id,
  7791. TeamName GroupName,
  7792. CASE WHEN EXISTS (
  7793. SELECT
  7794. 1
  7795. FROM
  7796. Grp_EnterExitCost
  7797. WHERE
  7798. IsDel = 0
  7799. AND DiId = di.Id
  7800. ) THEN 1 ELSE 0 END AS [IsNull],
  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 ELSE 0 END AS [IsEdit],
  7813. CASE WHEN EXISTS(
  7814. SELECT
  7815. TOP 1 *
  7816. FROM
  7817. Grp_EnterExitCost
  7818. WHERE
  7819. IsDel = 0
  7820. AND DiId = di.Id
  7821. AND CreateUserId = {0}
  7822. ORDER BY
  7823. CreateTime DESC
  7824. ) THEN 1 WHEN EXISTS(
  7825. SELECT
  7826. TOP 1 *
  7827. FROM
  7828. Grp_EnterExitCostPermission
  7829. WHERE
  7830. IsDel = 0
  7831. AND GroupId = di.Id
  7832. AND Permission = 1
  7833. AND UserId = {0}
  7834. ORDER BY
  7835. CreateTime DESC
  7836. ) THEN 1 ELSE 0 END AS [IsView]
  7837. FROM
  7838. Grp_DelegationInfo di
  7839. WHERE
  7840. di.Isdel = 0 ",dto.CurrUserId);
  7841. var data = await _sqlSugar.SqlQueryable<EnterExitCostMobileGroupView>(sql)
  7842. .Where(x => !string.IsNullOrEmpty(x.GroupName))
  7843. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7844. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.GroupName.Contains(dto.GroupName))
  7845. .OrderByDescending(x => x.Id)
  7846. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7847. return Ok(JsonView(true, "查询成功!", data, total));
  7848. }
  7849. /// <summary>
  7850. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7851. /// </summary>
  7852. /// <returns></returns>
  7853. [HttpPost]
  7854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7855. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7856. {
  7857. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7858. RefAsync<int> total = 0;
  7859. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7860. .Where(x => x.IsDel == 0 && x.STid == 66)
  7861. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7862. .Select(x => new
  7863. {
  7864. id = x.Id,
  7865. name = x.Name,
  7866. remark = x.Remark,
  7867. })
  7868. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7869. return Ok(JsonView(true, "查询成功!", data, total));
  7870. }
  7871. /// <summary>
  7872. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7873. /// </summary>
  7874. /// <returns></returns>
  7875. [HttpPost]
  7876. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7877. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7878. {
  7879. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7880. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7881. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7882. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7883. var groupOtherRateData = groupRateData.TeamRates;
  7884. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7885. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  7886. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  7887. groupOtherRateData = groupOtherRateData
  7888. .Select(x => new TeamRateDescAddCurrencyIdView {
  7889. CurrencyId = x.CurrencyId,
  7890. CurrencyName = x.CurrencyName,
  7891. CurrencyCode = x.CurrencyCode,
  7892. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  7893. }).ToList();
  7894. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  7895. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData= groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  7896. }
  7897. /// <summary>
  7898. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  7899. /// </summary>
  7900. /// <returns></returns>
  7901. [HttpPost]
  7902. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7903. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  7904. {
  7905. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7906. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7907. var tipsData = new List<int>() {1,2,3 };
  7908. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  7909. if (dto.TipsType == 1)
  7910. {
  7911. //默认币种显示
  7912. var _currencyInfos = _currencyInit;
  7913. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  7914. List<dynamic> reteInfos = new List<dynamic>();
  7915. if (_currencyRate.Count > 0)
  7916. {
  7917. foreach (var item in _currencyInfos)
  7918. {
  7919. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7920. if (rateInfo != null)
  7921. {
  7922. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  7923. decimal rate1 = item.Rate;
  7924. rate1 *= 1.03M;
  7925. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7926. reteInfos.Add(new
  7927. {
  7928. currCode = item.CurrencyCode,
  7929. currName = item.CurrencyName,
  7930. rate = rate2,
  7931. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  7932. });
  7933. }
  7934. }
  7935. }
  7936. return Ok(JsonView(true, "查询成功!", reteInfos));
  7937. }
  7938. else if (dto.TipsType == 2)
  7939. {
  7940. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  7941. return Ok(JsonView(true, "查询成功!", visaData.Data));
  7942. }
  7943. else if (dto.TipsType == 3)
  7944. {
  7945. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  7946. return Ok(JsonView(true, "查询成功!", airData.Data));
  7947. }
  7948. return Ok(JsonView(false));
  7949. }
  7950. /// <summary>
  7951. /// 团组模块 - 出入境国家费用标准-移动端 List
  7952. /// </summary>
  7953. /// <returns></returns>
  7954. [HttpPost]
  7955. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7956. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  7957. {
  7958. Stopwatch sw = new Stopwatch();
  7959. sw.Start();
  7960. RefAsync<int> total = 0;
  7961. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7962. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  7963. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  7964. .Where((ntf, sd, u) => ntf.IsDel == 0)
  7965. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  7966. .Select((ntf, sd, u) => new
  7967. {
  7968. Id = ntf.Id,
  7969. Area = $"{ntf.Country}-{ntf.City}",
  7970. Currency = ntf.Currency,
  7971. CurrencyCode = sd.Name,
  7972. CurrencyName = sd.Remark,
  7973. RoomCost = ntf.RoomCost,
  7974. FoodCost = ntf.FoodCost,
  7975. PublicCost = ntf.PublicCost,
  7976. LastUpdateUserId = ntf.LastUpdateUserId,
  7977. LastUpdateUserName = u.CnName,
  7978. LastUpdateTime = ntf.LastUpdateTime,
  7979. })
  7980. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7981. sw.Stop();
  7982. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data,total));
  7983. }
  7984. /// <summary>
  7985. /// 团组模块 - 出入境费用-移动端 - Info
  7986. /// </summary>
  7987. /// <returns></returns>
  7988. [HttpPost]
  7989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7990. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  7991. {
  7992. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7993. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7994. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  7995. return Ok(data);
  7996. }
  7997. /// <summary>
  7998. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  7999. /// </summary>
  8000. /// <returns></returns>
  8001. [HttpPost]
  8002. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8003. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  8004. {
  8005. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8006. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8007. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8008. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8009. var mobileInfo = new EnterExitCostMobileParentInfoView();
  8010. mobileInfo.DiId = dto.DiId;
  8011. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8012. if (eecInfo == null) return Ok(mobileInfo);
  8013. //验证查看权限
  8014. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8015. if (!isView) return Ok(JsonView(false, msg));
  8016. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8017. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8018. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8019. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8020. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8021. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8022. {
  8023. SubId = dac.Id,
  8024. DiId = dac.DiId,
  8025. Type = dac.Type,
  8026. Days = dac.Days,
  8027. NationalTravelFeeId = dac.NationalTravelFeeId,
  8028. Arae = $"{ntf.Country}-{ntf.City}",
  8029. Cost = dac.Cost,
  8030. Currency = dac.Currency,
  8031. CurrencyName = sd.Name,
  8032. SubTotal = dac.SubTotal,
  8033. })
  8034. .ToList();
  8035. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8036. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8037. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8038. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8039. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8040. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8041. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8042. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8043. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8044. //其他款项
  8045. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8046. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8047. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8048. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8049. .OrderBy((dop, sd1, sd2) => dop.Index)
  8050. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8051. {
  8052. SubId = dop.Id,
  8053. DiId = dop.Diid,
  8054. Index = dop.Index,
  8055. SetDataId = dop.SetDataId,
  8056. SetDataName = sd1.Name,
  8057. Cost = dop.Cost,
  8058. Currency = dop.Currency,
  8059. CurrencyName = sd2.Remark,
  8060. SubTotal = dop.SubTotal,
  8061. Remark = dop.Remark,
  8062. })
  8063. .ToArray();
  8064. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8065. return Ok(mobileInfo);
  8066. }
  8067. /// <summary>
  8068. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8069. /// </summary>
  8070. /// <returns></returns>
  8071. [HttpPost]
  8072. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8073. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8074. {
  8075. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8076. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8077. //验证查看权限
  8078. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8079. if (!isView) return Ok(JsonView(false, msg));
  8080. var userIds = Array.Empty<int>();
  8081. userIds = await _sqlSugar
  8082. .Queryable<Grp_EnterExitCostPermission>()
  8083. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8084. .Select(x => x.UserId)
  8085. .ToArrayAsync();
  8086. return Ok(userIds);
  8087. }
  8088. /// <summary>
  8089. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8090. /// </summary>
  8091. /// <returns></returns>
  8092. [HttpPost]
  8093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8094. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8095. {
  8096. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8097. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8098. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8099. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8100. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8101. //验证查看权限
  8102. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8103. if (!isView) return Ok(JsonView(false, msg));
  8104. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8105. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8106. var subType = dto.SubType;
  8107. if (subType == 1) //1:境内费用
  8108. {
  8109. var oneData = new ChoiceOneMobileSubInfoView()
  8110. {
  8111. Id = eecInfo.Id,
  8112. ChoiceOne = eecInfo.ChoiceOne,
  8113. ChoiceOneTotalCost = eecInfo.InsidePay,
  8114. Visa = eecInfo.Visa,
  8115. VisaRemark = eecInfo.VisaRemark,
  8116. YiMiao = eecInfo.YiMiao,
  8117. HeSuan = eecInfo.HeSuan,
  8118. Service = eecInfo.Service,
  8119. Ticket = eecInfo.Ticket,
  8120. Safe = eecInfo.Safe,
  8121. FirstItemRemark = eecInfo.FirstItemRemark
  8122. };
  8123. return Ok(JsonView(oneData));
  8124. }
  8125. else if (subType == 2) //2:国际旅费
  8126. {
  8127. var twoData = new ChoiceTwoMobileSubInfoView() {
  8128. Id = eecInfo.Id,
  8129. ChoiceTwoJJ = eecInfo.SumJJC,
  8130. OutsideJJPay = eecInfo.OutsideJJPay,
  8131. ChoiceTwoGW = eecInfo.SumGWC,
  8132. OutsideGWPay = eecInfo.OutsideGWPay,
  8133. ChoiceTwoTD = eecInfo.SumTDC,
  8134. OutsideTDPay = eecInfo.OutsideTDPay,
  8135. AirJJ = eecInfo.AirJJ,
  8136. AirGW = eecInfo.AirGW,
  8137. AirTD = eecInfo.AirTD,
  8138. CityTranffic = eecInfo.CityTranffic,
  8139. TwoItemRemark = eecInfo.TwoItemRemark
  8140. };
  8141. return Ok(JsonView(twoData));
  8142. }
  8143. else if (subType == 3) //3:住宿费
  8144. {
  8145. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8146. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8147. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8148. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8149. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8150. {
  8151. SubId = dac.Id,
  8152. DiId = dac.DiId,
  8153. Type = dac.Type,
  8154. Days = dac.Days,
  8155. NationalTravelFeeId = dac.NationalTravelFeeId,
  8156. Arae = $"{ntf.Country}-{ntf.City}",
  8157. Cost = dac.Cost,
  8158. Currency = dac.Currency,
  8159. CurrencyName = sd.Name,
  8160. SubTotal = dac.SubTotal,
  8161. })
  8162. .ToArray();
  8163. var data = new ChoiceMobileSubInfo3To6View() {
  8164. ParentId = eecInfo.Id,
  8165. Choice = eecInfo.ChoiceThree,
  8166. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8167. Details = dayAndCostDatas
  8168. };
  8169. return Ok(JsonView(data));
  8170. }
  8171. else if (subType == 4) //4:伙食费
  8172. {
  8173. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8174. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8175. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8176. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8177. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8178. {
  8179. SubId = dac.Id,
  8180. DiId = dac.DiId,
  8181. Type = dac.Type,
  8182. Days = dac.Days,
  8183. NationalTravelFeeId = dac.NationalTravelFeeId,
  8184. Arae = $"{ntf.Country}-{ntf.City}",
  8185. Cost = dac.Cost,
  8186. Currency = dac.Currency,
  8187. CurrencyName = sd.Name,
  8188. SubTotal = dac.SubTotal,
  8189. })
  8190. .ToArray();
  8191. var data = new ChoiceMobileSubInfo3To6View()
  8192. {
  8193. ParentId = eecInfo.Id,
  8194. Choice = eecInfo.ChoiceFour,
  8195. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8196. Details = dayAndCostDatas
  8197. };
  8198. return Ok(JsonView(data));
  8199. }
  8200. else if (subType == 5) //5:公杂费
  8201. {
  8202. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8203. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8204. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8205. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8206. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8207. {
  8208. SubId = dac.Id,
  8209. DiId = dac.DiId,
  8210. Type = dac.Type,
  8211. Days = dac.Days,
  8212. NationalTravelFeeId = dac.NationalTravelFeeId,
  8213. Arae = $"{ntf.Country}-{ntf.City}",
  8214. Cost = dac.Cost,
  8215. Currency = dac.Currency,
  8216. CurrencyName = sd.Name,
  8217. SubTotal = dac.SubTotal,
  8218. })
  8219. .ToArray();
  8220. var data = new ChoiceMobileSubInfo3To6View()
  8221. {
  8222. ParentId = eecInfo.Id,
  8223. Choice = eecInfo.ChoiceFive,
  8224. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8225. Details = dayAndCostDatas
  8226. };
  8227. return Ok(JsonView(data));
  8228. }
  8229. else if (subType == 6) //6:培训费
  8230. {
  8231. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8232. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8233. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8234. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8235. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8236. {
  8237. SubId = dac.Id,
  8238. DiId = dac.DiId,
  8239. Type = dac.Type,
  8240. Days = dac.Days,
  8241. NationalTravelFeeId = dac.NationalTravelFeeId,
  8242. Arae = $"{ntf.Country}-{ntf.City}",
  8243. Cost = dac.Cost,
  8244. Currency = dac.Currency,
  8245. CurrencyName = sd.Name,
  8246. SubTotal = dac.SubTotal,
  8247. })
  8248. .ToArray();
  8249. var data = new ChoiceMobileSubInfo3To6View()
  8250. {
  8251. ParentId = eecInfo.Id,
  8252. Choice = eecInfo.ChoiceSix,
  8253. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8254. Details = dayAndCostDatas
  8255. };
  8256. return Ok(JsonView(data));
  8257. }
  8258. else if (subType == 7) //7:其他
  8259. {
  8260. //其他款项
  8261. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8262. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8263. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8264. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8265. .OrderBy((dop, sd1, sd2) => dop.Index)
  8266. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8267. {
  8268. SubId = dop.Id,
  8269. DiId = dop.Diid,
  8270. Index = dop.Index,
  8271. SetDataId = dop.SetDataId,
  8272. SetDataName = sd1.Name,
  8273. Cost = dop.Cost,
  8274. Currency = dop.Currency,
  8275. CurrencyName = sd2.Name,
  8276. SubTotal = dop.SubTotal,
  8277. Remark = dop.Remark,
  8278. })
  8279. .ToArray();
  8280. var data = new ChoiceSevenMobileSubInfoView()
  8281. {
  8282. ParentId = eecInfo.Id,
  8283. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8284. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8285. Details = otherData
  8286. };
  8287. return Ok(JsonView(data));
  8288. }
  8289. return Ok(JsonView(false));
  8290. }
  8291. #region op
  8292. /// <summary>
  8293. /// 移动端更新费用消息通知
  8294. /// </summary>
  8295. /// <param name="diid"></param>
  8296. /// <param name="id"></param>
  8297. /// <param name="currUserId"></param>
  8298. private async Task EnterExitCostMobileOpNotice(int diid, int id,int currUserId)
  8299. {
  8300. try
  8301. {
  8302. ////生成默认文件pdf并且通知人员
  8303. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8304. //{
  8305. // DiId = diid,
  8306. // ExportType = 1,
  8307. // SubTypeId = 1005
  8308. //}, "pdf");
  8309. ////发送通知
  8310. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8311. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8312. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8313. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8314. ////汇率信息记录
  8315. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8316. }
  8317. catch (Exception ex)
  8318. {
  8319. //记录日志
  8320. throw;
  8321. }
  8322. }
  8323. /// <summary>
  8324. /// 验证出入境费用数据是否存在
  8325. /// 不存在添加
  8326. /// </summary>
  8327. /// <param name="diId"></param>
  8328. /// <param name="currUserId"></param>
  8329. /// <returns></returns>
  8330. /// <exception cref="CustomException"></exception>
  8331. private async Task<int> EnterExitCostVerifyIsNull(int diId,int currUserId)
  8332. {
  8333. var parentId = 0;
  8334. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8335. if (info != null) {
  8336. parentId = info.Id;
  8337. }
  8338. else
  8339. {
  8340. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8341. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8342. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8343. parentId = addId;
  8344. }
  8345. return parentId;
  8346. }
  8347. /// <summary>
  8348. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8349. /// </summary>
  8350. /// <returns></returns>
  8351. [HttpPost]
  8352. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8353. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8354. {
  8355. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8356. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8357. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8358. //验证编辑权限
  8359. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8360. if (!isEdit) return Ok(JsonView(false, msg));
  8361. var permissions = new List<Grp_EnterExitCostPermission>();
  8362. foreach (var userId in dto.UserIds)
  8363. {
  8364. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8365. }
  8366. if (permissions.Any())
  8367. {
  8368. _sqlSugar.BeginTran();
  8369. try
  8370. {
  8371. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8372. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8373. if (result < 1)
  8374. {
  8375. _sqlSugar.RollbackTran();
  8376. return Ok(JsonView(false));
  8377. }
  8378. }
  8379. catch (Exception ex)
  8380. {
  8381. _sqlSugar.RollbackTran();
  8382. return Ok(JsonView(false, ex.Message));
  8383. }
  8384. _sqlSugar.CommitTran();
  8385. return Ok(JsonView(true));
  8386. }
  8387. return Ok(JsonView(false));
  8388. }
  8389. /// <summary>
  8390. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8391. /// </summary>
  8392. /// <returns></returns>
  8393. [HttpPost]
  8394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8395. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8396. {
  8397. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8398. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8399. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8400. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8401. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8402. int id = dto.Id;
  8403. if (id <= 0) //add
  8404. {
  8405. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8406. if (add < 1) return Ok(JsonView(false));
  8407. id = add;
  8408. }
  8409. else //update
  8410. {
  8411. //验证编辑权限
  8412. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8413. if (!isEdit) return Ok(JsonView(false, msg));
  8414. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8415. if (upd < 1) return Ok(JsonView(false));
  8416. }
  8417. #region 汇率变更时更改币种相关费用
  8418. var opDayCosts = new List<Grp_DayAndCost>();
  8419. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8420. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8421. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8422. .LeftJoin<Sys_SetData>((dac,sd) => dac.Currency == sd.Id)
  8423. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8424. .Select((dac, sd) => new {
  8425. dac.Id,
  8426. dac.DiId,
  8427. CurrencyCode = sd.Name,
  8428. dac.Cost
  8429. })
  8430. .ToList();
  8431. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8432. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8433. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8434. .Select((dop, sd) => new {
  8435. dop.Id,
  8436. dop.Diid,
  8437. CurrencyCode = sd.Name,
  8438. dop.Cost
  8439. })
  8440. .ToList();
  8441. if (dayCosts.Count > 0)
  8442. {
  8443. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8444. foreach (var dc in new_dayCosts)
  8445. {
  8446. var thisCurrency = dc.Key.ToUpper();
  8447. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8448. if (thisRate == 0.00M) continue;
  8449. foreach (var dcSub in dc)
  8450. {
  8451. opDayCosts.Add(new Grp_DayAndCost() {
  8452. Id = dcSub.Id,
  8453. DiId = dcSub.DiId,
  8454. Cost = dcSub.Cost,
  8455. SubTotal = dcSub.Cost * thisRate,
  8456. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8457. });
  8458. }
  8459. }
  8460. if (opDayCosts.Count > 0)
  8461. {
  8462. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8463. }
  8464. }
  8465. if (dayOtherCosts.Count > 0)
  8466. {
  8467. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8468. foreach (var dc in new_dayOtherCosts)
  8469. {
  8470. var thisCurrency = dc.Key.ToUpper();
  8471. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8472. if (thisRate == 0.00M) continue;
  8473. foreach (var dcSub in dc)
  8474. {
  8475. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8476. {
  8477. Id = dcSub.Id,
  8478. Diid = dcSub.Diid,
  8479. Cost = dcSub.Cost,
  8480. SubTotal = dcSub.Cost * thisRate,
  8481. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8482. });
  8483. }
  8484. }
  8485. if (opDayOtherCosts.Count > 0)
  8486. {
  8487. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8488. }
  8489. }
  8490. #endregion
  8491. //消息通知
  8492. await EnterExitCostMobileOpNotice(dto.DiId, id,dto.CurrUserId);
  8493. //汇率信息记录
  8494. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8495. return Ok(JsonView(new { parentId = id }));
  8496. }
  8497. /// <summary>
  8498. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8499. /// </summary>
  8500. /// <returns></returns>
  8501. [HttpPost]
  8502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8503. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8504. {
  8505. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8506. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8507. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8508. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8509. int id = dto.Id;
  8510. if (id <= 0) //add
  8511. {
  8512. checkboxInfo.CreateUserId = dto.CurrUserId;
  8513. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8514. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8515. if (add < 1) return Ok(JsonView(false));
  8516. }
  8517. else //update
  8518. {
  8519. //验证编辑权限
  8520. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8521. if (!isEdit) return Ok(JsonView(false, msg));
  8522. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8523. .UpdateColumns(x => new {
  8524. x.ChoiceOne,
  8525. x.ChoiceTwo,
  8526. x.SumJJC,
  8527. x.SumGWC,
  8528. x.SumTDC,
  8529. x.ChoiceThree,
  8530. x.ChoiceFour,
  8531. x.ChoiceFive,
  8532. x.ChoiceSix,
  8533. x.OtherExpenses_Checked
  8534. })
  8535. .Where(x => x.Id == id)
  8536. .ExecuteCommandAsync();
  8537. if (upd < 1) return Ok(JsonView(false));
  8538. }
  8539. return Ok(JsonView(new { parentId = id }));
  8540. }
  8541. /// <summary>
  8542. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8543. /// </summary>
  8544. /// <returns></returns>
  8545. [HttpPost]
  8546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8547. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8548. {
  8549. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId,isSelected = dto.IsSelected;
  8550. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8551. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8552. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8553. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8554. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8555. var checkboxInfo = new Grp_EnterExitCost() {
  8556. Id = id,
  8557. DiId = diId,
  8558. CreateUserId = currUserId
  8559. };
  8560. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8561. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8562. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8563. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8564. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8565. if (id <= 0) //add
  8566. {
  8567. checkboxInfo.CreateUserId = dto.CurrUserId;
  8568. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8569. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8570. if (add < 1) return Ok(JsonView(false));
  8571. }
  8572. else //update
  8573. {
  8574. //验证编辑权限
  8575. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8576. if (!isEdit) return Ok(JsonView(false, msg));
  8577. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8578. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8579. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8580. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8581. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8582. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8583. .Where(x => x.Id == id)
  8584. .ExecuteCommandAsync();
  8585. if (upd < 1) return Ok(JsonView(false));
  8586. }
  8587. return Ok(JsonView(new { parentId = id }));
  8588. }
  8589. /// <summary>
  8590. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8591. /// </summary>
  8592. /// <returns></returns>
  8593. [HttpPost]
  8594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8595. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8596. {
  8597. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8598. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8599. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8600. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8601. info.FirstItemRemark = dto.FirstItemRemark;
  8602. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8603. int id = dto.Id;
  8604. if (id <= 0) //add
  8605. {
  8606. info.CreateUserId = dto.CurrUserId;
  8607. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8608. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8609. if (add < 1) return Ok(JsonView(false));
  8610. id = add;
  8611. }
  8612. else //update
  8613. {
  8614. //验证编辑权限
  8615. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8616. if (!isEdit) return Ok(JsonView(false, msg));
  8617. var upd = await _sqlSugar.Updateable(info)
  8618. .UpdateColumns(x => new {
  8619. x.ChoiceOne,
  8620. x.InsidePay,
  8621. x.VisaRemark,
  8622. x.Visa,
  8623. x.Service,
  8624. x.Safe,
  8625. x.Ticket,
  8626. x.HeSuan,
  8627. x.YiMiao,
  8628. x.FirstItemRemark
  8629. })
  8630. .Where(x => x.Id == id)
  8631. .ExecuteCommandAsync();
  8632. if (upd < 1) return Ok(JsonView(false));
  8633. }
  8634. //消息通知
  8635. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8636. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8637. }
  8638. /// <summary>
  8639. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8640. /// </summary>
  8641. /// <returns></returns>
  8642. [HttpPost]
  8643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8644. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8645. {
  8646. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8647. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8648. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8649. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8650. info.OutsideJJPay = dto.OutsideJJPay;
  8651. info.OutsideGWPay = dto.OutsideGWPay;
  8652. info.OutsideTDPay = dto.OutsideTDPay;
  8653. info.AirJJ = dto.AirJJ;
  8654. info.AirGW = dto.AirGW;
  8655. info.AirTD = dto.AirTD;
  8656. info.CityTranffic = dto.CityTranffic;
  8657. info.TwoItemRemark = dto.TwoItemRemark;
  8658. info.SumJJC = dto.ChoiceTwoJJ;
  8659. info.SumGWC = dto.ChoiceTwoGW;
  8660. info.SumTDC = dto.ChoiceTwoTD;
  8661. int id = dto.Id;
  8662. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8663. if (id <= 0) //add
  8664. {
  8665. info.CreateUserId = dto.CurrUserId;
  8666. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8667. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8668. if (addId <= 0) return Ok(JsonView(false));
  8669. id = addId;
  8670. }
  8671. else //update
  8672. {
  8673. //验证编辑权限
  8674. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8675. if (!isEdit) return Ok(JsonView(false, msg));
  8676. var upd = await _sqlSugar.Updateable(info)
  8677. .UpdateColumns(x => new {
  8678. x.SumJJC,
  8679. x.OutsideJJPay,
  8680. x.SumGWC,
  8681. x.OutsideGWPay,
  8682. x.SumTDC,
  8683. x.OutsideTDPay,
  8684. x.AirJJ,
  8685. x.AirGW,
  8686. x.AirTD,
  8687. x.CityTranffic,
  8688. x.TwoItemRemark
  8689. })
  8690. .Where(x => x.Id == id)
  8691. .ExecuteCommandAsync();
  8692. if (upd <1) return Ok(JsonView(false));
  8693. }
  8694. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8695. gwcItemTotal = info.AirGW + info.CityTranffic;
  8696. tdcItemTotal = info.AirTD + info.CityTranffic;
  8697. //消息通知
  8698. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8699. return Ok(JsonView(new
  8700. {
  8701. parentId = id,
  8702. choiceTwoJJ = dto.ChoiceTwoJJ,
  8703. jjcItemTotal = jjcItemTotal,
  8704. choiceTwoGW = dto.ChoiceTwoGW,
  8705. gwcItemTotal = gwcItemTotal,
  8706. choiceTwoTD = dto.ChoiceTwoTD,
  8707. tdcItemTotal = tdcItemTotal
  8708. }));
  8709. }
  8710. /// <summary>
  8711. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8712. /// </summary>
  8713. /// <returns></returns>
  8714. [HttpPost]
  8715. [ApiExplorerSettings(IgnoreApi = true)]
  8716. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8717. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8718. {
  8719. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8720. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8721. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8722. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8723. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8724. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8725. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8726. var infos = infos1.Select(x => new Grp_DayAndCost
  8727. {
  8728. Id = x.Id,
  8729. DiId = dto.DiId,
  8730. Type = dto.FeeType,
  8731. Days = x.Days,
  8732. NationalTravelFeeId = x.NationalTravelFeeId,
  8733. Cost = x.Cost,
  8734. Currency = x.Currency,
  8735. SubTotal = x.SubTotal,
  8736. CreateUserId = dto.CurrUserId
  8737. })
  8738. .ToList();
  8739. var adds = infos.Where(x => x.Id <= 0).ToList();
  8740. var upds = infos.Where(x => x.Id > 0).ToList();
  8741. if (adds.Count > 0)
  8742. {
  8743. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8744. if (add < 1) return Ok(JsonView(false));
  8745. }
  8746. if (upds.Count > 0)
  8747. {
  8748. var upd = await _sqlSugar.Updateable(adds)
  8749. .UpdateColumns(x => new
  8750. {
  8751. x.Days,
  8752. x.NationalTravelFeeId,
  8753. x.Cost,
  8754. x.Currency,
  8755. x.SubTotal
  8756. })
  8757. .WhereColumns(x => new { x.Id })
  8758. .ExecuteCommandAsync();
  8759. if (upd < 1) return Ok(JsonView(false));
  8760. }
  8761. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8762. //消息通知
  8763. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8764. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8765. return Ok(JsonView(new { itemTotal = itemTotal }));
  8766. }
  8767. /// <summary>
  8768. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8769. /// </summary>
  8770. /// <returns></returns>
  8771. [HttpPost]
  8772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8773. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8774. {
  8775. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8776. int subId = dto.SubId, feeType = dto.FeeType;
  8777. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8778. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8779. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8780. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8781. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8782. subInfo.Id = subId;
  8783. subInfo.DiId = dto.DiId;
  8784. if (feeType == 3) subInfo.Type = 1;
  8785. else if (feeType == 4) subInfo.Type = 2;
  8786. else if (feeType == 5) subInfo.Type = 3;
  8787. else if (feeType == 6) subInfo.Type = 4;
  8788. subInfo.CreateUserId = dto.CurrUserId;
  8789. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8790. if (parentId < 1) return Ok(JsonView(false));
  8791. //子表op
  8792. if (subId < 1)
  8793. {
  8794. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8795. if (subAdd < 1) return Ok(JsonView(false));
  8796. }
  8797. else
  8798. {
  8799. //验证编辑权限
  8800. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8801. if (!isEdit) return Ok(JsonView(false, msg));
  8802. var subUpd = await _sqlSugar.Updateable(subInfo)
  8803. .UpdateColumns(x => new
  8804. {
  8805. x.Days,
  8806. x.NationalTravelFeeId,
  8807. x.Cost,
  8808. x.Currency,
  8809. x.SubTotal
  8810. })
  8811. .WhereColumns(x => new { x.Id })
  8812. .ExecuteCommandAsync();
  8813. if (subUpd < 1) return Ok(JsonView(false));
  8814. }
  8815. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8816. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8817. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8818. }
  8819. /// <summary>
  8820. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8821. /// </summary>
  8822. /// <returns></returns>
  8823. [HttpPost]
  8824. [ApiExplorerSettings(IgnoreApi = true)]
  8825. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8826. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8827. {
  8828. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8829. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8830. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8831. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8832. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8833. {
  8834. Id = x.Id,
  8835. Diid = dto.DiId,
  8836. SetDataId = x.SetDataId,
  8837. Index = x.Index,
  8838. Cost = x.Cost,
  8839. Currency = x.Currency,
  8840. SubTotal = x.SubTotal,
  8841. CreateUserId = dto.CurrUserId,
  8842. Remark = x.Remark
  8843. }).ToList();
  8844. var adds = infos.Where(x => x.Id <= 0).ToList();
  8845. var upds = infos.Where(x => x.Id > 0).ToList();
  8846. if (adds.Count > 0)
  8847. {
  8848. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8849. if (add < 1) return Ok(JsonView(false));
  8850. }
  8851. if (upds.Count > 0)
  8852. {
  8853. var upd = await _sqlSugar.Updateable(adds)
  8854. .UpdateColumns(x => new
  8855. {
  8856. x.Index,
  8857. x.SetDataId,
  8858. x.Cost,
  8859. x.Currency,
  8860. x.SubTotal,
  8861. x.Remark
  8862. })
  8863. .WhereColumns(x => new { x.Id })
  8864. .ExecuteCommandAsync();
  8865. if (upd < 1) return Ok(JsonView(false));
  8866. }
  8867. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8868. //消息通知
  8869. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8870. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8871. return Ok(JsonView(new { itemTotal = itemTotal }));
  8872. }
  8873. /// <summary>
  8874. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8875. /// </summary>
  8876. /// <returns></returns>
  8877. [HttpPost]
  8878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8879. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8880. {
  8881. int subId = dto.SubId;
  8882. int diId = dto.Diid;
  8883. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8884. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8885. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8886. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8887. subInfo.Id = subId;
  8888. subInfo.Diid = dto.Diid;
  8889. subInfo.CreateUserId = dto.CurrUserId;
  8890. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8891. if (parentId < 1) return Ok(JsonView(false));
  8892. #region 子表op
  8893. if (subId < 1)//add
  8894. {
  8895. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8896. if (subAdd < 1) return Ok(JsonView(false));
  8897. }
  8898. else //upd
  8899. {
  8900. //验证编辑权限
  8901. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  8902. if (!isEdit) return Ok(JsonView(false, msg));
  8903. var subUpd = await _sqlSugar.Updateable(subInfo)
  8904. .UpdateColumns(x => new
  8905. {
  8906. x.Index,
  8907. x.SetDataId,
  8908. x.Cost,
  8909. x.Currency,
  8910. x.SubTotal,
  8911. x.Remark
  8912. })
  8913. .WhereColumns(x => new { x.Id })
  8914. .ExecuteCommandAsync();
  8915. if (subUpd < 1) return Ok(JsonView(false));
  8916. }
  8917. #endregion
  8918. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  8919. //消息通知
  8920. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  8921. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8922. }
  8923. /// <summary>
  8924. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  8925. /// </summary>
  8926. /// <returns></returns>
  8927. [HttpPost]
  8928. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8929. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  8930. {
  8931. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8932. if (data.Code != 0)
  8933. {
  8934. return Ok(JsonView(false, data.Msg));
  8935. }
  8936. return Ok(JsonView(true, "操作成功!", data.Data));
  8937. }
  8938. /// <summary>
  8939. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  8940. /// </summary>
  8941. /// <param name="dto"></param>
  8942. /// <returns></returns>
  8943. [HttpPost]
  8944. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  8945. {
  8946. var data = new Grp_DayOtherPrice()
  8947. {
  8948. Id = dto.Id,
  8949. IsDel = 1,
  8950. DeleteUserId = dto.DeleteUserId,
  8951. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8952. };
  8953. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8954. if (del > 0) return Ok(JsonView(true,"删除成功!"));
  8955. return Ok(JsonView(false,"删除失败!"));
  8956. }
  8957. #endregion
  8958. #endregion
  8959. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  8960. /// <summary>
  8961. /// 出入境费用-草稿 移动端
  8962. /// 获取币种基础数据(含逻辑处理)
  8963. /// </summary>
  8964. /// <returns></returns>
  8965. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  8966. {
  8967. //默认币种显示
  8968. var _currencyInfos = _currencyInit;
  8969. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  8970. if (_currencyRate.Count > 0)
  8971. {
  8972. foreach (var item in _currencyInfos)
  8973. {
  8974. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  8975. if (rateInfo != null)
  8976. {
  8977. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  8978. rate1 *= 1.035M;
  8979. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  8980. }
  8981. }
  8982. }
  8983. return _currencyInfos;
  8984. }
  8985. /// <summary>
  8986. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  8987. /// </summary>
  8988. /// <returns></returns>
  8989. [HttpPost]
  8990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8991. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(PortDtoBase dto)
  8992. {
  8993. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8994. //SetDataInfoView
  8995. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  8996. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  8997. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  8998. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  8999. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  9000. //默认币种显示
  9001. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9002. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9003. return Ok(JsonView(true, "查询成功!", new
  9004. {
  9005. WordTypeData = _WordTypeData,
  9006. ExcelTypeData = _ExcelTypeData,
  9007. CurrencyInit = _currencyInfos,
  9008. viewPermissionData= viewPermissionData
  9009. }));
  9010. }
  9011. /// <summary>
  9012. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9013. /// </summary>
  9014. /// <returns></returns>
  9015. [HttpPost]
  9016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9017. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9018. {
  9019. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9020. RefAsync<int> total = 0;
  9021. int diId = 0;
  9022. var status = int.TryParse(dto.GroupName, out diId);
  9023. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9024. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9025. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9026. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9027. .Select(x => new
  9028. {
  9029. Id = x.Id,
  9030. GroupName = x.TeamName
  9031. })
  9032. .OrderByDescending(x => x.Id)
  9033. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9034. return Ok(JsonView(true, "查询成功!", data, total));
  9035. }
  9036. /// <summary>
  9037. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9038. /// </summary>
  9039. /// <returns></returns>
  9040. [HttpPost]
  9041. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9042. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9043. {
  9044. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9045. RefAsync<int> total = 0;
  9046. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9047. .Where(x => x.IsDel == 0 && x.STid == 66)
  9048. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9049. .Select(x => new
  9050. {
  9051. id = x.Id,
  9052. name = x.Name,
  9053. remark = x.Remark,
  9054. })
  9055. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9056. return Ok(JsonView(true, "查询成功!", data, total));
  9057. }
  9058. /// <summary>
  9059. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9060. /// </summary>
  9061. /// <returns></returns>
  9062. [HttpPost]
  9063. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9064. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9065. {
  9066. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9067. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9068. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, 2274, 98);
  9069. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9070. var groupOtherRateData = groupRateData.TeamRates;
  9071. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9072. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9073. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9074. groupOtherRateData = groupOtherRateData
  9075. .Select(x => new TeamRateDescAddCurrencyIdView
  9076. {
  9077. CurrencyId = x.CurrencyId,
  9078. CurrencyName = x.CurrencyName,
  9079. CurrencyCode = x.CurrencyCode,
  9080. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9081. }).ToList();
  9082. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9083. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9084. }
  9085. /// <summary>
  9086. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9087. /// </summary>
  9088. /// <returns></returns>
  9089. [HttpPost]
  9090. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9091. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9092. {
  9093. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9094. var tipsData = new List<int>() { 1, 2, 3 };
  9095. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9096. if (dto.TipsType == 1)
  9097. {
  9098. //默认币种显示
  9099. var _currencyInfos = _currencyInit;
  9100. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  9101. List<dynamic> reteInfos = new List<dynamic>();
  9102. if (_currencyRate.Count > 0)
  9103. {
  9104. foreach (var item in _currencyInfos)
  9105. {
  9106. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  9107. if (rateInfo != null)
  9108. {
  9109. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  9110. decimal rate1 = item.Rate;
  9111. rate1 *= 1.03M;
  9112. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  9113. reteInfos.Add(new
  9114. {
  9115. currCode = item.CurrencyCode,
  9116. currName = item.CurrencyName,
  9117. rate = rate2,
  9118. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  9119. });
  9120. }
  9121. }
  9122. }
  9123. return Ok(JsonView(true, "查询成功!", reteInfos));
  9124. }
  9125. else if (dto.TipsType == 2)
  9126. {
  9127. }
  9128. else if (dto.TipsType == 3)
  9129. {
  9130. }
  9131. return Ok(JsonView(false));
  9132. }
  9133. /// <summary>
  9134. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9135. /// </summary>
  9136. /// <returns></returns>
  9137. [HttpPost]
  9138. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9139. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9140. {
  9141. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9142. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9143. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9144. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9145. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9146. if (eecInfo == null) return Ok(mobileInfo);
  9147. //验证查看权限
  9148. (bool isView, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId);
  9149. if (!isView) return Ok(JsonView(false, msg));
  9150. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9151. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9152. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9153. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9154. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9155. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9156. {
  9157. ParentId = dac.ParentId,
  9158. SubId = dac.Id,
  9159. Type = dac.Type,
  9160. Days = dac.Days,
  9161. NationalTravelFeeId = dac.NationalTravelFeeId,
  9162. Arae = $"{ntf.Country}-{ntf.City}",
  9163. Cost = dac.Cost,
  9164. Currency = dac.Currency,
  9165. CurrencyName = sd.Name,
  9166. SubTotal = dac.SubTotal,
  9167. })
  9168. .ToList();
  9169. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9170. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9171. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9172. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9173. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9174. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9175. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9176. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9177. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9178. //其他款项
  9179. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9180. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9181. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9182. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9183. .OrderBy((dop, sd1, sd2) => dop.Index)
  9184. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9185. {
  9186. ParentId = dop.ParentId,
  9187. SubId = dop.Id,
  9188. Index = dop.Index,
  9189. SetDataId = dop.SetDataId,
  9190. SetDataName = sd1.Name,
  9191. Cost = dop.Cost,
  9192. Currency = dop.Currency,
  9193. CurrencyName = sd2.Remark,
  9194. SubTotal = dop.SubTotal,
  9195. Remark = dop.Remark,
  9196. })
  9197. .ToArray();
  9198. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9199. return Ok(mobileInfo);
  9200. }
  9201. /// <summary>
  9202. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9203. /// </summary>
  9204. /// <returns></returns>
  9205. [HttpPost]
  9206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9207. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9208. {
  9209. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9210. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9211. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9212. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9213. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9214. //验证查看权限
  9215. (bool isView, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId);
  9216. if (!isView) return Ok(JsonView(false, msg));
  9217. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9218. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9219. var subType = dto.SubType;
  9220. if (subType == 1) //1:境内费用
  9221. {
  9222. var oneData = new ChoiceOneMobileSubInfoView()
  9223. {
  9224. Id = eecInfo.Id,
  9225. ChoiceOne = eecInfo.ChoiceOne,
  9226. ChoiceOneTotalCost = eecInfo.InsidePay,
  9227. Visa = eecInfo.Visa,
  9228. VisaRemark = eecInfo.VisaRemark,
  9229. YiMiao = eecInfo.YiMiao,
  9230. HeSuan = eecInfo.HeSuan,
  9231. Service = eecInfo.Service,
  9232. Ticket = eecInfo.Ticket,
  9233. Safe = eecInfo.Safe,
  9234. FirstItemRemark = eecInfo.FirstItemRemark
  9235. };
  9236. return Ok(JsonView(oneData));
  9237. }
  9238. else if (subType == 2) //2:国际旅费
  9239. {
  9240. var twoData = new ChoiceTwoMobileSubInfoView()
  9241. {
  9242. Id = eecInfo.Id,
  9243. ChoiceTwoJJ = eecInfo.SumJJC,
  9244. OutsideJJPay = eecInfo.OutsideJJPay,
  9245. ChoiceTwoGW = eecInfo.SumGWC,
  9246. OutsideGWPay = eecInfo.OutsideGWPay,
  9247. ChoiceTwoTD = eecInfo.SumTDC,
  9248. OutsideTDPay = eecInfo.OutsideTDPay,
  9249. AirJJ = eecInfo.AirJJ,
  9250. AirGW = eecInfo.AirGW,
  9251. AirTD = eecInfo.AirTD,
  9252. CityTranffic = eecInfo.CityTranffic,
  9253. TwoItemRemark = eecInfo.TwoItemRemark
  9254. };
  9255. return Ok(JsonView(twoData));
  9256. }
  9257. else if (subType == 3) //3:住宿费
  9258. {
  9259. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9260. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9261. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9262. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9263. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9264. {
  9265. ParentId = dac.ParentId,
  9266. SubId = dac.Id,
  9267. Type = dac.Type,
  9268. Days = dac.Days,
  9269. NationalTravelFeeId = dac.NationalTravelFeeId,
  9270. Arae = $"{ntf.Country}-{ntf.City}",
  9271. Cost = dac.Cost,
  9272. Currency = dac.Currency,
  9273. CurrencyName = sd.Name,
  9274. SubTotal = dac.SubTotal,
  9275. })
  9276. .ToArray();
  9277. var data = new ChoiceDraftMobileSubInfo3To6View()
  9278. {
  9279. ParentId = eecInfo.Id,
  9280. Choice = eecInfo.ChoiceThree,
  9281. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9282. Details = dayAndCostDatas
  9283. };
  9284. return Ok(JsonView(data));
  9285. }
  9286. else if (subType == 4) //4:伙食费
  9287. {
  9288. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9289. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9290. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9291. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9292. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9293. {
  9294. ParentId = dac.ParentId,
  9295. SubId = dac.Id,
  9296. Type = dac.Type,
  9297. Days = dac.Days,
  9298. NationalTravelFeeId = dac.NationalTravelFeeId,
  9299. Arae = $"{ntf.Country}-{ntf.City}",
  9300. Cost = dac.Cost,
  9301. Currency = dac.Currency,
  9302. CurrencyName = sd.Name,
  9303. SubTotal = dac.SubTotal,
  9304. })
  9305. .ToArray();
  9306. var data = new ChoiceDraftMobileSubInfo3To6View()
  9307. {
  9308. ParentId = eecInfo.Id,
  9309. Choice = eecInfo.ChoiceFour,
  9310. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9311. Details = dayAndCostDatas
  9312. };
  9313. return Ok(JsonView(data));
  9314. }
  9315. else if (subType == 5) //5:公杂费
  9316. {
  9317. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9318. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9319. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9320. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9321. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9322. {
  9323. ParentId = dac.ParentId,
  9324. SubId = dac.Id,
  9325. Type = dac.Type,
  9326. Days = dac.Days,
  9327. NationalTravelFeeId = dac.NationalTravelFeeId,
  9328. Arae = $"{ntf.Country}-{ntf.City}",
  9329. Cost = dac.Cost,
  9330. Currency = dac.Currency,
  9331. CurrencyName = sd.Name,
  9332. SubTotal = dac.SubTotal,
  9333. })
  9334. .ToArray();
  9335. var data = new ChoiceDraftMobileSubInfo3To6View()
  9336. {
  9337. ParentId = eecInfo.Id,
  9338. Choice = eecInfo.ChoiceFive,
  9339. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9340. Details = dayAndCostDatas
  9341. };
  9342. return Ok(JsonView(data));
  9343. }
  9344. else if (subType == 6) //6:培训费
  9345. {
  9346. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9347. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9348. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9349. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9350. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9351. {
  9352. ParentId = dac.ParentId,
  9353. SubId = dac.Id,
  9354. Type = dac.Type,
  9355. Days = dac.Days,
  9356. NationalTravelFeeId = dac.NationalTravelFeeId,
  9357. Arae = $"{ntf.Country}-{ntf.City}",
  9358. Cost = dac.Cost,
  9359. Currency = dac.Currency,
  9360. CurrencyName = sd.Name,
  9361. SubTotal = dac.SubTotal,
  9362. })
  9363. .ToArray();
  9364. var data = new ChoiceDraftMobileSubInfo3To6View()
  9365. {
  9366. ParentId = eecInfo.Id,
  9367. Choice = eecInfo.ChoiceSix,
  9368. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9369. Details = dayAndCostDatas
  9370. };
  9371. return Ok(JsonView(data));
  9372. }
  9373. else if (subType == 7) //7:其他
  9374. {
  9375. //其他款项
  9376. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9377. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9378. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9379. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9380. .OrderBy((dop, sd1, sd2) => dop.Index)
  9381. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9382. {
  9383. ParentId = dop.ParentId,
  9384. SubId = dop.Id,
  9385. Index = dop.Index,
  9386. SetDataId = dop.SetDataId,
  9387. SetDataName = sd1.Name,
  9388. Cost = dop.Cost,
  9389. Currency = dop.Currency,
  9390. CurrencyName = sd2.Name,
  9391. SubTotal = dop.SubTotal,
  9392. Remark = dop.Remark,
  9393. })
  9394. .ToArray();
  9395. var data = new ChoiceSevenDraftMobileSubInfoView()
  9396. {
  9397. ParentId = eecInfo.Id,
  9398. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9399. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9400. Details = otherData
  9401. };
  9402. return Ok(JsonView(data));
  9403. }
  9404. return Ok(JsonView(false));
  9405. }
  9406. #region op
  9407. /// <summary>
  9408. /// 移动端更新费用消息通知
  9409. /// </summary>
  9410. /// <param name="diid"></param>
  9411. /// <param name="id"></param>
  9412. /// <param name="currUserId"></param>
  9413. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9414. {
  9415. try
  9416. {
  9417. ////生成默认文件pdf并且通知人员
  9418. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9419. //{
  9420. // DiId = draftId,
  9421. // ExportType = 1,
  9422. // SubTypeId = 1005
  9423. //}, "pdf");
  9424. ////发送通知
  9425. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9426. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9427. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9428. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9429. ////汇率信息记录
  9430. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9431. }
  9432. catch (Exception ex)
  9433. {
  9434. //记录日志
  9435. throw;
  9436. }
  9437. }
  9438. /// <summary>
  9439. /// 验证出入境费用数据是否存在
  9440. /// 不存在添加
  9441. /// </summary>
  9442. /// <param name="draftId"></param>
  9443. /// <param name="currUserId"></param>
  9444. /// <returns></returns>
  9445. /// <exception cref="CustomException"></exception>
  9446. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9447. {
  9448. var parentId = 0;
  9449. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9450. if (info != null) parentId = info.Id;
  9451. else
  9452. {
  9453. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9454. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9455. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9456. parentId = addId;
  9457. }
  9458. return parentId;
  9459. }
  9460. /// <summary>
  9461. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9462. /// </summary>
  9463. /// <returns></returns>
  9464. [HttpPost]
  9465. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9466. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9467. {
  9468. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9469. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9470. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9471. //验证编辑权限
  9472. (bool isEdit, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId, 2);
  9473. if (!isEdit) return Ok(JsonView(false, msg));
  9474. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  9475. foreach (var userId in dto.UserIds)
  9476. {
  9477. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9478. }
  9479. if (permissions.Any())
  9480. {
  9481. _sqlSugar.BeginTran();
  9482. try
  9483. {
  9484. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9485. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9486. if (result < 1)
  9487. {
  9488. _sqlSugar.RollbackTran();
  9489. return Ok(JsonView(false));
  9490. }
  9491. }
  9492. catch (Exception ex)
  9493. {
  9494. _sqlSugar.RollbackTran();
  9495. return Ok(JsonView(false, ex.Message));
  9496. }
  9497. _sqlSugar.CommitTran();
  9498. return Ok(JsonView(true));
  9499. }
  9500. return Ok(JsonView(false));
  9501. }
  9502. /// <summary>
  9503. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9504. /// </summary>
  9505. /// <returns></returns>
  9506. [HttpPost]
  9507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9508. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9509. {
  9510. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9511. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9512. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9513. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9514. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9515. int id = dto.DraftId;
  9516. if (id <= 0) //add
  9517. {
  9518. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9519. if (add < 1) return Ok(JsonView(false));
  9520. id = add;
  9521. }
  9522. else //update
  9523. {
  9524. //验证编辑权限
  9525. (bool isEdit, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId, 2);
  9526. if (!isEdit) return Ok(JsonView(false, msg));
  9527. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9528. if (upd < 1) return Ok(JsonView(false));
  9529. }
  9530. #region 汇率变更时更改币种相关费用
  9531. var opDayCosts = new List<Grp_DayAndCostDraft>();
  9532. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  9533. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9534. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9535. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9536. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9537. .Select((dac, sd) => new
  9538. {
  9539. dac.Id,
  9540. dac.ParentId,
  9541. CurrencyCode = sd.Name,
  9542. dac.Cost
  9543. })
  9544. .ToList();
  9545. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9546. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9547. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9548. .Select((dop, sd) => new
  9549. {
  9550. dop.Id,
  9551. dop.ParentId,
  9552. CurrencyCode = sd.Name,
  9553. dop.Cost
  9554. })
  9555. .ToList();
  9556. if (dayCosts.Count > 0)
  9557. {
  9558. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9559. foreach (var dc in new_dayCosts)
  9560. {
  9561. var thisCurrency = dc.Key.ToUpper();
  9562. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9563. if (thisRate == 0.00M) continue;
  9564. foreach (var dcSub in dc)
  9565. {
  9566. opDayCosts.Add(new Grp_DayAndCostDraft()
  9567. {
  9568. Id = dcSub.Id,
  9569. ParentId = dcSub.ParentId,
  9570. Cost = dcSub.Cost,
  9571. SubTotal = dcSub.Cost * thisRate,
  9572. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9573. });
  9574. }
  9575. }
  9576. if (opDayCosts.Count > 0)
  9577. {
  9578. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9579. }
  9580. }
  9581. if (dayOtherCosts.Count > 0)
  9582. {
  9583. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9584. foreach (var dc in new_dayOtherCosts)
  9585. {
  9586. var thisCurrency = dc.Key.ToUpper();
  9587. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9588. if (thisRate == 0.00M) continue;
  9589. foreach (var dcSub in dc)
  9590. {
  9591. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  9592. {
  9593. Id = dcSub.Id,
  9594. ParentId = dcSub.ParentId,
  9595. Cost = dcSub.Cost,
  9596. SubTotal = dcSub.Cost * thisRate,
  9597. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9598. });
  9599. }
  9600. }
  9601. if (opDayOtherCosts.Count > 0)
  9602. {
  9603. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9604. }
  9605. }
  9606. #endregion
  9607. ////消息通知
  9608. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9609. ////汇率信息记录
  9610. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9611. return Ok(JsonView(new { parentId = id }));
  9612. }
  9613. /// <summary>
  9614. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  9615. /// </summary>
  9616. /// <returns></returns>
  9617. [HttpPost]
  9618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9619. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  9620. {
  9621. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9622. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9623. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9624. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9625. int id = dto.DraftId;
  9626. if (id <= 0) //add
  9627. {
  9628. checkboxInfo.CreateUserId = dto.CurrUserId;
  9629. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  9630. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9631. if (add < 1) return Ok(JsonView(false));
  9632. }
  9633. else //update
  9634. {
  9635. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9636. .UpdateColumns(x => new
  9637. {
  9638. x.ChoiceOne,
  9639. x.ChoiceTwo,
  9640. x.SumJJC,
  9641. x.SumGWC,
  9642. x.SumTDC,
  9643. x.ChoiceThree,
  9644. x.ChoiceFour,
  9645. x.ChoiceFive,
  9646. x.ChoiceSix,
  9647. x.OtherExpenses_Checked
  9648. })
  9649. .Where(x => x.Id == id)
  9650. .ExecuteCommandAsync();
  9651. if (upd < 1) return Ok(JsonView(false));
  9652. }
  9653. return Ok(JsonView(new { parentId = id }));
  9654. }
  9655. /// <summary>
  9656. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框更改
  9657. /// </summary>
  9658. /// <returns></returns>
  9659. [HttpPost]
  9660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9661. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  9662. {
  9663. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  9664. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9665. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9666. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9667. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9668. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9669. var checkboxInfo = new Grp_EnterExitCostDraft()
  9670. {
  9671. Id = draftId,
  9672. CreateUserId = currUserId
  9673. };
  9674. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9675. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9676. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9677. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9678. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9679. if (draftId <= 0) //add
  9680. {
  9681. checkboxInfo.CreateUserId = dto.CurrUserId;
  9682. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9683. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9684. if (add < 1) return Ok(JsonView(false));
  9685. }
  9686. else //update
  9687. {
  9688. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  9689. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9690. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9691. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9692. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9693. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9694. .Where(x => x.Id == draftId)
  9695. .ExecuteCommandAsync();
  9696. if (upd < 1) return Ok(JsonView(false));
  9697. }
  9698. return Ok(JsonView(new { parentId = draftId }));
  9699. }
  9700. /// <summary>
  9701. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  9702. /// </summary>
  9703. /// <returns></returns>
  9704. [HttpPost]
  9705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9706. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  9707. {
  9708. int id = dto.DraftId,currUserId = dto.CurrUserId;
  9709. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9710. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9711. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9712. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9713. info.FirstItemRemark = dto.FirstItemRemark;
  9714. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9715. if (id <= 0) //add
  9716. {
  9717. info.CreateUserId = dto.CurrUserId;
  9718. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9719. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9720. if (add < 1) return Ok(JsonView(false));
  9721. id = add;
  9722. }
  9723. else //update
  9724. {
  9725. var upd = await _sqlSugar.Updateable(info)
  9726. .UpdateColumns(x => new
  9727. {
  9728. x.ChoiceOne,
  9729. x.InsidePay,
  9730. x.VisaRemark,
  9731. x.Visa,
  9732. x.Service,
  9733. x.Safe,
  9734. x.Ticket,
  9735. x.HeSuan,
  9736. x.YiMiao,
  9737. x.FirstItemRemark
  9738. })
  9739. .Where(x => x.Id == id)
  9740. .ExecuteCommandAsync();
  9741. if (upd < 1) return Ok(JsonView(false));
  9742. }
  9743. ////消息通知
  9744. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9745. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9746. }
  9747. /// <summary>
  9748. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  9749. /// </summary>
  9750. /// <returns></returns>
  9751. [HttpPost]
  9752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9753. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  9754. {
  9755. int id = dto.DraftId;
  9756. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9757. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9758. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9759. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9760. info.OutsideJJPay = dto.OutsideJJPay;
  9761. info.OutsideGWPay = dto.OutsideGWPay;
  9762. info.OutsideTDPay = dto.OutsideTDPay;
  9763. info.AirJJ = dto.AirJJ;
  9764. info.AirGW = dto.AirGW;
  9765. info.AirTD = dto.AirTD;
  9766. info.CityTranffic = dto.CityTranffic;
  9767. info.TwoItemRemark = dto.TwoItemRemark;
  9768. info.SumJJC = dto.ChoiceTwoJJ;
  9769. info.SumGWC = dto.ChoiceTwoGW;
  9770. info.SumTDC = dto.ChoiceTwoTD;
  9771. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9772. if (id <= 0) //add
  9773. {
  9774. info.CreateUserId = dto.CurrUserId;
  9775. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9776. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9777. if (addId <= 0) return Ok(JsonView(false));
  9778. id = addId;
  9779. }
  9780. else //update
  9781. {
  9782. var upd = await _sqlSugar.Updateable(info)
  9783. .UpdateColumns(x => new
  9784. {
  9785. x.SumJJC,
  9786. x.OutsideJJPay,
  9787. x.SumGWC,
  9788. x.OutsideGWPay,
  9789. x.SumTDC,
  9790. x.OutsideTDPay,
  9791. x.AirJJ,
  9792. x.AirGW,
  9793. x.AirTD,
  9794. x.CityTranffic,
  9795. x.TwoItemRemark
  9796. })
  9797. .Where(x => x.Id == id)
  9798. .ExecuteCommandAsync();
  9799. if (upd < 1) return Ok(JsonView(false));
  9800. }
  9801. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9802. gwcItemTotal = info.AirGW + info.CityTranffic;
  9803. tdcItemTotal = info.AirTD + info.CityTranffic;
  9804. ////消息通知
  9805. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9806. return Ok(JsonView(new
  9807. {
  9808. parentId = id,
  9809. choiceTwoJJ = dto.ChoiceTwoJJ,
  9810. jjcItemTotal = jjcItemTotal,
  9811. choiceTwoGW = dto.ChoiceTwoGW,
  9812. gwcItemTotal = gwcItemTotal,
  9813. choiceTwoTD = dto.ChoiceTwoTD,
  9814. tdcItemTotal = tdcItemTotal
  9815. }));
  9816. }
  9817. /// <summary>
  9818. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9819. /// </summary>
  9820. /// <returns></returns>
  9821. [HttpPost]
  9822. [ApiExplorerSettings(IgnoreApi = true)]
  9823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9824. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  9825. {
  9826. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9827. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9828. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9829. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9830. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9831. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9832. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  9833. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  9834. {
  9835. Id = x.Id,
  9836. ParentId = dto.DraftId,
  9837. Type = dto.FeeType,
  9838. Days = x.Days,
  9839. NationalTravelFeeId = x.NationalTravelFeeId,
  9840. Cost = x.Cost,
  9841. Currency = x.Currency,
  9842. SubTotal = x.SubTotal,
  9843. CreateUserId = dto.CurrUserId
  9844. })
  9845. .ToList();
  9846. var adds = infos.Where(x => x.Id <= 0).ToList();
  9847. var upds = infos.Where(x => x.Id > 0).ToList();
  9848. if (adds.Count > 0)
  9849. {
  9850. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9851. if (add < 1) return Ok(JsonView(false));
  9852. }
  9853. if (upds.Count > 0)
  9854. {
  9855. var upd = await _sqlSugar.Updateable(adds)
  9856. .UpdateColumns(x => new
  9857. {
  9858. x.Days,
  9859. x.NationalTravelFeeId,
  9860. x.Cost,
  9861. x.Currency,
  9862. x.SubTotal
  9863. })
  9864. .WhereColumns(x => new { x.Id })
  9865. .ExecuteCommandAsync();
  9866. if (upd < 1) return Ok(JsonView(false));
  9867. }
  9868. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9869. ////消息通知
  9870. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  9871. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9872. return Ok(JsonView(new { itemTotal = itemTotal }));
  9873. }
  9874. /// <summary>
  9875. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9876. /// </summary>
  9877. /// <returns></returns>
  9878. [HttpPost]
  9879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9880. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  9881. {
  9882. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9883. int subId = dto.SubId, feeType = dto.FeeType;
  9884. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9885. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9886. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9887. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9888. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  9889. subInfo.Id = subId;
  9890. subInfo.ParentId = dto.DraftId;
  9891. if (feeType == 3) subInfo.Type = 1;
  9892. else if (feeType == 4) subInfo.Type = 2;
  9893. else if (feeType == 5) subInfo.Type = 3;
  9894. else if (feeType == 6) subInfo.Type = 4;
  9895. subInfo.CreateUserId = dto.CurrUserId;
  9896. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  9897. if (parentId < 1) return Ok(JsonView(false));
  9898. //子表op
  9899. if (subId < 1)
  9900. {
  9901. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9902. if (subAdd < 1) return Ok(JsonView(false));
  9903. }
  9904. else
  9905. {
  9906. var subUpd = await _sqlSugar.Updateable(subInfo)
  9907. .UpdateColumns(x => new
  9908. {
  9909. x.Days,
  9910. x.NationalTravelFeeId,
  9911. x.Cost,
  9912. x.Currency,
  9913. x.SubTotal
  9914. })
  9915. .WhereColumns(x => new { x.Id })
  9916. .ExecuteCommandAsync();
  9917. if (subUpd < 1) return Ok(JsonView(false));
  9918. }
  9919. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  9920. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9921. }
  9922. /// <summary>
  9923. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  9924. /// </summary>
  9925. /// <returns></returns>
  9926. [HttpPost]
  9927. [ApiExplorerSettings(IgnoreApi = true)]
  9928. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9929. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  9930. {
  9931. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9932. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9933. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9934. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  9935. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  9936. {
  9937. Id = x.Id,
  9938. ParentId = dto.DraftId,
  9939. SetDataId = x.SetDataId,
  9940. Index = x.Index,
  9941. Cost = x.Cost,
  9942. Currency = x.Currency,
  9943. SubTotal = x.SubTotal,
  9944. CreateUserId = dto.CurrUserId,
  9945. Remark = x.Remark
  9946. }).ToList();
  9947. var adds = infos.Where(x => x.Id <= 0).ToList();
  9948. var upds = infos.Where(x => x.Id > 0).ToList();
  9949. if (adds.Count > 0)
  9950. {
  9951. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9952. if (add < 1) return Ok(JsonView(false));
  9953. }
  9954. if (upds.Count > 0)
  9955. {
  9956. var upd = await _sqlSugar.Updateable(adds)
  9957. .UpdateColumns(x => new
  9958. {
  9959. x.Index,
  9960. x.SetDataId,
  9961. x.Cost,
  9962. x.Currency,
  9963. x.SubTotal,
  9964. x.Remark
  9965. })
  9966. .WhereColumns(x => new { x.Id })
  9967. .ExecuteCommandAsync();
  9968. if (upd < 1) return Ok(JsonView(false));
  9969. }
  9970. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  9971. //消息通知
  9972. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  9973. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9974. return Ok(JsonView(new { itemTotal = itemTotal }));
  9975. }
  9976. /// <summary>
  9977. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  9978. /// </summary>
  9979. /// <returns></returns>
  9980. [HttpPost]
  9981. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9982. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  9983. {
  9984. int subId = dto.SubId,id = dto.DarftId;
  9985. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9986. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  9987. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9988. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  9989. subInfo.Id = subId;
  9990. subInfo.ParentId = dto.DarftId;
  9991. subInfo.CreateUserId = dto.CurrUserId;
  9992. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  9993. if (parentId < 1) return Ok(JsonView(false));
  9994. #region 子表op
  9995. if (subId < 1)//add
  9996. {
  9997. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9998. if (subAdd < 1) return Ok(JsonView(false));
  9999. }
  10000. else //upd
  10001. {
  10002. var subUpd = await _sqlSugar.Updateable(subInfo)
  10003. .UpdateColumns(x => new
  10004. {
  10005. x.Index,
  10006. x.SetDataId,
  10007. x.Cost,
  10008. x.Currency,
  10009. x.SubTotal,
  10010. x.Remark
  10011. })
  10012. .WhereColumns(x => new { x.Id })
  10013. .ExecuteCommandAsync();
  10014. if (subUpd < 1) return Ok(JsonView(false));
  10015. }
  10016. #endregion
  10017. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10018. ////消息通知
  10019. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10020. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10021. }
  10022. /// <summary>
  10023. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10024. /// </summary>
  10025. /// <returns></returns>
  10026. [HttpPost]
  10027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10028. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10029. {
  10030. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10031. if (data.Code != 0)
  10032. {
  10033. return Ok(JsonView(false, data.Msg));
  10034. }
  10035. return Ok(JsonView(true, "操作成功!", data.Data));
  10036. }
  10037. /// <summary>
  10038. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10039. /// </summary>
  10040. /// <param name="dto"></param>
  10041. /// <returns></returns>
  10042. [HttpPost]
  10043. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10044. {
  10045. var data = new Grp_DayOtherPriceDraft()
  10046. {
  10047. Id = dto.Id,
  10048. IsDel = 1,
  10049. DeleteUserId = dto.DeleteUserId,
  10050. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10051. };
  10052. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10053. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10054. return Ok(JsonView(false, "删除失败!"));
  10055. }
  10056. #endregion
  10057. #endregion
  10058. #region 签证费用录入
  10059. /// <summary>
  10060. /// 根据diid查询签证费用列表
  10061. /// </summary>
  10062. /// <param name="dto"></param>
  10063. /// <returns></returns>
  10064. [HttpPost]
  10065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10066. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  10067. {
  10068. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  10069. if (groupData.Code != 0)
  10070. {
  10071. return Ok(JsonView(false, groupData.Msg));
  10072. }
  10073. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10074. }
  10075. /// <summary>
  10076. /// 根据签证费用Id查询单条数据及c表数据
  10077. /// </summary>
  10078. /// <param name="dto"></param>
  10079. /// <returns></returns>
  10080. [HttpPost]
  10081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10082. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  10083. {
  10084. Result groupData = await _visaPriceRep.PostVisaById(dto);
  10085. if (groupData.Code != 0)
  10086. {
  10087. return Ok(JsonView(false, groupData.Msg));
  10088. }
  10089. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10090. }
  10091. /// <summary>
  10092. /// 签证费用删除
  10093. /// </summary>
  10094. /// <param name="dto"></param>
  10095. /// <returns></returns>
  10096. [HttpPost]
  10097. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10098. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  10099. {
  10100. _sqlSugar.BeginTran();
  10101. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  10102. if (!res)
  10103. {
  10104. _sqlSugar.RollbackTran();
  10105. return Ok(JsonView(false, "删除失败"));
  10106. }
  10107. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  10108. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  10109. .SetColumns(a => new Grp_CreditCardPayment()
  10110. {
  10111. IsDel = 1,
  10112. DeleteUserId = dto.DeleteUserId,
  10113. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10114. })
  10115. .ExecuteCommand();
  10116. if (resSub < 1)
  10117. {
  10118. _sqlSugar.RollbackTran();
  10119. return Ok(JsonView(false, "删除失败"));
  10120. }
  10121. _sqlSugar.CommitTran();
  10122. return Ok(JsonView(true, "删除成功!"));
  10123. }
  10124. /// <summary>
  10125. /// 签证费用录入下拉框初始化
  10126. /// </summary>
  10127. /// <returns></returns>
  10128. [HttpPost]
  10129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10130. public async Task<IActionResult> VisaPriceAddSelect()
  10131. {
  10132. //支付方式
  10133. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  10134. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  10135. //币种
  10136. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  10137. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  10138. //乘客类型
  10139. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  10140. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  10141. //卡类型
  10142. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  10143. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  10144. //代办费类型
  10145. var agencyFeeTypeData = new List<dynamic>() {
  10146. new { id = 0 , Text = "未选择" },
  10147. new { id = 1 , Text = "小公务" },
  10148. new { id = 2 , Text = "大公务" },
  10149. };
  10150. //签证费用标准国家Data
  10151. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  10152. var data = new
  10153. {
  10154. Payment = _Payment,
  10155. CurrencyList = _CurrencyList,
  10156. PassengerType = _PassengerType,
  10157. BankCard = _BankCard,
  10158. AgencyFeeType = agencyFeeTypeData,
  10159. CountryFeeData = visaCountryFeeData
  10160. };
  10161. return Ok(JsonView(true, "查询成功!", data));
  10162. }
  10163. /// <summary>
  10164. /// 签证费用录入操作(Status:1.新增,2.修改)
  10165. /// </summary>
  10166. /// <param name="dto"></param>
  10167. /// <returns></returns>
  10168. [HttpPost]
  10169. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10170. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  10171. {
  10172. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  10173. if (groupData.Code != 0)
  10174. {
  10175. return Ok(JsonView(false, groupData.Msg));
  10176. }
  10177. #region 应用推送
  10178. try
  10179. {
  10180. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10181. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10182. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10183. //2024-10-21 新增LZ UID
  10184. var userIds = new List<int>() { 21 };
  10185. string title = $"系统通知";
  10186. string content = "";
  10187. var diId = dto.DiId;
  10188. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10189. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10190. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10191. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10192. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10193. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10194. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10195. }
  10196. catch (Exception ex)
  10197. {
  10198. }
  10199. #endregion
  10200. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10201. }
  10202. #endregion
  10203. #region 签证提成录入
  10204. /// <summary>
  10205. /// 签证提成录入
  10206. /// 基础数据
  10207. /// </summary>
  10208. /// <param name="_dto"></param>
  10209. /// <returns></returns>
  10210. [HttpGet]
  10211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10212. public async Task<IActionResult> VisaCommissionInit()
  10213. {
  10214. return Ok(await _visaCommissionRep.Init());
  10215. }
  10216. /// <summary>
  10217. /// 签证提成录入
  10218. /// Item
  10219. /// </summary>
  10220. /// <param name="_dto"></param>
  10221. /// <returns></returns>
  10222. [HttpPost]
  10223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10224. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  10225. {
  10226. var validator = new VisaCommissionItemDtoValidator();
  10227. var validatorRes = await validator.ValidateAsync(_dto);
  10228. if (!validatorRes.IsValid)
  10229. {
  10230. StringBuilder sb = new StringBuilder();
  10231. foreach (var item in validatorRes.Errors)
  10232. {
  10233. sb.AppendLine(item.ErrorMessage);
  10234. }
  10235. return Ok(JsonView(false, sb.ToString()));
  10236. }
  10237. return Ok(await _visaCommissionRep.Item(_dto));
  10238. }
  10239. /// <summary>
  10240. /// 签证提成录入
  10241. /// Save
  10242. /// </summary>
  10243. /// <param name="_dto"></param>
  10244. /// <returns></returns>
  10245. [HttpPost]
  10246. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10247. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  10248. {
  10249. //参数验证
  10250. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  10251. foreach (var item in _dto.Items)
  10252. {
  10253. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  10254. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  10255. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  10256. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  10257. }
  10258. return Ok(await _visaCommissionRep.Save(_dto));
  10259. }
  10260. /// <summary>
  10261. /// 签证提成录入
  10262. /// Create
  10263. /// </summary>
  10264. /// <param name="_dto"></param>
  10265. /// <returns></returns>
  10266. [HttpPost]
  10267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10268. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  10269. {
  10270. var validator = new VisaCommissionCreateDtoValidator();
  10271. var validatorRes = await validator.ValidateAsync(_dto);
  10272. if (!validatorRes.IsValid)
  10273. {
  10274. StringBuilder sb = new StringBuilder();
  10275. foreach (var item in validatorRes.Errors)
  10276. {
  10277. sb.AppendLine(item.ErrorMessage);
  10278. }
  10279. return Ok(JsonView(false, sb.ToString()));
  10280. }
  10281. return Ok(await _visaCommissionRep.Create(_dto));
  10282. }
  10283. /// <summary>
  10284. /// 签证提成录入
  10285. /// Put(编辑)
  10286. /// </summary>
  10287. /// <param name="id"></param>
  10288. /// <param name="_dto"></param>
  10289. /// <returns></returns>
  10290. [HttpPut]
  10291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10292. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  10293. {
  10294. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10295. var validator = new VisaCommissionCreateDtoValidator();
  10296. var validatorRes = await validator.ValidateAsync(_dto);
  10297. if (!validatorRes.IsValid)
  10298. {
  10299. StringBuilder sb = new StringBuilder();
  10300. foreach (var item in validatorRes.Errors)
  10301. {
  10302. sb.AppendLine(item.ErrorMessage);
  10303. }
  10304. return Ok(JsonView(false, sb.ToString()));
  10305. }
  10306. return Ok(await _visaCommissionRep.Edit(id, _dto));
  10307. }
  10308. /// <summary>
  10309. /// 签证提成录入
  10310. /// Del
  10311. /// </summary>
  10312. /// <param name="id"></param>
  10313. /// <param name="currUserId"></param>
  10314. /// <returns></returns>
  10315. [HttpPost]
  10316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10317. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  10318. {
  10319. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10320. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  10321. return Ok(await _visaCommissionRep.Del(id, currUserId));
  10322. }
  10323. #endregion
  10324. #region op费用录入
  10325. /// <summary>
  10326. /// 根据diid查询op费用列表
  10327. /// </summary>
  10328. /// <param name="dto"></param>
  10329. /// <returns></returns>
  10330. [HttpPost]
  10331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10332. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  10333. {
  10334. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  10335. if (groupData.Code != 0)
  10336. {
  10337. return Ok(JsonView(false, groupData.Msg));
  10338. }
  10339. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10340. }
  10341. /// <summary>
  10342. /// 根据op费用Id查询单条数据及c表数据
  10343. /// </summary>
  10344. /// <param name="dto"></param>
  10345. /// <returns></returns>
  10346. [HttpPost]
  10347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10348. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  10349. {
  10350. try
  10351. {
  10352. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  10353. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  10354. var data = new
  10355. {
  10356. CarTouristGuideGround = _groupData,
  10357. CreditCardPayment = _creditCardPayment
  10358. };
  10359. return Ok(JsonView(true, "查询成功!", data));
  10360. }
  10361. catch (Exception ex)
  10362. {
  10363. return Ok(JsonView(false, "程序错误!"));
  10364. }
  10365. }
  10366. /// <summary>
  10367. /// op费用删除
  10368. /// </summary>
  10369. /// <param name="dto"></param>
  10370. /// <returns></returns>
  10371. [HttpPost]
  10372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10373. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  10374. {
  10375. try
  10376. {
  10377. _sqlSugar.BeginTran();
  10378. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  10379. if (!res)
  10380. {
  10381. return Ok(JsonView(false, "删除失败"));
  10382. }
  10383. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  10384. {
  10385. IsDel = 1,
  10386. DeleteUserId = dto.DeleteUserId,
  10387. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10388. }).ExecuteCommandAsync();
  10389. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  10390. {
  10391. IsDel = 1,
  10392. DeleteUserId = dto.DeleteUserId,
  10393. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10394. }).ExecuteCommandAsync();
  10395. #region 删除超支相关数据
  10396. //删除导入的超支数据
  10397. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  10398. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  10399. {
  10400. IsDel = 1,
  10401. DeleteUserId = dto.DeleteUserId,
  10402. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10403. }).ExecuteCommand();
  10404. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  10405. {
  10406. IsDel = 1,
  10407. DeleteUserId = dto.DeleteUserId,
  10408. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10409. }).ExecuteCommand();
  10410. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  10411. {
  10412. IsDel = 1,
  10413. DeleteUserId = dto.DeleteUserId,
  10414. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10415. }).ExecuteCommand();
  10416. #endregion
  10417. _sqlSugar.CommitTran();
  10418. return Ok(JsonView(true, "删除成功!"));
  10419. }
  10420. catch (Exception ex)
  10421. {
  10422. _sqlSugar.RollbackTran();
  10423. return Ok(JsonView(false, "程序错误!" + ex.Message));
  10424. }
  10425. }
  10426. /// <summary>
  10427. /// op费用录入操作(Status:1.新增,2.修改)
  10428. /// </summary>
  10429. /// <param name="dto"></param>
  10430. /// <returns></returns>
  10431. [HttpPost]
  10432. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10433. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  10434. {
  10435. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  10436. if (groupData.Code != 0)
  10437. {
  10438. return Ok(JsonView(false, groupData.Msg));
  10439. }
  10440. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10441. }
  10442. /// <summary>
  10443. /// 填写费用详细页面初始化绑定
  10444. /// </summary>
  10445. /// <param name="dto"></param>
  10446. /// <returns></returns>
  10447. [HttpPost]
  10448. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10449. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  10450. {
  10451. try
  10452. {
  10453. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  10454. if (groupData.Code != 0)
  10455. {
  10456. return Ok(JsonView(false, groupData.Msg));
  10457. }
  10458. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10459. }
  10460. catch (Exception ex)
  10461. {
  10462. return Ok(JsonView(false, ex.Message));
  10463. }
  10464. }
  10465. /// <summary>
  10466. /// 根据op费用Id查询详细数据
  10467. /// </summary>
  10468. /// <param name="dto"></param>
  10469. /// <returns></returns>
  10470. [HttpPost]
  10471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10472. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  10473. {
  10474. try
  10475. {
  10476. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  10477. if (groupData.Code != 0)
  10478. {
  10479. return Ok(JsonView(false, groupData.Msg));
  10480. }
  10481. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10482. }
  10483. catch (Exception ex)
  10484. {
  10485. return Ok(JsonView(false, ex.Message));
  10486. }
  10487. }
  10488. /// <summary>
  10489. /// OP费用录入填写详情
  10490. /// </summary>
  10491. /// <param name="dto"></param>
  10492. /// <returns></returns>
  10493. [HttpPost]
  10494. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10495. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  10496. {
  10497. try
  10498. {
  10499. #region 参数校验
  10500. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  10501. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  10502. if (di == null) return Ok(JsonView(false, "团组错误!"));
  10503. #endregion
  10504. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  10505. if (groupData.Code != 0)
  10506. {
  10507. return Ok(JsonView(false, groupData.Msg));
  10508. }
  10509. //自动审核
  10510. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  10511. #region 应用推送
  10512. try
  10513. {
  10514. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10515. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10516. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10517. //2024-10-21 新增LZ UID
  10518. var userIds = new List<int>() { 21 };
  10519. string title = $"系统通知";
  10520. var diId = dto.DiId;
  10521. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10522. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10523. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  10524. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10525. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10526. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10527. }
  10528. catch (Exception ex)
  10529. {
  10530. }
  10531. #endregion
  10532. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10533. }
  10534. catch (Exception ex)
  10535. {
  10536. return Ok(JsonView(false, ex.Message));
  10537. }
  10538. }
  10539. /// <summary>
  10540. /// 获取三公详细所有城市
  10541. /// </summary>
  10542. /// <returns></returns>
  10543. [HttpGet]
  10544. public IActionResult OpCarCityResult()
  10545. {
  10546. var jw = JsonView(false);
  10547. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  10548. {
  10549. x.Id,
  10550. x.Country,
  10551. x.City,
  10552. }).ToList();
  10553. if (data.Count > 0)
  10554. {
  10555. jw = JsonView(true, "获取成功!", data);
  10556. }
  10557. else
  10558. {
  10559. jw.Msg = "城市数据为空!";
  10560. jw.Data = new string[0];
  10561. }
  10562. return Ok(jw);
  10563. }
  10564. /// <summary>
  10565. /// 导出地接费用明细
  10566. /// </summary>
  10567. /// <param name="dto"></param>
  10568. /// <returns></returns>
  10569. [HttpPost]
  10570. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  10571. {
  10572. var jw = JsonView(false);
  10573. if (dto.Diid < 1)
  10574. {
  10575. jw.Msg = "请输入正确的diid!";
  10576. return Ok(jw);
  10577. }
  10578. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  10579. if (group == null)
  10580. {
  10581. jw.Msg = "未找到团组信息!";
  10582. return Ok(jw);
  10583. }
  10584. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  10585. if (localGuideArr.Count == 0)
  10586. {
  10587. jw.Msg = "该团组暂无地接信息!";
  10588. return Ok(jw);
  10589. }
  10590. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  10591. var overspendSoure = new Dictionary<int, int>
  10592. {
  10593. { 91, 982 }, //车
  10594. { 92 , 1059} ,//导游
  10595. { 994 , 1073}, //翻译
  10596. { 988 , 1074 }, //早餐
  10597. { 93 , 1075 }, //午餐
  10598. { 989 , 1076 }, //晚餐
  10599. };
  10600. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  10601. foreach (var groupArr in localGroup)
  10602. {
  10603. var keyValue = groupArr.Key;
  10604. if (int.TryParse(keyValue, out int cityid))
  10605. {
  10606. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  10607. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  10608. }
  10609. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  10610. foreach (var item in groupArr)
  10611. {
  10612. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  10613. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  10614. new Grp_CarTouristGuideGroundReservationsContentExtend
  10615. {
  10616. Count = a.Count,
  10617. CreateTime = a.CreateTime,
  10618. CreateUserId = a.CreateUserId,
  10619. CTGGRId = a.CTGGRId,
  10620. Currency = a.Currency,
  10621. DatePrice = a.DatePrice,
  10622. DeleteTime = a.DeleteTime,
  10623. DeleteUserId = a.DeleteUserId,
  10624. DiId = a.DiId,
  10625. Id = a.Id,
  10626. IsDel = a.IsDel,
  10627. Price = a.Price,
  10628. PriceContent = a.PriceContent,
  10629. Remark = a.Remark,
  10630. SId = a.SId,
  10631. SidName = b.Name,
  10632. Units = a.Units,
  10633. }
  10634. ).ToList();
  10635. if (content.Count > 0)
  10636. {
  10637. contentArr.Add(content);
  10638. }
  10639. }
  10640. //open excel
  10641. //set excel
  10642. //save excel
  10643. try
  10644. {
  10645. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  10646. IWorkbook workbook;
  10647. if (Path.GetExtension(filePath).ToLower() == ".xls")
  10648. {
  10649. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10650. }
  10651. else
  10652. {
  10653. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10654. }
  10655. ISheet sheet = workbook.GetSheetAt(0);
  10656. var rowStartIndex = 2;
  10657. var clounmCount = 10;
  10658. var initStyleRow = sheet.GetRow(2);
  10659. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  10660. //var overspendArrDetail =
  10661. var existsId = new List<CarCompare>();
  10662. var lastElem = arr.Last();
  10663. var thisSid = -1;
  10664. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  10665. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  10666. {
  10667. Name = "未知币种!",
  10668. Remark = "未知币种!",
  10669. };
  10670. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  10671. Action cloneRowFn = () =>
  10672. {
  10673. rowStartIndex++;
  10674. var cloneRow = sheet.CreateRow(rowStartIndex);
  10675. // 复制样式
  10676. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  10677. {
  10678. ICell sourceCell = initStyleRow.GetCell(i);
  10679. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  10680. // 确保单元格存在样式
  10681. if (sourceCell.CellStyle != null)
  10682. {
  10683. targetCell.CellStyle = sourceCell.CellStyle;
  10684. }
  10685. }
  10686. };
  10687. var mergeRow = () =>
  10688. {
  10689. for (int i = 2; i < sheet.LastRowNum; i++)
  10690. {
  10691. var row = sheet.GetRow(i);
  10692. var cellFirst = row.GetCell(0);
  10693. var thisIndex = i + 1;
  10694. while (thisIndex < sheet.LastRowNum)
  10695. {
  10696. var nextRow = sheet.GetRow(thisIndex);
  10697. var nextCellFirst = nextRow.GetCell(0);
  10698. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  10699. {
  10700. thisIndex++;
  10701. }
  10702. else
  10703. {
  10704. break;
  10705. }
  10706. }
  10707. thisIndex--;
  10708. if (thisIndex != i)
  10709. {
  10710. //合并row
  10711. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10712. i, // 起始行索引(0-based)
  10713. thisIndex, // 结束行索引(0-based)
  10714. 0, // 起始列索引(0-based)
  10715. 0 // 结束列索引(0-based)
  10716. );
  10717. sheet.AddMergedRegion(cellRangeAddress);
  10718. i = thisIndex;
  10719. }
  10720. }
  10721. };
  10722. var chaoshiNumber = 0;
  10723. var totalNumber = 0.00M;
  10724. string lastStr = "";
  10725. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  10726. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  10727. {
  10728. b.IsAuditGM,
  10729. x.Id,
  10730. x.Area,
  10731. b.PayPercentage,
  10732. b.PayMoney,
  10733. }).ToList();
  10734. string yesPayment = "", noPayment = "";
  10735. foreach (var item in queryCarArrByCityAndDiid)
  10736. {
  10737. if (item.IsAuditGM == 1)
  10738. {
  10739. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10740. }
  10741. else
  10742. {
  10743. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10744. }
  10745. }
  10746. lastStr = yesPayment + noPayment;
  10747. foreach (var item in arr)
  10748. {
  10749. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  10750. {
  10751. if (thisSid != item.SId)
  10752. {
  10753. if (thisSid == -1)
  10754. {
  10755. thisSid = item.SId;
  10756. }
  10757. else
  10758. {
  10759. //合并小计行
  10760. //创建合并区域的实例
  10761. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10762. rowStartIndex, // 起始行索引(0-based)
  10763. rowStartIndex, // 结束行索引(0-based)
  10764. 0, // 起始列索引(0-based)
  10765. 3 // 结束列索引(0-based)
  10766. );
  10767. sheet.AddMergedRegion(cellRangeAddress);
  10768. var CellStyle = workbook.CreateCellStyle();
  10769. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10770. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10771. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10772. for (int i = 0; i <= clounmCount; i++)
  10773. {
  10774. if (i > 6)
  10775. {
  10776. var CellStyle1 = workbook.CreateCellStyle();
  10777. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10778. IFont Font = workbook.CreateFont(); // 创建字体
  10779. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  10780. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10781. CellStyle1.SetFont(Font);
  10782. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  10783. }
  10784. else
  10785. {
  10786. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  10787. }
  10788. }
  10789. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  10790. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  10791. //超时合计
  10792. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  10793. //超时数
  10794. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  10795. //超时合计费用
  10796. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  10797. thisSid = item.SId;
  10798. cloneRowFn();
  10799. chaoshiNumber = 0;
  10800. totalNumber = 0;
  10801. }
  10802. }
  10803. IRow row = sheet.GetRow(rowStartIndex);
  10804. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10805. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  10806. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  10807. if (isOpenOverspendSoure)
  10808. {
  10809. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10810. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  10811. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  10812. }
  10813. for (int i = 0; i <= clounmCount; i++)
  10814. {
  10815. var cell = row.GetCell(i);
  10816. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  10817. if (cell == null)
  10818. {
  10819. cell = row.CreateCell(i);
  10820. }
  10821. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  10822. fontRed.CloneStyleFrom(cell.CellStyle);
  10823. IFont Font = workbook.CreateFont(); // 创建字体
  10824. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  10825. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10826. fontRed.SetFont(Font);
  10827. byte[] rgb = new byte[3] { 255, 242, 204 };
  10828. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  10829. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  10830. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  10831. if (workbook is XSSFWorkbook)
  10832. {
  10833. BackgroundColor255_242_204.FillForegroundColor = 0;
  10834. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  10835. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  10836. }
  10837. else
  10838. {
  10839. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  10840. }
  10841. if (i == 1 || i > 6)
  10842. {
  10843. if (i > 6)
  10844. {
  10845. fontRed.FillForegroundColor = 0;
  10846. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  10847. fontRed.FillPattern = FillPattern.SolidForeground;
  10848. }
  10849. cell.CellStyle = fontRed;
  10850. }
  10851. if (i > 2 && i < 7)
  10852. {
  10853. cell.CellStyle = BackgroundColor255_242_204;
  10854. }
  10855. cell.SetCellValue(setCellValue); //写入单元格
  10856. }
  10857. if (overspendSoure.ContainsKey(thisSid))
  10858. {
  10859. var overspendId = overspendSoure[thisSid];
  10860. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10861. }
  10862. cloneRowFn();
  10863. existsId.Add(new CarCompare
  10864. {
  10865. DataPrice = item.DatePrice.ObjToDate(),
  10866. Sid = item.SId
  10867. });
  10868. }
  10869. if (item.Equals(lastElem))
  10870. {
  10871. //合并小计行
  10872. //创建合并区域的实例
  10873. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10874. rowStartIndex, // 起始行索引(0-based)
  10875. rowStartIndex, // 结束行索引(0-based)
  10876. 0, // 起始列索引(0-based)
  10877. 3 // 结束列索引(0-based)
  10878. );
  10879. sheet.AddMergedRegion(cellRangeAddress);
  10880. var CellStyle = workbook.CreateCellStyle();
  10881. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10882. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10883. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10884. for (int i = 0; i <= clounmCount; i++)
  10885. {
  10886. if (i > 6)
  10887. {
  10888. var CellStyle1 = workbook.CreateCellStyle();
  10889. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10890. IFont Font = workbook.CreateFont(); // 创建字体
  10891. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  10892. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10893. CellStyle1.SetFont(Font);
  10894. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  10895. }
  10896. else
  10897. {
  10898. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  10899. }
  10900. }
  10901. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  10902. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  10903. //超时合计
  10904. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  10905. //超时数
  10906. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  10907. //超时合计费用
  10908. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  10909. cloneRowFn();
  10910. // 创建合并区域的实例
  10911. cellRangeAddress = new CellRangeAddress(
  10912. rowStartIndex, // 起始行索引(0-based)
  10913. rowStartIndex, // 结束行索引(0-based)
  10914. 0, // 起始列索引(0-based)
  10915. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  10916. );
  10917. // 添加合并区域
  10918. sheet.AddMergedRegion(cellRangeAddress);
  10919. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  10920. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  10921. }
  10922. }
  10923. mergeRow();
  10924. // 保存修改后的Excel文件到新文件
  10925. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  10926. // new FileStream(newFilePath, FileMode.CreateNew)
  10927. using (var stream = new MemoryStream())
  10928. {
  10929. workbook.Write(stream, true);
  10930. stream.Flush();
  10931. stream.Seek(0, SeekOrigin.Begin);
  10932. MemoryStream memoryStream = new MemoryStream();
  10933. stream.CopyTo(memoryStream);
  10934. memoryStream.Seek(0, SeekOrigin.Begin);
  10935. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  10936. }
  10937. workbook.Close();
  10938. workbook.Dispose();
  10939. }
  10940. catch (Exception ex)
  10941. {
  10942. jw.Msg = "出现异常!" + ex.Message;
  10943. return Ok(jw);
  10944. }
  10945. }
  10946. if (Zips.Count > 0)
  10947. {
  10948. IOOperatorHelper io = new IOOperatorHelper();
  10949. var byts = io.ConvertZipStream(Zips);
  10950. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  10951. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  10952. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  10953. }
  10954. else
  10955. {
  10956. jw.Msg = "暂无生成文件!";
  10957. }
  10958. return Ok(jw);
  10959. }
  10960. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  10961. {
  10962. string outStr = string.Empty;
  10963. switch (i)
  10964. {
  10965. case 0:
  10966. outStr = arr[0].SidName;
  10967. break;
  10968. case 1:
  10969. outStr = arr[0].DataPriceStr;
  10970. break;
  10971. case 2:
  10972. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  10973. break;
  10974. case 4:
  10975. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  10976. break;
  10977. case 7:
  10978. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  10979. {
  10980. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  10981. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  10982. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  10983. }
  10984. break;
  10985. case 8:
  10986. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  10987. {
  10988. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  10989. }
  10990. break;
  10991. case 9:
  10992. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  10993. {
  10994. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  10995. }
  10996. break;
  10997. case 10:
  10998. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  10999. {
  11000. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  11001. }
  11002. break;
  11003. }
  11004. return outStr;
  11005. }
  11006. #region OP行程单
  11007. /// <summary>
  11008. /// OP行程单初始化
  11009. /// </summary>
  11010. /// <param name="dto"></param>
  11011. /// <returns></returns>
  11012. [HttpPost]
  11013. public IActionResult InitOpTravel(InitOpTravelDto dto)
  11014. {
  11015. var jw = JsonView(false);
  11016. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  11017. var group = groupList.First();
  11018. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11019. if (group == null)
  11020. {
  11021. jw.Msg = "暂无团组!";
  11022. return Ok(jw);
  11023. }
  11024. group = groupList.Find(x => x.Id == diid);
  11025. if (group == null)
  11026. {
  11027. jw.Msg = "请输入正确的团组ID!";
  11028. return Ok(jw);
  11029. }
  11030. string city = string.Empty;
  11031. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  11032. if (blackCode.Count > 0)
  11033. {
  11034. var black = blackCode.First();
  11035. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  11036. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  11037. if (blackSp.Length > 0)
  11038. {
  11039. try
  11040. {
  11041. var cityArrCode = new List<string>(20);
  11042. foreach (var item in blackSp)
  11043. {
  11044. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  11045. var IndexSelect = itemSp[2];
  11046. var cityArrCodeLength = cityArrCode.Count - 1;
  11047. var startCity = IndexSelect.Substring(0, 3);
  11048. if (cityArrCodeLength > 0)
  11049. {
  11050. var arrEndCity = cityArrCode[cityArrCodeLength];
  11051. if (arrEndCity != startCity)
  11052. {
  11053. cityArrCode.Add(startCity.ToUpper());
  11054. }
  11055. }
  11056. else
  11057. {
  11058. cityArrCode.Add(startCity.ToUpper());
  11059. }
  11060. var endCity = IndexSelect.Substring(3, 3);
  11061. cityArrCode.Add(endCity.ToUpper());
  11062. }
  11063. var cityThree = string.Empty;
  11064. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  11065. cityThree = cityThree.TrimEnd(',');
  11066. if (string.IsNullOrWhiteSpace(cityThree))
  11067. {
  11068. throw new
  11069. Exception("error");
  11070. }
  11071. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  11072. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  11073. foreach (var item in cityArrCode)
  11074. {
  11075. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  11076. if (find != null)
  11077. {
  11078. city += find.City + "/";
  11079. }
  11080. else
  11081. {
  11082. city += item + "三字码未收入/";
  11083. }
  11084. }
  11085. city = city.TrimEnd('/');
  11086. }
  11087. catch (Exception e)
  11088. {
  11089. city = "黑屏代码格式不正确!";
  11090. }
  11091. }
  11092. }
  11093. else
  11094. {
  11095. city = "未录入黑屏代码";
  11096. }
  11097. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  11098. {
  11099. Date = x.Date,
  11100. Days = x.Days,
  11101. Diffgroup = x.Diffgroup,
  11102. Diid = x.Diid,
  11103. Traffic_First = x.Traffic_First,
  11104. Traffic_Second = x.Traffic_Second,
  11105. Trip = x.Trip,
  11106. WeekDay = x.WeekDay,
  11107. Id = x.Id
  11108. }).ToList();
  11109. jw.Data = new
  11110. {
  11111. groupList = groupList.Select(x => new
  11112. {
  11113. x.Id,
  11114. x.TeamName,
  11115. x.TourCode
  11116. }).ToList(),
  11117. groupInfo = new
  11118. {
  11119. group.VisitDays,
  11120. group.TourCode,
  11121. group.VisitPNumber,
  11122. group.TeamName,
  11123. city
  11124. },
  11125. OpTravelList
  11126. };
  11127. jw.Code = 200;
  11128. jw.Msg = "操作成功!";
  11129. return Ok(jw);
  11130. }
  11131. /// <summary>
  11132. /// 删除团组行程单
  11133. /// </summary>
  11134. /// <returns></returns>
  11135. [HttpPost]
  11136. public IActionResult DelTravel(DelOpTravelDto dto)
  11137. {
  11138. var jw = JsonView(false);
  11139. if (dto.UserId <= 0 || dto.Diid <= 0)
  11140. {
  11141. jw.Msg = "请输入正确的参数!";
  11142. return Ok(jw);
  11143. }
  11144. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  11145. .SetColumns(x => new Grp_TravelList
  11146. {
  11147. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11148. DeleteUserId = dto.UserId,
  11149. IsDel = 1,
  11150. }).ExecuteCommand();
  11151. jw = JsonView(true);
  11152. return Ok(jw);
  11153. }
  11154. /// <summary>
  11155. /// 行程单保存
  11156. /// </summary>
  11157. /// <returns></returns>
  11158. [HttpPost]
  11159. public IActionResult TravelSave(TravelSaveDto dto)
  11160. {
  11161. var jw = JsonView(false);
  11162. if (dto.Arr.Count > 0)
  11163. {
  11164. try
  11165. {
  11166. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  11167. .Where(x => dto.Arr.Select(x=>x.Id).Contains(x.Id))
  11168. .ToList();
  11169. _sqlSugar.BeginTran();
  11170. foreach (var item in dto.Arr)
  11171. {
  11172. if (item.Id == 0)
  11173. {
  11174. throw new Exception("请传入正确的Id");
  11175. }
  11176. //比较上一次的差异
  11177. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  11178. if (findTravel != null)
  11179. {
  11180. item.Trip = item.Trip.Replace("[++]", string.Empty);
  11181. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  11182. item.Trip = CheckStr(findTravel.Trip,item.Trip);
  11183. }
  11184. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  11185. .SetColumns(x => new Grp_TravelList
  11186. {
  11187. Trip = item.Trip
  11188. }).ExecuteCommand();
  11189. }
  11190. _sqlSugar.CommitTran();
  11191. jw = JsonView(true);
  11192. }
  11193. catch (Exception ex)
  11194. {
  11195. _sqlSugar.RollbackTran();
  11196. jw.Msg = "程序异常!" + ex.Message;
  11197. }
  11198. }
  11199. else
  11200. {
  11201. jw.Msg = "请传入正确的参数!";
  11202. }
  11203. return Ok(jw);
  11204. }
  11205. private string CheckStr(string original, string changed)
  11206. {
  11207. // 创建diff_match_patch对象
  11208. var dmp = new diff_match_patch();
  11209. // 计算差异
  11210. List<Diff> diffs = dmp.diff_main(original, changed);
  11211. // 清理和合并差异
  11212. dmp.diff_cleanupSemantic(diffs);
  11213. // 使用StringBuilder构建最终的字符串
  11214. StringBuilder finalString = new StringBuilder();
  11215. // 输出差异结果,并构建变动后的字符串
  11216. foreach (Diff diff in diffs)
  11217. {
  11218. switch (diff.operation)
  11219. {
  11220. case Operation.EQUAL:
  11221. // 相等的部分,直接添加到最终字符串
  11222. finalString.Append(diff.text);
  11223. break;
  11224. case Operation.INSERT:
  11225. // 插入的部分,添加标记并添加到最终字符串
  11226. finalString.Append("[++]" + diff.text + "[++]");
  11227. break;
  11228. case Operation.DELETE:
  11229. // 删除的部分,不添加到最终字符串
  11230. //finalString.Append("[++]" + diff.text + "[++]");
  11231. break;
  11232. }
  11233. }
  11234. // 输出变动后的字符串
  11235. return finalString.ToString();
  11236. }
  11237. private class tagContent
  11238. {
  11239. public DateTime Date { get; set; }
  11240. public string StartTag { get; set; }
  11241. public string EndTag { get; set; }
  11242. public string Content { get; set; }
  11243. public static int tagLength { get { return 3; } }
  11244. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  11245. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  11246. public bool IsFinally { get; set; }
  11247. }
  11248. private List<string> ExtractContentBetweenTags(string input, string tag)
  11249. {
  11250. List<string> results = new List<string>();
  11251. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  11252. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  11253. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  11254. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  11255. string[] strValueArr = new string[1];
  11256. foreach (System.Text.RegularExpressions.Match match in matches)
  11257. {
  11258. var strValue = match.Groups[1].Value;
  11259. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  11260. }
  11261. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  11262. return results;
  11263. }
  11264. /// <summary>
  11265. /// 导出行程单
  11266. /// </summary>
  11267. /// <param name="dto"></param>
  11268. /// <returns></returns>
  11269. [HttpPost]
  11270. public IActionResult ExportTravel(ExportTravelDto dto)
  11271. {
  11272. var jw = JsonView(false);
  11273. jw.Data = "";
  11274. int diid = 0;
  11275. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  11276. if (Find == null)
  11277. {
  11278. jw.Msg = "请选择正确的团组!";
  11279. return Ok(jw);
  11280. }
  11281. else
  11282. {
  11283. diid = Find.Id;
  11284. }
  11285. //数据源
  11286. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  11287. DataTable dtBlack = null;
  11288. try
  11289. {
  11290. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  11291. }
  11292. catch (Exception)
  11293. {
  11294. jw.Msg = "机票黑屏代码有误!";
  11295. return Ok(jw);
  11296. }
  11297. string CityStr = string.Empty;
  11298. if (dtBlack.Rows.Count == 0)
  11299. {
  11300. jw.Msg = "机票黑屏代码有误!";
  11301. return Ok(jw);
  11302. }
  11303. else
  11304. {
  11305. foreach (DataRow row in dtBlack.Rows)
  11306. {
  11307. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11308. {
  11309. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  11310. return Ok(jw);
  11311. }
  11312. }
  11313. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  11314. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  11315. }
  11316. // 指定的文字
  11317. var targetTextDic = new Dictionary<string, List<string>>();
  11318. //创建数据源Table
  11319. DataTable dtSource = new DataTable();
  11320. dtSource.Columns.Add("Days", typeof(string));
  11321. dtSource.Columns.Add("Date", typeof(string));
  11322. dtSource.Columns.Add("Week", typeof(string));
  11323. dtSource.Columns.Add("Traffic", typeof(string));
  11324. dtSource.Columns.Add("Trip", typeof(string));
  11325. //获取数据,放到datatable
  11326. foreach (var item in _travelList)
  11327. {
  11328. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  11329. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  11330. .Replace(tagContent.TagFormat.Item2, string.Empty)
  11331. .Replace("[++]", string.Empty);
  11332. DataRow dr = dtSource.NewRow();
  11333. dr["Days"] = item.Days;
  11334. dr["Date"] = item.Date;
  11335. dr["Week"] = item.WeekDay;
  11336. dr["Traffic"] = item.Traffic_First
  11337. + "\r\n"
  11338. + item.Traffic_Second;
  11339. dr["Trip"] = item.Trip;
  11340. dtSource.Rows.Add(dr);
  11341. }
  11342. Dictionary<string, string> dic = new Dictionary<string, string>();
  11343. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  11344. dic.Add("City", CityStr);
  11345. dic.Add("Days", Find.VisitDays.ToString());
  11346. dic.Add("DeleCode", Find.TourCode);
  11347. dic.Add("Pnum", Find.VisitPNumber.ToString());
  11348. //模板路径
  11349. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  11350. //载入模板
  11351. Document doc = null;
  11352. DocumentBuilder builder = null;
  11353. try
  11354. {
  11355. //载入模板
  11356. doc = new Document(tempPath);
  11357. builder = new DocumentBuilder(doc);
  11358. }
  11359. catch (Exception)
  11360. {
  11361. jw.Msg = "模板位置不存在!";
  11362. return Ok(jw);
  11363. }
  11364. foreach (var key in dic.Keys)
  11365. {
  11366. Bookmark bookmark = doc.Range.Bookmarks[key];
  11367. if (bookmark != null)
  11368. {
  11369. builder.MoveToBookmark(key);
  11370. builder.Write(dic[key]);
  11371. }
  11372. }
  11373. //获取word里所有表格
  11374. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11375. //获取所填表格的序数
  11376. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11377. try
  11378. {
  11379. //循环赋值
  11380. for (int i = 0; i < dtSource.Rows.Count; i++)
  11381. {
  11382. builder.MoveToCell(0, i + 1, 0, 0);
  11383. builder.Write(dtSource.Rows[i]["Days"].ToString());
  11384. builder.MoveToCell(0, i + 1, 1, 0);
  11385. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  11386. builder.MoveToCell(0, i + 1, 2, 0);
  11387. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  11388. var trip = dtSource.Rows[i]["Trip"].ToString();
  11389. builder.MoveToCell(0, i + 1, 3, 0);
  11390. builder.Write(trip);
  11391. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  11392. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11393. // 获取特定索引的段落
  11394. Paragraph paragraph = (Paragraph)paragraphs[0];
  11395. Run run = paragraph.Runs[0];
  11396. Aspose.Words.Font font = run.Font;
  11397. font.Name = "黑体";
  11398. //设置双休红色
  11399. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  11400. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11401. paragraph = (Paragraph)paragraphs[1];
  11402. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  11403. {
  11404. run = paragraph.Runs[0];
  11405. font = run.Font;
  11406. font.Color = Color.Red;
  11407. }
  11408. }
  11409. }
  11410. catch (Exception ex)
  11411. {
  11412. }
  11413. //删除多余行
  11414. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  11415. {
  11416. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  11417. }
  11418. var targetTextList = new List<string>();
  11419. // 遍历文档中的表格
  11420. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11421. {
  11422. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11423. {
  11424. var cellIndex = 0;
  11425. foreach (Cell cell in row.Cells)
  11426. {
  11427. if (cellIndex == 1 && row.Cells.Count == 4)
  11428. {
  11429. foreach (var target in targetTextDic.Keys)
  11430. {
  11431. if (cell.GetText().Contains(target))
  11432. {
  11433. targetTextList = targetTextDic[target];
  11434. break;
  11435. }
  11436. }
  11437. }
  11438. // 遍历单元格中的所有段落
  11439. foreach (Paragraph paragraph in cell.Paragraphs)
  11440. {
  11441. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  11442. List<Run> runs = new List<Run>();
  11443. foreach (Run run in paragraph.Runs)
  11444. {
  11445. runs.Add(run);
  11446. }
  11447. foreach (Run run in runs)
  11448. {
  11449. foreach (var targetText in targetTextList)
  11450. {
  11451. // 检查文字是否包含指定文字
  11452. if (run.Text.Contains(targetText))
  11453. {
  11454. // 将包含的部分设置为红色
  11455. HighlightText(run, targetText, Color.Red);
  11456. }
  11457. }
  11458. }
  11459. }
  11460. cellIndex++;
  11461. }
  11462. }
  11463. }
  11464. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  11465. if (!Directory.Exists(savePath))
  11466. {
  11467. try
  11468. {
  11469. Directory.CreateDirectory(savePath);
  11470. }
  11471. catch
  11472. {
  11473. }
  11474. }
  11475. string path = savePath + Find.TeamName + "出访日程";
  11476. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  11477. try
  11478. {
  11479. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  11480. string postfix = ".docx";
  11481. if (dto.IsPDF == 1)
  11482. {
  11483. saveFormat = Aspose.Words.SaveFormat.Pdf;
  11484. postfix = ".pdf";
  11485. }
  11486. doc.Save(path + postfix, saveFormat);
  11487. jw = JsonView(true, "导出成功", ftpPath + postfix);
  11488. }
  11489. catch (Exception)
  11490. {
  11491. jw = JsonView(false);
  11492. }
  11493. return Ok(jw);
  11494. }
  11495. /// <summary>
  11496. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  11497. /// </summary>
  11498. /// <param name="num"></param>
  11499. /// <returns></returns>
  11500. string GetNum(string num)
  11501. {
  11502. string str = "";
  11503. switch (num)
  11504. {
  11505. case "1":
  11506. str = "一";
  11507. break;
  11508. case "2":
  11509. str = "二";
  11510. break;
  11511. case "3":
  11512. str = "三";
  11513. break;
  11514. case "4":
  11515. str = "四";
  11516. break;
  11517. case "5":
  11518. str = "五";
  11519. break;
  11520. case "6":
  11521. str = "六";
  11522. break;
  11523. case "7":
  11524. str = "七";
  11525. break;
  11526. case "8":
  11527. str = "八";
  11528. break;
  11529. case "9":
  11530. str = "九";
  11531. break;
  11532. case "10":
  11533. str = "十";
  11534. break;
  11535. case "11":
  11536. str = "十一";
  11537. break;
  11538. case "12":
  11539. str = "十二";
  11540. break;
  11541. case "一":
  11542. str = "1";
  11543. break;
  11544. case "二":
  11545. str = "2";
  11546. break;
  11547. case "三":
  11548. str = "3";
  11549. break;
  11550. case "四":
  11551. str = "4";
  11552. break;
  11553. case "五":
  11554. str = "5";
  11555. break;
  11556. case "六":
  11557. str = "6";
  11558. break;
  11559. case "七":
  11560. str = "7";
  11561. break;
  11562. case "八":
  11563. str = "8";
  11564. break;
  11565. case "九":
  11566. str = "9";
  11567. break;
  11568. case "十":
  11569. str = "10";
  11570. break;
  11571. case "十一":
  11572. str = "11";
  11573. break;
  11574. case "十二":
  11575. str = "12";
  11576. break;
  11577. }
  11578. return str;
  11579. }
  11580. // 高亮包含指定文字的部分
  11581. void HighlightText(Run run, string targetText, Color color)
  11582. {
  11583. string text = run.Text;
  11584. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  11585. if (startIndex >= 0)
  11586. {
  11587. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  11588. // 前部分
  11589. if (startIndex > 0)
  11590. {
  11591. Run beforeRun = (Run)run.Clone(true);
  11592. beforeRun.Text = text.Substring(0, startIndex);
  11593. parentParagraph.InsertBefore(beforeRun, run);
  11594. }
  11595. // 匹配部分
  11596. Run matchRun = (Run)run.Clone(true);
  11597. matchRun.Text = text.Substring(startIndex, targetText.Length);
  11598. matchRun.Font.Color = color;
  11599. parentParagraph.InsertBefore(matchRun, run);
  11600. // 后部分
  11601. if (startIndex + targetText.Length < text.Length)
  11602. {
  11603. Run afterRun = (Run)run.Clone(true);
  11604. afterRun.Text = text.Substring(startIndex + targetText.Length);
  11605. parentParagraph.InsertBefore(afterRun, run);
  11606. }
  11607. // 删除原始Run
  11608. run.Remove();
  11609. }
  11610. }
  11611. #endregion
  11612. #endregion
  11613. #region 团组成本
  11614. /// <summary>
  11615. /// 团组成本数据初始化
  11616. /// </summary>
  11617. /// <param name="dto"></param>
  11618. /// <returns></returns>
  11619. [HttpPost]
  11620. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  11621. {
  11622. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  11623. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  11624. WHEN COUNT(*) >= 0 THEN 'True'
  11625. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  11626. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  11627. ").ToList(); //团组列表
  11628. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  11629. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  11630. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  11631. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  11632. if (groupinfoValue != null)
  11633. {
  11634. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  11635. var spArr = new string[1] { countryArr };
  11636. if (countryArr.Contains("|"))
  11637. {
  11638. spArr = countryArr.Split("|");
  11639. }
  11640. else if (countryArr.Contains("、"))
  11641. {
  11642. spArr = countryArr.Split("、");
  11643. }
  11644. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  11645. {
  11646. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  11647. if (dbQueryCountry != null)
  11648. {
  11649. visaCountryInfoArr.Add(dbQueryCountry);
  11650. }
  11651. }
  11652. }
  11653. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  11654. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  11655. var create = _GroupCostRepository.
  11656. CreateGroupCostByBlackCode(dto.Diid);
  11657. if (groupCost.Count == 0 && create.Code == 0)
  11658. {
  11659. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  11660. }
  11661. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  11662. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  11663. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  11664. groupCostMap = groupCostMap.Select(x =>
  11665. {
  11666. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  11667. {
  11668. x.Date = dataForamt.ToString("yyyy-MM-dd");
  11669. }
  11670. return x;
  11671. }).ToList();
  11672. //GroupCostParameter.Add(new
  11673. // Grp_GroupCostParameter());
  11674. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  11675. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  11676. return Ok(JsonView(new
  11677. {
  11678. groupList,
  11679. groupInfo,
  11680. groupChecks,
  11681. groupCost = groupCostMap,
  11682. hotelNumber,
  11683. GroupCostParameter = GroupCostParameterMap,
  11684. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  11685. {
  11686. x.VisaCountry,
  11687. x.VisaPrice,
  11688. x.Id,
  11689. }).ToList(),
  11690. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  11691. blackCodeIsTrue = create.Code == 0 ? true : false,
  11692. hotelIsTrue = hotelIsTrue,
  11693. }));
  11694. }
  11695. /// <summary>
  11696. /// 团组成本信息保存
  11697. /// </summary>
  11698. /// <param name="dto"></param>
  11699. /// <returns></returns>
  11700. [HttpPost]
  11701. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  11702. {
  11703. if (dto.Diid <= 0 || dto.Userid <= 0)
  11704. {
  11705. return Ok(JsonView(false));
  11706. }
  11707. JsonView jw = null;
  11708. bool isTrue = false;
  11709. #region 复制团组成本
  11710. //if (dto.Diid == 2581)
  11711. //{
  11712. // dto.Diid = 2599;
  11713. // dto.CheckBoxs.ForEach(x =>
  11714. // {
  11715. // x.Diid = 2599;
  11716. // });
  11717. // dto.GroupCosts.ForEach(x =>
  11718. // {
  11719. // x.Diid = 2599;
  11720. // });
  11721. // dto.CostTypeHotelNumbers.ForEach(x =>
  11722. // {
  11723. // x.Diid = 2599;
  11724. // });
  11725. // dto.GroupCostParameters.ForEach(x =>
  11726. // {
  11727. // x.DiId = 2599;
  11728. // });
  11729. //}
  11730. #endregion
  11731. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  11732. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  11733. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  11734. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  11735. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  11736. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  11737. try
  11738. {
  11739. _sqlSugar.BeginTran();
  11740. isTrue = await _GroupCostRepository.
  11741. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  11742. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  11743. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  11744. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  11745. _sqlSugar.CommitTran();
  11746. jw = JsonView(true, "保存成功!", isTrue);
  11747. }
  11748. catch (Exception)
  11749. {
  11750. _sqlSugar.RollbackTran();
  11751. jw = JsonView(false);
  11752. }
  11753. return Ok(jw);
  11754. }
  11755. /// <summary>
  11756. /// 司兼导数据
  11757. /// </summary>
  11758. /// <param name="dto"></param>
  11759. /// <returns></returns>
  11760. [HttpPost]
  11761. public IActionResult GetCarGuides(CarGuidesDto dto)
  11762. {
  11763. JsonView jw = null;
  11764. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  11765. jw = JsonView(true, "获取成功!", Data);
  11766. return Ok(jw);
  11767. }
  11768. /// <summary>
  11769. /// 导游数据
  11770. /// </summary>
  11771. /// <param name="dto"></param>
  11772. /// <returns></returns>
  11773. [HttpPost]
  11774. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  11775. {
  11776. JsonView jw = null;
  11777. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  11778. // 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
  11779. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  11780. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  11781. jw = JsonView(true, "获取成功!", Data);
  11782. return Ok(jw);
  11783. }
  11784. /// <summary>
  11785. /// 成本车数据
  11786. /// </summary>
  11787. /// <param name="dto"></param>
  11788. /// <returns></returns>
  11789. [HttpPost]
  11790. public IActionResult GetCarInfo(CarGuidesDto dto)
  11791. {
  11792. JsonView jw = null;
  11793. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  11794. jw = JsonView(true, "获取成功!", Data);
  11795. return Ok(jw);
  11796. }
  11797. /// <summary>
  11798. /// 景点数据
  11799. /// </summary>
  11800. /// <param name="dto"></param>
  11801. /// <returns></returns>
  11802. [HttpPost]
  11803. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  11804. {
  11805. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  11806. return Ok(JsonView(true, "获取成功!", Data));
  11807. }
  11808. /// <summary>
  11809. /// 成本通知
  11810. /// </summary>
  11811. /// <param name="dto"></param>
  11812. /// <returns></returns>
  11813. [HttpPost]
  11814. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  11815. {
  11816. if (dto.Diid < 0)
  11817. {
  11818. return Ok(JsonView(false));
  11819. }
  11820. JsonView jw = null;
  11821. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  11822. if (GroupCostParameter != null)
  11823. {
  11824. int IsShare = 0;
  11825. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  11826. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  11827. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  11828. string msg = string.Empty;
  11829. if (isTrue)
  11830. {
  11831. if (IsShare == 0)
  11832. {
  11833. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  11834. }
  11835. else
  11836. {
  11837. #region 企微通知对应岗位用户
  11838. try
  11839. {
  11840. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  11841. }
  11842. catch (Exception ex)
  11843. {
  11844. }
  11845. #endregion
  11846. msg = "通知成功,其他模块操作人员可见此成本信息!";
  11847. }
  11848. jw = JsonView(isTrue, msg, new { IsShare });
  11849. }
  11850. else
  11851. {
  11852. msg = "修改失败!";
  11853. jw = JsonView(isTrue, msg);
  11854. }
  11855. }
  11856. else
  11857. {
  11858. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  11859. }
  11860. return Ok(jw);
  11861. }
  11862. /// <summary>
  11863. /// 导出报价单
  11864. /// </summary>
  11865. /// <param name="dto"></param>
  11866. /// <returns></returns>
  11867. [HttpPost]
  11868. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  11869. {
  11870. if (dto.Diid == 0)
  11871. {
  11872. return Ok(JsonView(false, "请传递团组id"));
  11873. }
  11874. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  11875. if (deleInfo.Code != 0)
  11876. {
  11877. return Ok(JsonView(false, "团组信息查询失败!"));
  11878. }
  11879. var di = deleInfo.Data as DelegationInfoWebView;
  11880. if (di != null)
  11881. {
  11882. di.TeamName = di.TeamName.Replace("|", "、");
  11883. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  11884. //文件名
  11885. string strFileName = di.TeamName + "-收款账单.doc";
  11886. //获取模板
  11887. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  11888. //载入模板
  11889. Document doc = new Document(tmppath);
  11890. decimal TotalPrice = 0.00M;
  11891. string itemStr = string.Empty;
  11892. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  11893. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  11894. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  11895. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  11896. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  11897. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  11898. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  11899. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  11900. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  11901. foreach (var cost in groupCostType)
  11902. {
  11903. var List = cost.ToList();
  11904. if (cost.Key == "A")
  11905. {
  11906. foreach (var ListItem in List)
  11907. {
  11908. if (ListItem.number > 0)
  11909. {
  11910. if (ListItem.code.Contains("TBR"))
  11911. {
  11912. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11913. }
  11914. else
  11915. {
  11916. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11917. }
  11918. TotalPrice += (ListItem.number * ListItem.price);
  11919. }
  11920. }
  11921. }
  11922. else
  11923. {
  11924. itemStr = itemStr.Insert(0, "A段\r\n");
  11925. itemStr += "B段\r\n";
  11926. foreach (var ListItem in List)
  11927. {
  11928. if (ListItem.number > 0)
  11929. {
  11930. if (ListItem.code.Contains("TBR"))
  11931. {
  11932. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11933. }
  11934. else
  11935. {
  11936. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11937. }
  11938. TotalPrice += (ListItem.number * ListItem.price);
  11939. }
  11940. }
  11941. }
  11942. }
  11943. #region 替换Word模板书签内容
  11944. Dictionary<string, string> marks = new Dictionary<string, string>();
  11945. marks.Add("To", di.ClientUnit);//付款方
  11946. marks.Add("ToTel", di.TellPhone);//付款方电话
  11947. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  11948. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  11949. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  11950. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  11951. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  11952. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  11953. marks.Add("PayItemContent", itemStr);//详细信息
  11954. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  11955. #endregion
  11956. ////注
  11957. //if (doc.Range.Bookmarks["Attention"] != null)
  11958. //{
  11959. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  11960. // mark.Text = frList[0].Attention;
  11961. //}
  11962. foreach (var item in marks.Keys)
  11963. {
  11964. if (doc.Range.Bookmarks[item] != null)
  11965. {
  11966. Bookmark mark = doc.Range.Bookmarks[item];
  11967. mark.Text = marks[item];
  11968. }
  11969. }
  11970. byte[] bytes = null;
  11971. using (MemoryStream stream = new MemoryStream())
  11972. {
  11973. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  11974. bytes = stream.ToArray();
  11975. }
  11976. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  11977. return Ok(JsonView(true, "", new
  11978. {
  11979. Data = bytes,
  11980. strFileName,
  11981. }));
  11982. }
  11983. else
  11984. {
  11985. return Ok(JsonView(false, "团组信息不存在!"));
  11986. }
  11987. }
  11988. /// <summary>
  11989. /// 导出团组成本
  11990. /// </summary>
  11991. /// <param name="dto"></param>
  11992. /// <returns></returns>
  11993. [HttpPost]
  11994. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  11995. {
  11996. var jw = JsonView(false);
  11997. if (dto.Diid == 0)
  11998. {
  11999. return Ok(JsonView(false, "请传递团组id"));
  12000. }
  12001. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12002. if (deleInfo.Code != 0)
  12003. {
  12004. return Ok(JsonView(false, "团组信息查询失败!"));
  12005. }
  12006. var di = deleInfo.Data as DelegationInfoWebView;
  12007. if (di == null)
  12008. {
  12009. return Ok(JsonView(false, "团组信息查询失败!"));
  12010. }
  12011. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  12012. WorkbookDesigner designer = new WorkbookDesigner();
  12013. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  12014. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  12015. for (int i = 0; i < List_GC.Count; i++)
  12016. {
  12017. GroupCost_Excel gc = new GroupCost_Excel();
  12018. gc.Id = List_GC[i].Id;
  12019. gc.Diid = List_GC[i].Diid.ToString();
  12020. gc.DAY = List_GC[i].DAY;
  12021. string week = "";
  12022. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  12023. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  12024. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  12025. gc.ITIN = List_GC[i].ITIN;
  12026. gc.CarType = List_GC[i].CarType;
  12027. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  12028. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  12029. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  12030. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  12031. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  12032. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  12033. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  12034. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  12035. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  12036. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  12037. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  12038. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  12039. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12040. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12041. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  12042. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  12043. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  12044. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  12045. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  12046. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  12047. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  12048. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  12049. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  12050. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  12051. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  12052. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  12053. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  12054. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  12055. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  12056. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  12057. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  12058. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  12059. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  12060. List_GC1.Add(gc);
  12061. }
  12062. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  12063. dt.TableName = "TB";
  12064. //报表标题等不用dt的值
  12065. designer.SetDataSource("TeamName", dto.title.TeamName);
  12066. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  12067. designer.SetDataSource("Tax", dto.title.Tax);
  12068. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  12069. designer.SetDataSource("Currency", dto.title.Currency);
  12070. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  12071. designer.SetDataSource("Rate", dto.title.Rate);
  12072. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  12073. var Aparams = hotels.Find(x => x.Type == "Default");
  12074. if (Aparams == null)
  12075. {
  12076. return Ok(jw);
  12077. }
  12078. //酒店数量
  12079. var txtSGRNumber = Aparams.SGR.ToString();
  12080. var txtTBRNumber = Aparams.TBR.ToString();
  12081. var txtJSESNumber = Aparams.JSES.ToString();
  12082. var txtSUITENumbe = Aparams.SUITE.ToString();
  12083. if (dto.costType == "B")
  12084. {
  12085. Aparams = hotels.Find(x => x.Type == "A");
  12086. var Bparams = hotels.Find(x => x.Type == "B");
  12087. if (Aparams == null || Bparams == null)
  12088. {
  12089. return Ok(jw);
  12090. }
  12091. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  12092. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  12093. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  12094. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  12095. }
  12096. designer.SetDataSource("SGRNumber", txtSGRNumber);
  12097. designer.SetDataSource("TBRNumber", txtTBRNumber);
  12098. designer.SetDataSource("JSESNumber", txtJSESNumber);
  12099. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  12100. var ws = designer.Workbook.Worksheets[0];
  12101. int Row = List_GC.Count;
  12102. int startIndex = 11;
  12103. int HideRows = 0;
  12104. List<int> hideRowsList = new List<int>();
  12105. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  12106. #region A段left数据
  12107. var left = dto.leftInfo.Find(x => x.Type == "A");
  12108. if (left == null)
  12109. {
  12110. return Ok(jw);
  12111. }
  12112. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  12113. if (leftBindData != null)
  12114. {
  12115. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  12116. designer.SetDataSource("VisaRS", leftBindData.rs);
  12117. designer.SetDataSource("VisaXS", leftBindData.xs);
  12118. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12119. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12120. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12121. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12122. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12123. }
  12124. else
  12125. {
  12126. hideRowsList.Add(Row + startIndex + HideRows);
  12127. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12128. }
  12129. HideRows += 2;
  12130. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  12131. if (leftBindData != null)
  12132. {
  12133. designer.SetDataSource("BXDRCB", leftBindData.cb);
  12134. designer.SetDataSource("BXRS", leftBindData.rs);
  12135. designer.SetDataSource("BXXS", leftBindData.xs);
  12136. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12137. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12138. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12139. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12140. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12141. }
  12142. else
  12143. {
  12144. hideRowsList.Add(Row + startIndex + HideRows);
  12145. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12146. }
  12147. HideRows += 2;
  12148. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12149. if (leftBindData != null)
  12150. {
  12151. designer.SetDataSource("HSDRCB", leftBindData.cb);
  12152. designer.SetDataSource("HSRS", leftBindData.rs);
  12153. designer.SetDataSource("HSXS", leftBindData.xs);
  12154. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12155. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12156. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12157. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12158. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12159. }
  12160. else
  12161. {
  12162. hideRowsList.Add(Row + startIndex + HideRows);
  12163. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12164. }
  12165. HideRows += 2;
  12166. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12167. if (leftBindData != null)
  12168. {
  12169. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  12170. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  12171. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  12172. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12173. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12174. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12175. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12176. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12177. }
  12178. else
  12179. {
  12180. hideRowsList.Add(Row + startIndex + HideRows);
  12181. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12182. }
  12183. HideRows += 2;
  12184. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12185. if (leftBindData != null)
  12186. {
  12187. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  12188. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  12189. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  12190. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12191. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12192. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12193. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12194. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12195. }
  12196. else
  12197. {
  12198. hideRowsList.Add(Row + startIndex + HideRows);
  12199. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12200. }
  12201. HideRows += 2;
  12202. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12203. if (leftBindData != null)
  12204. {
  12205. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  12206. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  12207. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  12208. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12209. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12210. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12211. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12212. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12213. }
  12214. else
  12215. {
  12216. hideRowsList.Add(Row + startIndex + HideRows);
  12217. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12218. }
  12219. HideRows += 2;
  12220. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12221. if (leftBindData != null)
  12222. {
  12223. ////TBR
  12224. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  12225. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  12226. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  12227. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12228. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12229. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12230. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12231. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12232. }
  12233. else
  12234. {
  12235. hideRowsList.Add(Row + startIndex + HideRows);
  12236. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12237. }
  12238. HideRows += 2;
  12239. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12240. if (leftBindData != null)
  12241. {
  12242. ////SGR
  12243. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  12244. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  12245. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  12246. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12247. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12248. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12249. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12250. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12251. }
  12252. else
  12253. {
  12254. hideRowsList.Add(Row + startIndex + HideRows);
  12255. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12256. }
  12257. HideRows += 2;
  12258. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12259. if (leftBindData != null)
  12260. {
  12261. ////JS/ES
  12262. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  12263. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  12264. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  12265. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12266. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12267. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12268. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12269. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12270. }
  12271. else
  12272. {
  12273. hideRowsList.Add(Row + startIndex + HideRows);
  12274. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12275. }
  12276. HideRows += 2;
  12277. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12278. if (leftBindData != null)
  12279. {
  12280. ////SUITE
  12281. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  12282. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  12283. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  12284. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12285. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12286. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12287. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12288. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12289. }
  12290. else
  12291. {
  12292. hideRowsList.Add(Row + startIndex + HideRows);
  12293. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12294. }
  12295. HideRows += 2;
  12296. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12297. if (leftBindData != null)
  12298. {
  12299. designer.SetDataSource("DJDRCB", leftBindData.cb);
  12300. designer.SetDataSource("DJRS", leftBindData.rs);
  12301. designer.SetDataSource("DJXS", leftBindData.xs);
  12302. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12303. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12304. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12305. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12306. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12307. }
  12308. else
  12309. {
  12310. hideRowsList.Add(Row + startIndex + HideRows);
  12311. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12312. }
  12313. HideRows += 2;
  12314. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12315. if (leftBindData != null)
  12316. {
  12317. designer.SetDataSource("HCPCB", leftBindData.cb);
  12318. designer.SetDataSource("HCPRS", leftBindData.rs);
  12319. designer.SetDataSource("HCPXS", leftBindData.xs);
  12320. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12321. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12322. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12323. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12324. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12325. }
  12326. else
  12327. {
  12328. hideRowsList.Add(Row + startIndex + HideRows);
  12329. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12330. }
  12331. HideRows += 2;
  12332. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12333. if (leftBindData != null)
  12334. {
  12335. designer.SetDataSource("CPCB", leftBindData.cb);
  12336. designer.SetDataSource("CPRS", leftBindData.rs);
  12337. designer.SetDataSource("CPXS", leftBindData.xs);
  12338. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12339. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12340. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12341. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12342. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12343. }
  12344. else
  12345. {
  12346. hideRowsList.Add(Row + startIndex + HideRows);
  12347. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12348. }
  12349. HideRows += 2;
  12350. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12351. if (leftBindData != null)
  12352. {
  12353. designer.SetDataSource("GWDRCD", leftBindData.cb);
  12354. designer.SetDataSource("GWRS", leftBindData.rs);
  12355. designer.SetDataSource("GWXS", leftBindData.xs);
  12356. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12357. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12358. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12359. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12360. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12361. }
  12362. else
  12363. {
  12364. hideRowsList.Add(Row + startIndex + HideRows);
  12365. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12366. }
  12367. HideRows += 2;
  12368. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12369. if (leftBindData != null)
  12370. {
  12371. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  12372. designer.SetDataSource("LYJRS", leftBindData.rs);
  12373. designer.SetDataSource("LYJXS", leftBindData.xs);
  12374. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12375. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12376. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12377. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12378. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12379. }
  12380. else
  12381. {
  12382. hideRowsList.Add(Row + startIndex + HideRows);
  12383. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12384. }
  12385. #endregion
  12386. #region A段Right信息
  12387. var right = dto.rightInfo.Find(x => x.Type == "A");
  12388. if (right == null)
  12389. {
  12390. return Ok(jw);
  12391. }
  12392. HideRows += 4;
  12393. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12394. if (rightBindData != null)
  12395. {
  12396. //经济舱 + 双人间 TBR
  12397. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  12398. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  12399. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12400. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  12401. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12402. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12403. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12404. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12405. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12406. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12407. }
  12408. else
  12409. {
  12410. hideRowsList.Add(Row + startIndex + HideRows);
  12411. }
  12412. HideRows += 2;
  12413. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12414. if (rightBindData != null)
  12415. {
  12416. //经济舱 + 单人间 SGR
  12417. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  12418. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  12419. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12420. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  12421. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12422. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12423. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12424. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12425. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12426. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12427. }
  12428. else
  12429. {
  12430. hideRowsList.Add(Row + startIndex + HideRows);
  12431. }
  12432. HideRows += 2;
  12433. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12434. if (rightBindData != null)
  12435. {
  12436. //公务舱 + 单人间 SGR
  12437. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  12438. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  12439. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12440. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  12441. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12442. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12443. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12444. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12445. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12446. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12447. }
  12448. else
  12449. {
  12450. hideRowsList.Add(Row + startIndex + HideRows);
  12451. }
  12452. HideRows += 2;
  12453. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12454. if (rightBindData != null)
  12455. {
  12456. //公务舱 + 小套房 JSES
  12457. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  12458. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  12459. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12460. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  12461. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12462. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12463. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12464. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12465. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12466. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12467. }
  12468. else
  12469. {
  12470. hideRowsList.Add(Row + startIndex + HideRows);
  12471. }
  12472. HideRows += 2;
  12473. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12474. if (rightBindData != null)
  12475. {
  12476. //公务舱 + 小套房 JSES
  12477. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  12478. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  12479. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12480. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  12481. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12482. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12483. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12484. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12485. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12486. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12487. }
  12488. else
  12489. {
  12490. hideRowsList.Add(Row + startIndex + HideRows);
  12491. }
  12492. HideRows += 2;
  12493. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12494. if (rightBindData != null)
  12495. {
  12496. //经济舱 + 大套房
  12497. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  12498. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  12499. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12500. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  12501. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12502. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12503. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12504. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12505. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12506. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12507. }
  12508. else
  12509. {
  12510. hideRowsList.Add(Row + startIndex + HideRows);
  12511. }
  12512. HideRows += 2;
  12513. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12514. if (rightBindData != null)
  12515. {
  12516. //头等舱 + 小套房 JSES
  12517. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  12518. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  12519. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12520. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  12521. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12522. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12523. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12524. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12525. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12526. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12527. }
  12528. else
  12529. {
  12530. hideRowsList.Add(Row + startIndex + HideRows);
  12531. }
  12532. HideRows += 2;
  12533. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12534. if (rightBindData != null)
  12535. {
  12536. //头等舱 + 大套房
  12537. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  12538. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  12539. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12540. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  12541. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12542. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12543. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12544. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12545. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12546. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12547. }
  12548. else
  12549. {
  12550. hideRowsList.Add(Row + startIndex + HideRows);
  12551. }
  12552. #endregion
  12553. #region B段标题清空
  12554. designer.SetDataSource("CostBDRCB", "");
  12555. designer.SetDataSource("CostBRS", "");
  12556. designer.SetDataSource("CostBXS", "");
  12557. designer.SetDataSource("CostBZCB", "");
  12558. designer.SetDataSource("CostBDRBJ", "");
  12559. designer.SetDataSource("CostBZBJ", "");
  12560. designer.SetDataSource("CostBDRLR", "");
  12561. designer.SetDataSource("CostBZLR", "");
  12562. designer.SetDataSource("CostBDRCBOM", "");
  12563. designer.SetDataSource("CostBRSOM", "");
  12564. designer.SetDataSource("CostBZCBOM", "");
  12565. designer.SetDataSource("CostBDRBJOM", "");
  12566. designer.SetDataSource("CostBZBJOM", "");
  12567. designer.SetDataSource("CostBDRLROM", "");
  12568. designer.SetDataSource("CostBZLROM", "");
  12569. #endregion
  12570. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  12571. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  12572. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  12573. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  12574. designer.SetDataSource("DJName", "地接(CNY)");
  12575. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  12576. designer.SetDataSource("CPName", "地接-船票(CNY)");
  12577. designer.SetDataSource("GWName", "公务(CNY)");
  12578. designer.SetDataSource("YQHName", "邀请函(CNY)");
  12579. designer.SetDataSource("LYJName", "零用金(CNY)");
  12580. designer.SetDataSource("HSName", "核酸检测(CNY)");
  12581. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  12582. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  12583. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  12584. designer.SetDataSource("BXName", "保险(CNY)");
  12585. designer.SetDataSource("VisaName", "签证(CNY)");
  12586. #region B段基本数据
  12587. if (dto.costType == "B")
  12588. {
  12589. left = dto.leftInfo.Find(x => x.Type == "B");
  12590. if (left == null)
  12591. {
  12592. return Ok(jw);
  12593. }
  12594. #region B段left数据
  12595. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12596. if (leftBindData != null)
  12597. {
  12598. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  12599. designer.SetDataSource("BHSRS", leftBindData.rs);
  12600. designer.SetDataSource("BHSXS", leftBindData.xs);
  12601. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12602. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12603. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12604. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12605. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12606. }
  12607. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12608. if (leftBindData != null)
  12609. {
  12610. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  12611. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  12612. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  12613. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12614. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12615. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12616. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12617. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12618. }
  12619. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12620. if (leftBindData != null)
  12621. {
  12622. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  12623. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  12624. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  12625. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12626. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12627. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12628. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12629. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12630. }
  12631. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12632. if (leftBindData != null)
  12633. {
  12634. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  12635. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  12636. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  12637. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12638. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12639. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12640. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12641. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12642. }
  12643. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12644. if (leftBindData != null)
  12645. {
  12646. designer.SetDataSource("BHCPCB", leftBindData.cb);
  12647. designer.SetDataSource("BHCPRS", leftBindData.rs);
  12648. designer.SetDataSource("BHCPXS", leftBindData.xs);
  12649. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12650. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12651. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12652. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12653. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12654. }
  12655. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12656. if (leftBindData != null)
  12657. {
  12658. designer.SetDataSource("BCPCB", leftBindData.cb);
  12659. designer.SetDataSource("BCPRS", leftBindData.rs);
  12660. designer.SetDataSource("BCPXS", leftBindData.xs);
  12661. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12662. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12663. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12664. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12665. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12666. }
  12667. //TBR
  12668. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12669. if (leftBindData != null)
  12670. {
  12671. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  12672. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  12673. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  12674. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12675. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12676. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12677. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12678. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12679. }
  12680. //SGR
  12681. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12682. if (leftBindData != null)
  12683. {
  12684. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  12685. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  12686. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  12687. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12688. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12689. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12690. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12691. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12692. }
  12693. //JS/ES
  12694. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12695. if (leftBindData != null)
  12696. {
  12697. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  12698. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  12699. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  12700. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12701. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12702. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12703. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12704. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12705. }
  12706. //SUITE
  12707. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12708. if (leftBindData != null)
  12709. {
  12710. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  12711. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  12712. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  12713. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12714. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12715. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12716. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12717. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12718. }
  12719. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12720. if (leftBindData != null)
  12721. {
  12722. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  12723. designer.SetDataSource("BDJRS", leftBindData.rs);
  12724. designer.SetDataSource("BDJXS", leftBindData.xs);
  12725. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12726. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12727. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12728. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12729. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12730. }
  12731. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12732. if (leftBindData != null)
  12733. {
  12734. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  12735. designer.SetDataSource("BGWRS", leftBindData.rs);
  12736. designer.SetDataSource("BGWXS", leftBindData.xs);
  12737. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12738. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12739. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12740. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12741. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12742. }
  12743. #region 优化方案
  12744. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  12745. //excelBind.Add("零用金", new {
  12746. //cb="",
  12747. //rs="",
  12748. //xs ="",
  12749. //zcb = "",
  12750. //});
  12751. #endregion
  12752. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12753. if (leftBindData != null)
  12754. {
  12755. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  12756. designer.SetDataSource("BLYJRS", leftBindData.rs);
  12757. designer.SetDataSource("BLYJXS", leftBindData.xs);
  12758. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12759. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12760. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12761. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12762. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12763. }
  12764. #endregion
  12765. #region B段Right信息
  12766. right = dto.rightInfo.Find(x => x.Type == "B");
  12767. if (right == null)
  12768. {
  12769. return Ok(jw);
  12770. }
  12771. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12772. if (rightBindData != null)
  12773. {
  12774. //经济舱 + 双人间 TBR
  12775. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  12776. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  12777. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12778. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  12779. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12780. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12781. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12782. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12783. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12784. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12785. }
  12786. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12787. if (rightBindData != null)
  12788. {
  12789. //经济舱 + 单人间 SGR
  12790. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  12791. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  12792. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12793. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  12794. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12795. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12796. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12797. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12798. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12799. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12800. }
  12801. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12802. if (rightBindData != null)
  12803. {
  12804. //公务舱 + 单人间 SGR
  12805. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  12806. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  12807. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12808. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  12809. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12810. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12811. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12812. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12813. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12814. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12815. }
  12816. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12817. if (rightBindData != null)
  12818. {
  12819. //公务舱 + 小套房 JSES
  12820. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  12821. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  12822. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12823. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  12824. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12825. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12826. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12827. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12828. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12829. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12830. }
  12831. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12832. if (rightBindData != null)
  12833. {
  12834. //公务舱 + 小套房 JSES
  12835. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  12836. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  12837. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12838. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  12839. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12840. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12841. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12842. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12843. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12844. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12845. }
  12846. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12847. if (rightBindData != null)
  12848. {
  12849. //经济舱 + 大套房
  12850. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  12851. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  12852. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12853. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  12854. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12855. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12856. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12857. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12858. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12859. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12860. }
  12861. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12862. if (rightBindData != null)
  12863. {
  12864. //头等舱 + 小套房 JSES
  12865. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  12866. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  12867. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12868. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  12869. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12870. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12871. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12872. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12873. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12874. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12875. }
  12876. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12877. if (rightBindData != null)
  12878. {
  12879. //头等舱 + 大套房
  12880. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  12881. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  12882. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12883. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  12884. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12885. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12886. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12887. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12888. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12889. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12890. }
  12891. #endregion
  12892. #region 标题
  12893. designer.SetDataSource("CostBDRCB", "单人成本");
  12894. designer.SetDataSource("CostBRS", "人数");
  12895. designer.SetDataSource("CostBXS", "系数");
  12896. designer.SetDataSource("CostBZCB", "总成本");
  12897. designer.SetDataSource("CostBDRBJ", "单人报价");
  12898. designer.SetDataSource("CostBZBJ", "总报价");
  12899. designer.SetDataSource("CostBDRLR", "单人利润");
  12900. designer.SetDataSource("CostBZLR", "总利润");
  12901. designer.SetDataSource("CostBDRCBOM", "单人成本");
  12902. designer.SetDataSource("CostBRSOM", "人数");
  12903. designer.SetDataSource("CostBZCBOM", "总成本");
  12904. designer.SetDataSource("CostBDRBJOM", "单人报价");
  12905. designer.SetDataSource("CostBZBJOM", "总报价");
  12906. designer.SetDataSource("CostBDRLROM", "单人利润");
  12907. designer.SetDataSource("CostBZLROM", "总利润");
  12908. #endregion
  12909. }
  12910. #endregion
  12911. designer.SetDataSource("TzZCB2", TzZCB2);
  12912. designer.SetDataSource("TzZBJ2", TzZBJ2);
  12913. designer.SetDataSource("TzZLR2", TzZLR2);
  12914. string[] dataSourceKeys = new string[]
  12915. {
  12916. "VF",
  12917. "TGS",
  12918. "TGOF",
  12919. "TGM",
  12920. "TGA",
  12921. "TGTF",
  12922. "TGEF",
  12923. "CFM",
  12924. "CFOF",
  12925. "B",
  12926. "L",
  12927. "D",
  12928. "TBR",
  12929. "SGR",
  12930. "JSES",
  12931. "Suite",
  12932. "TV",
  12933. "1L",
  12934. "IF",
  12935. "EF",
  12936. "BRF",
  12937. "TE",
  12938. "TGT",
  12939. "DRVT",
  12940. "PC",
  12941. "TLF",
  12942. "ECT"
  12943. };
  12944. foreach (var item in dataSourceKeys)
  12945. {
  12946. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  12947. if (find != null)
  12948. {
  12949. designer.SetDataSource(item, find.text);
  12950. }
  12951. else
  12952. {
  12953. designer.SetDataSource(item, 0);
  12954. }
  12955. }
  12956. designer.SetDataSource(dt);
  12957. //根据数据源处理生成报表内容
  12958. designer.Process();
  12959. designer.Workbook.Worksheets[0].Name = "清单";
  12960. Worksheet sheet = designer.Workbook.Worksheets[0];
  12961. foreach (var Rowindex in hideRowsList)
  12962. {
  12963. ws.Cells.HideRows(Rowindex, 2);
  12964. }
  12965. byte[] bytes = null;
  12966. string strFileName = di.TeamName + "-团组-成本.xls";
  12967. using (MemoryStream stream = new MemoryStream())
  12968. {
  12969. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  12970. bytes = stream.ToArray();
  12971. }
  12972. return Ok(JsonView(true, "", new
  12973. {
  12974. Data = bytes,
  12975. strFileName,
  12976. }));
  12977. }
  12978. /// <summary>
  12979. /// 导出客户报表
  12980. /// </summary>
  12981. /// <returns></returns>
  12982. [HttpPost]
  12983. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  12984. {
  12985. var jw = JsonView(false);
  12986. if (dto.Diid == 0)
  12987. {
  12988. return Ok(JsonView(false, "请传递团组id"));
  12989. }
  12990. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12991. if (deleInfo.Code != 0)
  12992. {
  12993. return Ok(JsonView(false, "团组信息查询失败!"));
  12994. }
  12995. var di = deleInfo.Data as DelegationInfoWebView;
  12996. if (di == null)
  12997. {
  12998. return Ok(JsonView(false, "团组信息查询失败!"));
  12999. }
  13000. //文件名
  13001. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  13002. //获取模板
  13003. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  13004. //载入模板
  13005. Document doc = new Document(tmppath);
  13006. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  13007. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  13008. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  13009. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  13010. var AParameter = ParameterList.Find(x => x.CostType == "A");
  13011. var BParameter = ParameterList.Find(x => x.CostType == "B");
  13012. if (AParameter == null)
  13013. {
  13014. return Ok(JsonView(false, "系数不存在!"));
  13015. }
  13016. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  13017. , TzAirDesc, TzZCost;
  13018. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  13019. = TzAirDesc = TzZCost = string.Empty;
  13020. TzNumber = AParameter.CostTypenumber.ToString();
  13021. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  13022. CarGuides1 = dto.CarGuides1;
  13023. Meal = dto.Meal;
  13024. SubsidizedMeals = dto.SubsidizedMeals;
  13025. NightRepair = dto.NightRepair;
  13026. AttractionsTickets = dto.AttractionsTickets;
  13027. MiscellaneousFees = dto.MiscellaneousFees;
  13028. ATip = dto.ATip;
  13029. TzHotelDesc = "";
  13030. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  13031. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  13032. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  13033. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  13034. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  13035. TzAirDesc = "";
  13036. TzZCost = dto.TzZCost;
  13037. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  13038. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  13039. var index = 1;
  13040. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  13041. foreach (var item in TzHotelDescArr)
  13042. {
  13043. if (AinfoArr != null)
  13044. {
  13045. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13046. if (Ainfo != null)
  13047. {
  13048. if (int.Parse(Ainfo.rs) <= 0)
  13049. {
  13050. continue;
  13051. }
  13052. var hotelText = string.Empty;
  13053. switch (item)
  13054. {
  13055. case "SGR":
  13056. hotelText = "单人间";
  13057. break;
  13058. case "JSES":
  13059. hotelText = "小套房";
  13060. break;
  13061. case "SUITE":
  13062. hotelText = "套房";
  13063. break;
  13064. case "TBR":
  13065. hotelText = "双人间";
  13066. break;
  13067. }
  13068. if (item != "TBR")
  13069. {
  13070. 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";
  13071. }
  13072. else
  13073. {
  13074. 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";
  13075. }
  13076. index++;
  13077. }
  13078. }
  13079. }
  13080. index = 1;
  13081. foreach (var item in TzAirDescArr)
  13082. {
  13083. if (AinfoArr != null)
  13084. {
  13085. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13086. if (Ainfo != null)
  13087. {
  13088. if (int.Parse(Ainfo.rs) <= 0)
  13089. {
  13090. continue;
  13091. }
  13092. 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";
  13093. index++;
  13094. }
  13095. }
  13096. }
  13097. if (dto.costType == "B")
  13098. {
  13099. if (BParameter == null)
  13100. {
  13101. return Ok(JsonView(false, "B段系数不存在!"));
  13102. }
  13103. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  13104. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  13105. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  13106. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  13107. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  13108. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  13109. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  13110. foreach (var item in TzHotelDescArr)
  13111. {
  13112. if (AinfoArr != null)
  13113. {
  13114. TzHotelDesc += "B段信息 \r\n";
  13115. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13116. if (Ainfo != null)
  13117. {
  13118. if (int.Parse(Ainfo.rs) <= 0)
  13119. {
  13120. continue;
  13121. }
  13122. var hotelText = string.Empty;
  13123. switch (item)
  13124. {
  13125. case "SGR":
  13126. hotelText = "单人间";
  13127. break;
  13128. case "JSES":
  13129. hotelText = "小套房";
  13130. break;
  13131. case "SUITE":
  13132. hotelText = "套房";
  13133. break;
  13134. case "TBR":
  13135. hotelText = "双人间";
  13136. break;
  13137. }
  13138. if (item != "TBR")
  13139. {
  13140. 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";
  13141. }
  13142. else
  13143. {
  13144. 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";
  13145. }
  13146. index++;
  13147. }
  13148. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  13149. }
  13150. }
  13151. index = 1;
  13152. foreach (var item in TzAirDescArr)
  13153. {
  13154. if (AinfoArr != null)
  13155. {
  13156. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13157. if (Ainfo != null)
  13158. {
  13159. if (int.Parse(Ainfo.rs) <= 0)
  13160. {
  13161. continue;
  13162. }
  13163. 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";
  13164. index++;
  13165. }
  13166. }
  13167. }
  13168. }
  13169. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  13170. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  13171. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  13172. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  13173. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  13174. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  13175. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  13176. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  13177. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  13178. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  13179. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  13180. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  13181. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  13182. DickeyValue.Add("Visa", Visa); // 签证单人报价
  13183. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  13184. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  13185. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  13186. DickeyValue.Add("TzZCost", TzZCost);
  13187. foreach (var key in DickeyValue.Keys)
  13188. {
  13189. if (doc.Range.Bookmarks[key] != null)
  13190. {
  13191. Bookmark mark = doc.Range.Bookmarks[key];
  13192. mark.Text = DickeyValue[key];
  13193. }
  13194. }
  13195. byte[] bytes = null;
  13196. string strFileName = di.TeamName + "-客户报价.doc";
  13197. using (MemoryStream stream = new MemoryStream())
  13198. {
  13199. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13200. bytes = stream.ToArray();
  13201. }
  13202. return Ok(JsonView(true, "", new
  13203. {
  13204. Data = bytes,
  13205. strFileName,
  13206. }));
  13207. }
  13208. /// <summary>
  13209. /// 团组成本 各模块(酒店,地接,机票)成本提示
  13210. /// </summary>
  13211. /// <param name="dto"></param>
  13212. /// <returns></returns>
  13213. [HttpPost]
  13214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13215. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  13216. {
  13217. try
  13218. {
  13219. #region 参数验证
  13220. if (dto.DiId < 0)
  13221. {
  13222. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  13223. }
  13224. List<int> cTableIds = new List<int>() {
  13225. 76 ,//酒店预订
  13226. 77 ,//行程
  13227. 79 ,//车/导游地接
  13228. 80 ,//签证
  13229. 81 ,//邀请/公务活
  13230. 82 ,//团组客户保险
  13231. 85 ,//机票预订
  13232. 98 ,//其他款项
  13233. 285 ,//收款退还
  13234. 751 ,//酒店早餐
  13235. 1015 // 超支费用
  13236. };
  13237. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  13238. {
  13239. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  13240. }
  13241. #endregion
  13242. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  13243. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  13244. if (_GroupCostParameters.Count <= 0)
  13245. {
  13246. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  13247. }
  13248. if (_GroupCostParameters[0].IsShare == 0)
  13249. {
  13250. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  13251. }
  13252. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13253. //处理date为空问题
  13254. if (_GroupCosts.Count > 0)
  13255. {
  13256. for (int i = 0; i < _GroupCosts.Count; i++)
  13257. {
  13258. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  13259. {
  13260. if (i > 0)
  13261. {
  13262. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  13263. }
  13264. }
  13265. }
  13266. }
  13267. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  13268. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  13269. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  13270. string currCode = "";
  13271. #region currCode 验证
  13272. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  13273. if (isInt)
  13274. {
  13275. var currData = currDatas.Find(it => it.Id == intCurrency);
  13276. if (currData != null)
  13277. {
  13278. currCode = currData.Name;
  13279. }
  13280. }
  13281. else
  13282. {
  13283. currCode = _GroupCostParameters[0].Currency.Trim();
  13284. }
  13285. #endregion
  13286. //op,酒店单段模式存储
  13287. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  13288. {
  13289. CurrencyCode = currCode,
  13290. Rate = _GroupCostParameters[0].Rate,
  13291. CostType = _GroupCostParameters[0].CostType,
  13292. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  13293. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  13294. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  13295. };
  13296. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  13297. if (_GroupCostParameters.Count == 2)
  13298. {
  13299. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  13300. }
  13301. foreach (var item in _GroupCostParameters)
  13302. {
  13303. decimal _rate = 1;
  13304. decimal _rate1 = item.Rate;
  13305. decimal _scale = 1;
  13306. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  13307. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  13308. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  13309. //if (userInfo != null)
  13310. //{
  13311. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  13312. // {
  13313. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  13314. // {
  13315. // _scale = 1.00M;
  13316. // }
  13317. // }
  13318. //}
  13319. #endregion
  13320. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  13321. {
  13322. CurrencyCode = currCode,
  13323. Rate = _rate1,
  13324. CostType = item.CostType,
  13325. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  13326. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  13327. CostTypeNumber = item.CostTypenumber
  13328. };
  13329. if (_GroupCostParameters.Count > 1)
  13330. {
  13331. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  13332. }
  13333. else
  13334. {
  13335. modulePromptInfo.CostTypeNumber = item.LYJRS;
  13336. }
  13337. if (dto.CTable == 79)//
  13338. {
  13339. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  13340. modulePromptInfo.TotalCost = item.DJCB;
  13341. }
  13342. List<string> costTypes = new List<string>() { "A", "B" };
  13343. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  13344. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  13345. if (_GroupCostsDuplicates.Count() == 1)
  13346. {
  13347. _GroupCostsTypeData = _GroupCosts;
  13348. }
  13349. else
  13350. {
  13351. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  13352. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  13353. }
  13354. /*
  13355. * 76 酒店预订
  13356. * 77 行程
  13357. * 79 车/导游地接
  13358. * 80 签证
  13359. * 81 邀请/公务活动
  13360. * 82 团组客户保险
  13361. * 85 机票预订
  13362. * 98 其他款项
  13363. * 285 收款退还
  13364. * 751 酒店早餐
  13365. * 1015 超支费用
  13366. */
  13367. switch (dto.CTable)
  13368. {
  13369. case 76: // 酒店预订
  13370. _ModuleSubPromptInfo.AddRange(
  13371. _GroupCostsTypeData.Select(it => new
  13372. {
  13373. it.DAY,
  13374. it.Date,
  13375. it.ACCON,
  13376. it.ITIN,
  13377. it.SGR,
  13378. it.TBR,
  13379. it.JS_ES,
  13380. it.Suite
  13381. })
  13382. );
  13383. break;
  13384. case 79: // 车/导游地接
  13385. _ModuleSubPromptInfo.AddRange(
  13386. _GroupCostsTypeData.Select(it => new
  13387. {
  13388. Date = it.Date, //日期
  13389. CarFee = it.CarCost * _rate * _scale, //车费用
  13390. CarType = it.CarType, //车型
  13391. DriverFee = it.CFS * _rate * _scale, //司机工资
  13392. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  13393. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  13394. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  13395. GuideFee = it.TGS * _rate * _scale, //导游费用
  13396. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  13397. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  13398. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  13399. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  13400. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  13401. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  13402. Breakfast = it.B * _rate * _scale, //早餐费
  13403. Lunch = it.L * _rate * _scale, //午餐费
  13404. Dinner = it.D * _rate * _scale, //晚餐费
  13405. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  13406. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  13407. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  13408. TicketFee = it.EF * _rate * _scale, //门票费
  13409. TicketRemark = it.EFR, //门票费描述
  13410. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  13411. TravelSupplies = it.TE * _rate * _scale, //出行物资
  13412. SpentCash = it.PC * _rate * _scale, //零用金
  13413. LeadersFee = it.TLF * _rate * _scale, //领队费
  13414. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  13415. })
  13416. );
  13417. break;
  13418. case 85: // 机票
  13419. List<dynamic> datas = new List<dynamic>();
  13420. datas.Add(
  13421. new
  13422. {
  13423. AirType = "经济舱",
  13424. AirNum = item.JJCRS,
  13425. AirDRCB = item.JJCCB,
  13426. AirZCB = (item.JJCRS * item.JJCCB)
  13427. }
  13428. );
  13429. datas.Add(
  13430. new
  13431. {
  13432. AirType = "公务舱",
  13433. AirNum = item.GWCRS,
  13434. AirDRCB = item.GWCCB,
  13435. AirZCB = (item.GWCRS * item.GWCCB)
  13436. }
  13437. );
  13438. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13439. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  13440. modulePromptInfo.Data = new
  13441. {
  13442. airFeeData = datas,
  13443. airInitData = initDatas
  13444. };
  13445. _ModulePromptInfos.Add(modulePromptInfo);
  13446. break;
  13447. default:
  13448. break;
  13449. }
  13450. }
  13451. if (dto.CTable != 85)
  13452. {
  13453. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  13454. _ModulePromptInfos.Add(_ModulePromptInfo);
  13455. }
  13456. _view.ModulePromptInfos = _ModulePromptInfos;
  13457. return Ok(JsonView(true, "操作成功!", _view));
  13458. }
  13459. catch (Exception ex)
  13460. {
  13461. return Ok(JsonView(false, ex.Message));
  13462. }
  13463. }
  13464. /// <summary>
  13465. /// 根据黑屏代码重新生成行程
  13466. /// </summary>
  13467. /// <param name="dto"></param>
  13468. /// <returns></returns>
  13469. [HttpPost]
  13470. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  13471. {
  13472. var jw = JsonView(false);
  13473. var Create = _GroupCostRepository.
  13474. CreateGroupCostByBlackCode(dto.Diid);
  13475. jw.Msg = Create.Msg;
  13476. if (Create.Code == 0)
  13477. {
  13478. jw.Code = 200;
  13479. jw.Data = new
  13480. {
  13481. groupCost = Create.Data,
  13482. blackCodeIsTrue = true
  13483. };
  13484. }
  13485. else
  13486. {
  13487. jw.Code = 400;
  13488. jw.Data = new
  13489. {
  13490. groupCost = Create.Data,
  13491. blackCodeIsTrue = false,
  13492. };
  13493. }
  13494. return Ok(jw);
  13495. }
  13496. /// <summary>
  13497. /// 成本获取OP历史车费用
  13498. /// </summary>
  13499. /// <param name="dto"></param>
  13500. /// <returns></returns>
  13501. [HttpPost]
  13502. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  13503. {
  13504. var jw = JsonView(false);
  13505. try
  13506. {
  13507. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  13508. //获取现有所有车的数据
  13509. if (!dto.Param.IsNullOrWhiteSpace())
  13510. {
  13511. string sql = $@"
  13512. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  13513. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  13514. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  13515. 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
  13516. AND gctggr.ServiceEndTime is not NULL
  13517. ORDER by gctggrc.id DESC
  13518. ";
  13519. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  13520. var numeberResult = await Task.Run(() =>
  13521. {
  13522. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  13523. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  13524. return numberArr;
  13525. });
  13526. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  13527. foreach (var item in numeberResult)
  13528. {
  13529. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  13530. {
  13531. Country = "数据异常!",
  13532. City = string.Empty,
  13533. };
  13534. item.Area = find.Country + " " + find.City;
  13535. }
  13536. dbResult.AddRange(numeberResult);
  13537. if (dto.Param.Contains("、"))
  13538. {
  13539. var sp = dto.Param.Split("、");
  13540. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13541. .Where(x =>
  13542. {
  13543. return System.Array.Exists(sp, e =>
  13544. {
  13545. bool where = false;
  13546. if (x.Area != null)
  13547. {
  13548. where = x.Area.Contains(e);
  13549. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13550. {
  13551. return false;
  13552. }
  13553. }
  13554. if (x.PriceName != null && !where)
  13555. {
  13556. where = x.PriceName.Contains(e);
  13557. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13558. {
  13559. return false;
  13560. }
  13561. }
  13562. return where;
  13563. });
  13564. }).ToList();
  13565. }
  13566. else
  13567. {
  13568. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13569. .Where(x =>
  13570. {
  13571. bool where = false;
  13572. if (x.Area != null)
  13573. {
  13574. where = x.Area.Contains(dto.Param);
  13575. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13576. {
  13577. return false;
  13578. }
  13579. }
  13580. if (x.PriceName != null && !where)
  13581. {
  13582. where = x.PriceName.Contains(dto.Param);
  13583. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13584. {
  13585. return false;
  13586. }
  13587. }
  13588. return where;
  13589. }
  13590. )
  13591. .ToList();
  13592. }
  13593. }
  13594. var view = dbResult.Select(x =>
  13595. {
  13596. decimal dp = 0.00M;
  13597. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  13598. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  13599. if (string.IsNullOrWhiteSpace(x.DatePrice))
  13600. {
  13601. if (startB && endB)
  13602. {
  13603. var timesp = endD.Subtract(startD);
  13604. if ((timesp.Days + 1) != 0)
  13605. {
  13606. dp = x.Price / (timesp.Days + 1);
  13607. }
  13608. }
  13609. }
  13610. else
  13611. {
  13612. dp = x.Price;
  13613. }
  13614. return new
  13615. {
  13616. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  13617. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  13618. x.Area,
  13619. x.id,
  13620. price = x.Price.ToString("F2"),
  13621. x.PriceName,
  13622. x.PriceContent,
  13623. x.TeamName,
  13624. x.DatePrice,
  13625. dayPrice = dp.ToString("F2"),
  13626. };
  13627. }).OrderByDescending(x => x.id).ToList();
  13628. jw = JsonView(true, "获取成功!", view);
  13629. }
  13630. catch (Exception e)
  13631. {
  13632. jw = JsonView(false, e.Message);
  13633. }
  13634. return Ok(jw);
  13635. }
  13636. #endregion
  13637. #region 酒店预订 新 雷怡 2023-12-28 17:45
  13638. /// <summary>
  13639. /// 酒店预订
  13640. /// 酒店费用列表 根据团组Id查询
  13641. /// </summary>
  13642. /// <param name="_dto"></param>
  13643. /// <returns></returns>
  13644. [HttpPost]
  13645. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13646. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  13647. {
  13648. #region 参数验证
  13649. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13650. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13651. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13652. #region 团组操作权限验证 76 酒店预定模块
  13653. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13654. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13655. #endregion
  13656. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13657. #region 页面操作权限验证
  13658. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13659. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13660. #endregion
  13661. #endregion
  13662. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  13663. }
  13664. /// <summary>
  13665. /// 酒店预订
  13666. /// 基础数据
  13667. /// </summary>
  13668. /// <param name="_dto"></param>
  13669. /// <returns></returns>
  13670. [HttpPost]
  13671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13672. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  13673. {
  13674. #region 参数验证
  13675. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13676. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13677. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13678. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13679. #region 页面操作权限验证
  13680. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13681. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13682. #endregion
  13683. #region 团组操作权限验证 76 酒店预定模块
  13684. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13685. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13686. #endregion
  13687. #endregion
  13688. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  13689. }
  13690. /// <summary>
  13691. /// 酒店预订
  13692. /// 创建 入住卷号码
  13693. /// </summary>
  13694. /// <param name="_dto"></param>
  13695. /// <returns></returns>
  13696. [HttpPost]
  13697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13698. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  13699. {
  13700. #region 参数验证
  13701. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13702. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13703. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13704. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13705. #region 页面操作权限验证
  13706. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13707. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13708. #endregion
  13709. #region 团组操作权限验证 76 酒店预定模块
  13710. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13711. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13712. #endregion
  13713. #endregion
  13714. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  13715. if (data.Code != 0)
  13716. {
  13717. return Ok(JsonView(false, data.Msg));
  13718. }
  13719. return Ok(JsonView(true, data.Msg, data.Data));
  13720. }
  13721. /// <summary>
  13722. /// 酒店预订
  13723. /// 详情
  13724. /// </summary>
  13725. /// <param name="_dto"></param>
  13726. /// <returns></returns>
  13727. [HttpPost]
  13728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13729. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  13730. {
  13731. #region 参数验证
  13732. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  13733. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13734. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  13735. #region 团组操作权限验证 76 酒店预定模块
  13736. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13737. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13738. #endregion
  13739. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13740. #region 页面操作权限验证
  13741. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13742. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13743. #endregion
  13744. #endregion
  13745. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  13746. }
  13747. /// <summary>
  13748. /// 酒店预订
  13749. /// Add Or Edit
  13750. /// </summary>
  13751. /// <param name="_dto"></param>
  13752. /// <returns></returns>
  13753. [HttpPost]
  13754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13755. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  13756. {
  13757. #region 参数验证
  13758. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13759. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13760. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13761. #region 团组操作权限验证 76 酒店预定模块
  13762. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13763. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13764. #endregion
  13765. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13766. #region 页面操作权限验证
  13767. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13768. if (_dto.Id == 0) // Add
  13769. {
  13770. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13771. }
  13772. else if (_dto.Id > 1) // Edit
  13773. {
  13774. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  13775. }
  13776. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  13777. #endregion
  13778. #endregion
  13779. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  13780. if (_view.Code != 200)
  13781. {
  13782. return Ok(_view);
  13783. }
  13784. #region 成本无酒店价格数据进入超支
  13785. _sqlSugar.BeginTran();
  13786. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  13787. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  13788. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  13789. for (int i = 0; i < groupCost.Count; i++)
  13790. {
  13791. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  13792. {
  13793. groupCost[i].Date = groupCost[i - 1].Date;
  13794. }
  13795. }
  13796. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  13797. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  13798. List<Fin_GroupExtraCostDto_OP>();
  13799. if (start_Bool && end_Bool)
  13800. {
  13801. while (start_Time < end_Time)
  13802. {
  13803. foreach (var item in groupCost_Grp)
  13804. {
  13805. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  13806. {
  13807. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  13808. {
  13809. extraCostList.Add(new
  13810. Fin_GroupExtraCostDto_OP
  13811. {
  13812. Area = _dto.AreaId,
  13813. coefficient = 1.5M,
  13814. createUser = _dto.UserId,
  13815. currency = _dto.CardPriceCurrency,
  13816. diId = _dto.DiId,
  13817. ManagerConfirm = 0,
  13818. SupervisorConfirm = 0,
  13819. SYsupervisorConfirm = 0,
  13820. editType = 1,
  13821. PortType = 1,
  13822. price = _dto.CardPrice,
  13823. PriceCount = 1,
  13824. priceType = 1027,
  13825. priceDetailType = 1044,
  13826. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  13827. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  13828. });
  13829. }
  13830. }
  13831. }
  13832. start_Time = start_Time.AddDays(1);
  13833. }
  13834. }
  13835. if (extraCostList.Any())
  13836. {
  13837. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  13838. }
  13839. _sqlSugar.CommitTran();
  13840. #endregion
  13841. #region 应用推送
  13842. try
  13843. {
  13844. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  13845. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  13846. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  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. #region 操作记录
  13851. var opInfo = new Crm_TableOperationRecord() {
  13852. TableName = "Grp_HotelReservations",
  13853. PortType = _dto.PortType,
  13854. DataId = hotelId,
  13855. CreateUserId = _dto.UserId
  13856. };
  13857. var opStatus = OperationEnum.NoOperation;
  13858. if (_dto.Id<1) //添加操作
  13859. {
  13860. opInfo.OperationItem = OperationEnum.Add;
  13861. }
  13862. else if (_dto.Id > 0)
  13863. {
  13864. opInfo.OperationItem = OperationEnum.Edit;
  13865. }
  13866. string opRemark = string.Empty;
  13867. if (ccpInfo != null)
  13868. {
  13869. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  13870. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  13871. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  13872. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  13873. }
  13874. opInfo.Remark = opRemark;
  13875. await _tableorRep.AddAsync(opInfo);
  13876. #endregion
  13877. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  13878. //2024-10-21 新增LZ UID
  13879. var userIds = new List<int>() { 21 };
  13880. string title = $"费用审核";
  13881. string content = "";
  13882. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13883. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13884. try
  13885. {
  13886. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  13887. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  13888. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  13889. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  13890. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  13891. }
  13892. catch (Exception ex )
  13893. {
  13894. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  13895. }
  13896. }
  13897. catch (Exception ex)
  13898. {
  13899. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  13900. }
  13901. try
  13902. {
  13903. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  13904. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  13905. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  13906. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13907. //自动审核
  13908. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  13909. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  13910. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  13911. //2024-10-21 新增LZ UID
  13912. var userIds = new List<int>() { 21 };
  13913. string title = $"系统通知";
  13914. var diId = _dto.DiId;
  13915. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13916. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13917. string content = "";
  13918. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13919. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13920. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13921. }
  13922. catch (Exception ex)
  13923. {
  13924. }
  13925. #endregion
  13926. return Ok(_view);
  13927. }
  13928. /// <summary>
  13929. /// 酒店自动审核测试
  13930. /// Add Or Edit
  13931. /// </summary>
  13932. /// <param name="_dto"></param>
  13933. /// <returns></returns>
  13934. [HttpPost]
  13935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13936. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  13937. {
  13938. #region 应用推送
  13939. try
  13940. {
  13941. //自动审核
  13942. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  13943. }
  13944. catch (Exception ex)
  13945. {
  13946. return Ok(JsonView(false, "操作失败"));
  13947. }
  13948. #endregion
  13949. return Ok(JsonView(false, "操作成功"));
  13950. }
  13951. /// <summary>
  13952. /// 酒店预订
  13953. /// Del
  13954. /// </summary>
  13955. /// <param name="_dto"></param>
  13956. /// <returns></returns>
  13957. [HttpPost]
  13958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13959. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  13960. {
  13961. #region 参数验证
  13962. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13963. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13964. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13965. #region 团组操作权限验证 76 酒店预定模块
  13966. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13967. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13968. #endregion
  13969. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13970. #region 页面操作权限验证
  13971. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13972. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  13973. #endregion
  13974. #endregion
  13975. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  13976. #region 操作记录
  13977. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  13978. {
  13979. TableName = "Grp_HotelReservations",
  13980. PortType = _dto.PortType,
  13981. OperationItem = OperationEnum.Del,
  13982. DataId = _dto.Id,
  13983. CreateUserId = _dto.UserId
  13984. });
  13985. #endregion
  13986. return Ok(data);
  13987. }
  13988. /// <summary>
  13989. /// 酒店预订
  13990. /// 生成VOUCHER
  13991. /// 2024.05.06 之前版本
  13992. /// </summary>
  13993. /// <param name="_dto"></param>
  13994. /// <returns></returns>
  13995. [HttpPost]
  13996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13997. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  13998. {
  13999. try
  14000. {
  14001. #region 参数验证
  14002. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14003. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14004. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14005. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  14006. #region 团组操作权限验证 76 酒店预定模块
  14007. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14008. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14009. #endregion
  14010. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14011. #region 页面操作权限验证
  14012. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14013. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14014. #endregion
  14015. #endregion
  14016. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  14017. //判断数据是否完整
  14018. if (hr != null)
  14019. {
  14020. if (!string.IsNullOrEmpty(hr.DetermineNo))
  14021. {
  14022. string strFileName = "HotelStatement/";
  14023. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14024. if (dele != null)
  14025. strFileName += dele.TourCode;
  14026. //载入模板
  14027. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  14028. Document doc = new Document(sss);
  14029. DocumentBuilder builder = new DocumentBuilder(doc);
  14030. #region 替换Word模板书签内容
  14031. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  14032. //入住卷预定号码
  14033. if (doc.Range.Bookmarks["VNO"] != null)
  14034. {
  14035. Bookmark mark = doc.Range.Bookmarks["VNO"];
  14036. mark.Text = hr.CheckNumber;
  14037. }
  14038. //酒店时间
  14039. if (doc.Range.Bookmarks["Date"] != null)
  14040. {
  14041. Bookmark mark = doc.Range.Bookmarks["Date"];
  14042. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14043. }
  14044. //团号
  14045. if (doc.Range.Bookmarks["TNo"] != null)
  14046. {
  14047. Bookmark mark = doc.Range.Bookmarks["TNo"];
  14048. mark.Text = dele.TourCode;
  14049. }
  14050. //预定号码
  14051. if (doc.Range.Bookmarks["BookingId"] != null)
  14052. {
  14053. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  14054. mark.Text = hr.ReservationsNo;
  14055. }
  14056. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  14057. {
  14058. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  14059. mark.Text = hr.DetermineNo;
  14060. }
  14061. //酒店城市
  14062. if (doc.Range.Bookmarks["City"] != null)
  14063. {
  14064. Bookmark mark = doc.Range.Bookmarks["City"];
  14065. mark.Text = hr.City;
  14066. }
  14067. //酒店名称
  14068. if (doc.Range.Bookmarks["HName"] != null)
  14069. {
  14070. Bookmark mark = doc.Range.Bookmarks["HName"];
  14071. mark.Text = hr.HotelName;
  14072. }
  14073. //酒店地址
  14074. if (doc.Range.Bookmarks["Address"] != null)
  14075. {
  14076. Bookmark mark = doc.Range.Bookmarks["Address"];
  14077. mark.Text = hr.HotelAddress;
  14078. }
  14079. //酒店电话
  14080. if (doc.Range.Bookmarks["Tel"] != null)
  14081. {
  14082. Bookmark mark = doc.Range.Bookmarks["Tel"];
  14083. mark.Text = hr.HotelTel;
  14084. }
  14085. //酒店传真
  14086. if (doc.Range.Bookmarks["Fax"] != null)
  14087. {
  14088. Bookmark mark = doc.Range.Bookmarks["Fax"];
  14089. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  14090. {
  14091. mark.Text = hr.HotelFax;
  14092. }
  14093. }
  14094. //入住时间
  14095. if (doc.Range.Bookmarks["CIn"] != null)
  14096. {
  14097. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14098. Bookmark mark = doc.Range.Bookmarks["CIn"];
  14099. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  14100. }
  14101. //退房时间
  14102. if (doc.Range.Bookmarks["COut"] != null)
  14103. {
  14104. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14105. Bookmark mark = doc.Range.Bookmarks["COut"];
  14106. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14107. }
  14108. //客户名称
  14109. if (doc.Range.Bookmarks["GName"] != null)
  14110. {
  14111. string guestName = "";
  14112. string[] clients = new string[] { };
  14113. if (hr.GuestName.Contains(","))
  14114. {
  14115. clients = hr.GuestName.Split(",");
  14116. }
  14117. else
  14118. {
  14119. clients = new string[] { hr.GuestName };
  14120. }
  14121. List<int> clientIds_int = new List<int>();
  14122. if (clients.Length > 0)
  14123. {
  14124. foreach (var item in clients)
  14125. {
  14126. if (item.IsNumeric())
  14127. {
  14128. clientIds_int.Add(int.Parse(item));
  14129. }
  14130. }
  14131. }
  14132. if (clientIds_int.Count > 0)
  14133. {
  14134. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  14135. foreach (var client in _clientDatas)
  14136. {
  14137. //男
  14138. if (client.Sex == 0) guestName += $"Mr.";
  14139. //女
  14140. else if (client.Sex == 1) guestName += $"Ms.";
  14141. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  14142. {
  14143. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  14144. }
  14145. //guestName += $"{client.Pinyin},";
  14146. }
  14147. if (guestName.Length > 0)
  14148. {
  14149. guestName = guestName.Substring(0, guestName.Length - 1);
  14150. }
  14151. }
  14152. else
  14153. {
  14154. guestName = hr.GuestName;
  14155. }
  14156. Bookmark mark = doc.Range.Bookmarks["GName"];
  14157. mark.Text = guestName;
  14158. }
  14159. //房间介绍
  14160. if (doc.Range.Bookmarks["ROOM"] != null)
  14161. {
  14162. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  14163. mark.Text = hr.RoomExplanation;
  14164. }
  14165. //报价描述
  14166. if (doc.Range.Bookmarks["NOTE"] != null)
  14167. {
  14168. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  14169. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  14170. if (ss != null)
  14171. mark.Text = ss.Name;
  14172. }
  14173. //入住时间
  14174. if (doc.Range.Bookmarks["CheckIn"] != null)
  14175. {
  14176. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14177. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  14178. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14179. }
  14180. //退房时间
  14181. if (doc.Range.Bookmarks["CheckOut"] != null)
  14182. {
  14183. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14184. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  14185. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14186. }
  14187. //日期
  14188. if (doc.Range.Bookmarks["DT"] != null)
  14189. {
  14190. Bookmark mark = doc.Range.Bookmarks["DT"];
  14191. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14192. }
  14193. //名称
  14194. if (doc.Range.Bookmarks["VName"] != null)
  14195. {
  14196. Bookmark mark = doc.Range.Bookmarks["VName"];
  14197. mark.Text = hr.HotelName;
  14198. }
  14199. //号码
  14200. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  14201. {
  14202. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  14203. mark.Text = hr.CheckNumber;
  14204. }
  14205. #endregion
  14206. strFileName += "VOUCHER.doc";
  14207. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14208. doc.Save(fileDir);
  14209. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14210. return Ok(JsonView(true, "操作成功!", Url));
  14211. }
  14212. else
  14213. {
  14214. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  14215. }
  14216. }
  14217. else
  14218. {
  14219. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  14220. }
  14221. }
  14222. catch (Exception ex)
  14223. {
  14224. return Ok(JsonView(false, ex.Message));
  14225. }
  14226. }
  14227. /// <summary>
  14228. /// 酒店预订
  14229. /// 生成VOUCHER
  14230. /// 2024.05.06 之后版本
  14231. /// </summary>
  14232. /// <param name="_dto"></param>
  14233. /// <returns></returns>
  14234. [HttpPost]
  14235. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14236. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  14237. {
  14238. #region 参数验证
  14239. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14240. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14241. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14242. #region 团组操作权限验证 76 酒店预定模块
  14243. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14244. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14245. #endregion
  14246. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14247. #region 页面操作权限验证
  14248. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14249. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14250. #endregion
  14251. #endregion
  14252. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  14253. //判断数据是否完整
  14254. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14255. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14256. string strFileName = "HotelStatement/";
  14257. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14258. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  14259. #region 数据处理
  14260. List<int> guestIds = new List<int>();
  14261. int index = 0;
  14262. foreach (var item in hrDtas)
  14263. {
  14264. if (item.GuestName.Contains(","))
  14265. {
  14266. string[] guestIdArr = item.GuestName.Split(',');
  14267. foreach (var guestIdStr in guestIdArr)
  14268. {
  14269. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  14270. if (guestBool)
  14271. {
  14272. guestIds.Add(guestId);
  14273. }
  14274. }
  14275. }
  14276. else guestNames += item.GuestName;
  14277. var voucherInfo = new HotelVoucherInfoView()
  14278. {
  14279. HotelName = item.HotelName,
  14280. CheckInDate = item.CheckInDate,
  14281. CheckOutDate = item.CheckOutDate,
  14282. ConfirmationNumber = item.DetermineNo.Trim(),
  14283. RoomType = item.RoomExplanation
  14284. };
  14285. vouchers.Add(voucherInfo);
  14286. }
  14287. if (guestIds.Count > 0)
  14288. {
  14289. guestIds = guestIds.Distinct().ToList();
  14290. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  14291. if (guestDatas.Count > 0)
  14292. {
  14293. guestNames = "";
  14294. foreach (var guest in guestDatas)
  14295. {
  14296. string guestName = "";
  14297. if (guest.Sex == 0) guestName += @"MR.";
  14298. else if (guest.Sex == 1) guestName += @"MS.";
  14299. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14300. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14301. guestNames += @$"{guestName.Trim()}、";
  14302. }
  14303. if (guestNames.Length > 0)
  14304. {
  14305. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14306. }
  14307. }
  14308. }
  14309. #endregion
  14310. //载入模板
  14311. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  14312. Document doc = new Document(sss);
  14313. DocumentBuilder builder = new DocumentBuilder(doc);
  14314. if (doc.Range.Bookmarks["GuestName"] != null)
  14315. {
  14316. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  14317. mark.Text = guestNames;
  14318. }
  14319. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14320. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  14321. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  14322. for (int i = 1; i <= vouchers.Count; i++)
  14323. {
  14324. HotelVoucherInfoView hviv = vouchers[i - 1];
  14325. builder.MoveToCell(0, i, 0, 0);
  14326. builder.Write(hviv.HotelName);
  14327. builder.MoveToCell(0, i, 1, 0);
  14328. builder.Write(hviv.CheckInDate);
  14329. builder.MoveToCell(0, i, 2, 0);
  14330. builder.Write(hviv.CheckOutDate);
  14331. builder.MoveToCell(0, i, 3, 0);
  14332. builder.Write(hviv.RoomType);
  14333. builder.MoveToCell(0, i, 4, 0);
  14334. builder.Write(hviv.ConfirmationNumber);
  14335. }
  14336. //删除多余行
  14337. int currRowIndex = vouchers.Count + 1;
  14338. int delRows = 21 - currRowIndex;
  14339. if (delRows > 0)
  14340. {
  14341. for (int i = 0; i < delRows; i++)
  14342. {
  14343. table.Rows.RemoveAt(currRowIndex);
  14344. //cultivateRowIndex++;
  14345. }
  14346. }
  14347. strFileName += "VOUCHER.docx";
  14348. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14349. doc.Save(fileDir);
  14350. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14351. return Ok(JsonView(true, "操作成功!", Url));
  14352. }
  14353. /// <summary>
  14354. /// 酒店预订
  14355. /// 生成VOUCHER 批量生成
  14356. /// New
  14357. /// </summary>
  14358. /// <param name="_dto"></param>
  14359. /// <returns></returns>
  14360. [HttpPost]
  14361. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14362. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  14363. {
  14364. #region 参数验证
  14365. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14366. if (_dto.PageId < 1) _dto.PageId = 28;
  14367. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14368. #region 团组操作权限验证 76 酒店预定模块
  14369. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14370. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14371. #endregion
  14372. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14373. #region 页面操作权限验证
  14374. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14375. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14376. #endregion
  14377. #endregion
  14378. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  14379. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  14380. .OrderBy(x => x.CheckInDate)
  14381. .ToListAsync();
  14382. //判断数据是否完整
  14383. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14384. string strFileName = "HotelStatement/";
  14385. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14386. if (dele != null)
  14387. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  14388. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  14389. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  14390. .Where(it => it.IsDel == 0)
  14391. .ToListAsync();
  14392. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  14393. for (int i = 0; i < hrDtas.Count; i++)
  14394. {
  14395. string guestNames = string.Empty;
  14396. List<int> guestIds = new List<int>();
  14397. var item = hrDtas[i];
  14398. //处理客户姓名
  14399. if (item.GuestName.Contains(","))
  14400. {
  14401. string[] guestIdArr = item.GuestName.Split(',');
  14402. foreach (var guestIdStr in guestIdArr)
  14403. if (int.TryParse(guestIdStr, out int guestId))
  14404. guestIds.Add(guestId);
  14405. }
  14406. else
  14407. {
  14408. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  14409. if (guestIdBool)
  14410. {
  14411. guestIds.Add(guestId);
  14412. }
  14413. //NaN
  14414. if (item.GuestName.Contains("NaN"))
  14415. {
  14416. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  14417. }
  14418. }
  14419. if (guestIds.Count > 0)
  14420. {
  14421. guestIds = guestIds.Distinct().ToList();
  14422. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  14423. if (guestDatas1.Count > 0)
  14424. {
  14425. guestNames = "";
  14426. foreach (var guest in guestDatas1)
  14427. {
  14428. string guestName = "";
  14429. if (guest.Sex == 0) guestName += @"MR.";
  14430. else if (guest.Sex == 1) guestName += @"MS.";
  14431. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14432. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14433. guestNames += @$"{guestName.Trim()}、";
  14434. }
  14435. if (guestNames.Length > 0)
  14436. {
  14437. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14438. }
  14439. }
  14440. }
  14441. //if (!string.IsNullOrEmpty(guestNames))
  14442. //{
  14443. hrDtas[i].GuestName = guestNames;
  14444. //}
  14445. }
  14446. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  14447. Document doc = new Document();
  14448. DocumentBuilder builder = new DocumentBuilder(doc);
  14449. try
  14450. {
  14451. builder.MoveToDocumentStart();
  14452. foreach (var item in hrDtas)
  14453. {
  14454. //标题
  14455. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14456. builder.ParagraphFormat.LineSpacing = 1;
  14457. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14458. builder.ParagraphFormat.Style.Font.Size = 9;
  14459. builder.ParagraphFormat.Style.Font.Bold = true;
  14460. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14461. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  14462. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14463. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14464. builder.ParagraphFormat.LineSpacing = 1;
  14465. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14466. builder.ParagraphFormat.Style.Font.Size = 9;
  14467. builder.ParagraphFormat.Style.Font.Bold = true;
  14468. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  14469. builder.StartTable();
  14470. // 设置边框颜色
  14471. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  14472. //设置边框样式
  14473. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  14474. //表格
  14475. #region 第一行
  14476. builder.InsertCell();
  14477. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14478. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14479. //builder.CellFormat.AllowAutoFit = false;
  14480. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14481. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14482. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14483. builder.CellFormat.WrapText = true; //自动换行
  14484. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14485. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  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.Write("TOUR NO:");
  14491. builder.InsertCell();
  14492. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14493. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14494. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14495. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14496. builder.ParagraphFormat.Style.Font.Bold = false;
  14497. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14498. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14499. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14500. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14501. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14502. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14503. builder.Write($"{dele?.TourCode ?? "-"}");
  14504. builder.InsertCell();
  14505. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14506. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14507. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14508. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14509. builder.ParagraphFormat.Style.Font.Bold = false;
  14510. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14511. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14512. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14513. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14514. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14515. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14516. builder.Write($"CITY:");
  14517. builder.InsertCell();
  14518. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14519. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14520. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14521. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14522. builder.ParagraphFormat.Style.Font.Bold = false;
  14523. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14524. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14525. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14526. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14527. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14528. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14529. builder.Write($"{item.City}");
  14530. builder.EndRow();
  14531. #endregion
  14532. #region 第二行
  14533. builder.InsertCell();
  14534. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14535. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14536. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14537. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14538. builder.ParagraphFormat.Style.Font.Bold = false;
  14539. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14540. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14541. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14542. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14543. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14544. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14545. builder.Write("CONFIRMATION NO:");
  14546. builder.InsertCell();
  14547. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14548. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14549. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14550. builder.ParagraphFormat.Style.Font.Bold = false;
  14551. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14552. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14553. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14554. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14555. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14556. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14557. builder.CellFormat.VerticalMerge = CellMerge.None;
  14558. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14559. builder.Write($"{item.DetermineNo}");
  14560. builder.InsertCell();
  14561. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14562. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14563. builder.InsertCell();
  14564. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14565. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14566. builder.EndRow();
  14567. #endregion
  14568. #region 第三行
  14569. builder.InsertCell();
  14570. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14571. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14572. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14573. builder.ParagraphFormat.Style.Font.Bold = false;
  14574. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14575. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14576. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14577. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14578. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14579. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14580. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14581. builder.Write($"HOTEL NAME:");
  14582. builder.InsertCell();
  14583. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14584. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14585. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14586. builder.ParagraphFormat.Style.Font.Bold = false;
  14587. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14588. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14589. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14590. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14591. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14592. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14593. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14594. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14595. builder.Write($"{item.HotelName}");
  14596. builder.InsertCell();
  14597. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14598. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14599. builder.InsertCell();
  14600. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14601. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14602. builder.EndRow();
  14603. #endregion
  14604. #region 第四行
  14605. builder.InsertCell();
  14606. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14607. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14608. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14609. builder.ParagraphFormat.Style.Font.Bold = false;
  14610. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14611. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14612. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14613. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14614. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14615. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14616. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14617. builder.Write($"HOTEL ADDRESS:");
  14618. builder.InsertCell();
  14619. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14620. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14621. builder.ParagraphFormat.Style.Font.Size = 8;
  14622. builder.ParagraphFormat.Style.Font.Bold = false;
  14623. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14624. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14625. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14626. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14627. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14628. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14629. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14630. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14631. builder.Write($"{item.HotelAddress}");
  14632. builder.InsertCell();
  14633. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14634. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14635. builder.InsertCell();
  14636. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14637. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14638. builder.EndRow();
  14639. #endregion
  14640. #region 第五行
  14641. builder.InsertCell();
  14642. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14643. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14644. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14645. builder.ParagraphFormat.Style.Font.Bold = false;
  14646. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14647. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14648. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14649. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14650. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14651. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14652. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14653. builder.Write("TEL:");
  14654. builder.InsertCell();
  14655. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14656. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14657. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14658. builder.ParagraphFormat.Style.Font.Bold = false;
  14659. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14660. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14661. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14662. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14663. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14664. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14665. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14666. builder.Write($"{item.HotelTel}");
  14667. builder.InsertCell();
  14668. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14669. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14670. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14671. builder.ParagraphFormat.Style.Font.Bold = false;
  14672. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14673. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14674. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14675. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14676. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14677. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14678. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14679. builder.Write($"FAX:");
  14680. builder.InsertCell();
  14681. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14682. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14683. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14684. builder.ParagraphFormat.Style.Font.Bold = false;
  14685. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14686. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14687. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14688. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14689. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14690. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14691. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14692. builder.Write($"{item.HotelFax}");
  14693. builder.EndRow();
  14694. #endregion
  14695. #region 第六行
  14696. builder.InsertCell();
  14697. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14698. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14699. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14700. builder.ParagraphFormat.Style.Font.Bold = false;
  14701. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14702. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14703. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14704. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14705. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14706. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14707. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14708. builder.Write("CHECK IN:");
  14709. builder.InsertCell();
  14710. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14711. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14712. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14713. builder.ParagraphFormat.Style.Font.Bold = false;
  14714. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14715. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14716. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14717. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14718. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14719. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14720. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14721. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  14722. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14723. builder.Write($"{checkInStr}");
  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($"CHECK OUT:");
  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. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  14750. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  14751. builder.Write($"{checkOutStr}");
  14752. builder.EndRow();
  14753. #endregion
  14754. #region 第七行
  14755. builder.InsertCell();
  14756. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14757. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14758. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14759. builder.ParagraphFormat.Style.Font.Bold = false;
  14760. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14761. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14762. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14763. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14764. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14765. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14766. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14767. builder.Write($"GUEST NAME:");
  14768. builder.InsertCell();
  14769. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14770. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14771. builder.ParagraphFormat.Style.Font.Size = 8;
  14772. builder.ParagraphFormat.Style.Font.Bold = false;
  14773. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14774. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14775. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14776. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14777. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14778. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14779. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14780. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14781. builder.Write($"{item.GuestName}");
  14782. builder.InsertCell();
  14783. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14784. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14785. builder.InsertCell();
  14786. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14787. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14788. builder.EndRow();
  14789. #endregion
  14790. #region 第八行
  14791. builder.InsertCell();
  14792. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14793. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14794. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14795. builder.ParagraphFormat.Style.Font.Bold = false;
  14796. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14797. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14798. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14799. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14800. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14801. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14802. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14803. builder.Write($"ROOM TYPE:");
  14804. builder.InsertCell();
  14805. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14806. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14807. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14808. builder.ParagraphFormat.Style.Font.Bold = false;
  14809. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14810. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14811. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14812. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14813. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14814. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14815. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14816. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14817. builder.Write($"{item.RoomExplanation}");
  14818. builder.InsertCell();
  14819. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14820. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14821. builder.InsertCell();
  14822. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14823. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14824. builder.EndRow();
  14825. #endregion
  14826. #region 第九行
  14827. builder.InsertCell();
  14828. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14829. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14830. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14831. builder.ParagraphFormat.Style.Font.Bold = false;
  14832. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14833. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14834. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14835. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14836. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14837. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14838. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14839. builder.Write($"NOTE:");
  14840. builder.InsertCell();
  14841. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14842. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14843. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14844. builder.ParagraphFormat.Style.Font.Bold = false;
  14845. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14846. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14847. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14848. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14849. 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.");
  14850. builder.InsertCell();
  14851. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14852. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14853. builder.InsertCell();
  14854. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14855. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14856. builder.EndRow();
  14857. #endregion
  14858. builder.EndTable();
  14859. //换行
  14860. builder.Writeln("");
  14861. builder.Writeln("");
  14862. }
  14863. #region 获取文档中的所有表格 设置文字自适应
  14864. // 获取文档中的所有表格。
  14865. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14866. {
  14867. // 遍历表格中的所有行。
  14868. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14869. {
  14870. foreach (Cell cell in row.Cells)
  14871. {
  14872. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  14873. cellFormat.Width = 0;
  14874. }
  14875. }
  14876. }
  14877. #endregion
  14878. #region 设置页眉
  14879. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  14880. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  14881. if (System.IO.File.Exists(voucherHeaderPath))
  14882. {
  14883. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  14884. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  14885. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  14886. Shape shape = builder.InsertImage(imageBytes);
  14887. // 调整图片位置
  14888. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  14889. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  14890. shape.Top = 50; // 将图片距离页眉上边缘的距离
  14891. shape.Left = 0; // 将图片距离页面左边缘的距离
  14892. shape.Width = 81; // 设置图片宽度
  14893. shape.Height = 36; // 设置图片高度
  14894. }
  14895. //靠右
  14896. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  14897. //// 设置页脚上下边距
  14898. //builder.PageSetup.HeaderDistance = 42;
  14899. // 添加页眉线
  14900. Aspose.Words.Border borderHeader = null;
  14901. try
  14902. {
  14903. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  14904. }
  14905. catch (Exception e)
  14906. {
  14907. // TODO Auto-generated catch block
  14908. //e.printStackTrace();
  14909. }
  14910. borderHeader.Shadow = true;
  14911. borderHeader.DistanceFromText = 2;
  14912. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  14913. #endregion
  14914. }
  14915. catch (Exception ex)
  14916. {
  14917. }
  14918. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14919. doc.Save(fileDir);
  14920. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14921. return Ok(JsonView(true, "操作成功!", Url));
  14922. }
  14923. /// <summary>
  14924. /// 酒店预订
  14925. /// 生成 预定成本 Excel
  14926. /// </summary>
  14927. /// <param name="_dto"></param>
  14928. /// <returns></returns>
  14929. [HttpPost]
  14930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14931. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  14932. {
  14933. #region 参数验证
  14934. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  14935. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  14936. if (!vadalitorRes.IsValid)
  14937. {
  14938. var errors = new StringBuilder();
  14939. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  14940. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  14941. }
  14942. #region 团组操作权限验证 76 酒店预定模块
  14943. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14944. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14945. #endregion
  14946. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14947. #region 页面操作权限验证
  14948. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14949. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14950. #endregion
  14951. #endregion
  14952. decimal _rate = 1.00M;
  14953. string _currency = string.Empty;
  14954. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  14955. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  14956. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  14957. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  14958. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  14959. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  14960. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  14961. if (_GroupCostParameter == null)
  14962. {
  14963. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  14964. bool isIntType = int.TryParse(_currency, out int currId);
  14965. if (isIntType)
  14966. {
  14967. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  14968. }
  14969. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  14970. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  14971. if (currInfo == null)
  14972. {
  14973. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  14974. }
  14975. else _rate = currInfo.Rate;
  14976. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  14977. {
  14978. _rate = _GroupCostParameter.Rate;
  14979. }
  14980. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14981. string strFileName = "HotelStatement/";
  14982. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14983. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  14984. var rateDatas = new List<dynamic>();
  14985. #region 数据处理
  14986. foreach (var item in hrDtas)
  14987. {
  14988. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  14989. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  14990. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  14991. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  14992. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  14993. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  14994. {
  14995. continue;
  14996. }
  14997. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  14998. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  14999. string singleRoomFeeStr = string.Empty,
  15000. doubleRoomFeeStr = string.Empty,
  15001. suiteRoomFeeStr = string.Empty,
  15002. otherRoomFeeStr = string.Empty,
  15003. payMoneyStr = string.Empty,
  15004. cardPriceStr = string.Empty;
  15005. if (roomCurr.Equals("CNY"))
  15006. {
  15007. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  15008. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15009. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15010. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15011. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15012. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  15013. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  15014. }
  15015. else
  15016. {
  15017. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15018. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15019. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15020. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15021. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15022. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15023. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15024. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15025. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15026. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15027. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  15028. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  15029. if (ccpPaymentCurrency.Equals("CNY"))
  15030. {
  15031. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  15032. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15033. }
  15034. else
  15035. {
  15036. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  15037. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  15038. }
  15039. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  15040. if (hotelcardPriceCurrency.Equals("CNY"))
  15041. {
  15042. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15043. }
  15044. else
  15045. {
  15046. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  15047. }
  15048. }
  15049. string breakfastPriceStr = string.Empty,
  15050. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15051. governmentRentStr = string.Empty,
  15052. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15053. cityTaxStr = string.Empty,
  15054. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15055. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  15056. if (!string.IsNullOrEmpty(breakfastCurrency1))
  15057. {
  15058. if (breakfastCurrency1.Equals("CNY"))
  15059. {
  15060. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15061. }
  15062. else
  15063. {
  15064. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  15065. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  15066. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  15067. }
  15068. }
  15069. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15070. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  15071. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  15072. {
  15073. if (governmentRentCurrency.Equals("CNY"))
  15074. {
  15075. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15076. }
  15077. else
  15078. {
  15079. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  15080. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  15081. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  15082. }
  15083. }
  15084. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15085. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  15086. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  15087. {
  15088. if (cityTaxStrCurrency1.Equals("CNY"))
  15089. {
  15090. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15091. }
  15092. else
  15093. {
  15094. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  15095. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  15096. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  15097. }
  15098. }
  15099. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15100. int payDId = roomInfo?.PayDId ?? 0;
  15101. pcfds.Add(new HotelReservations_PCFD_View()
  15102. {
  15103. City = item.City,
  15104. HotelName = item.HotelName,
  15105. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15106. // SingleRoomCount = item.SingleRoomCount,
  15107. SingleRoomPrice = singleRoomFeeStr,
  15108. // DoubleRoomCount = item.DoubleRoomCount,
  15109. DoubleRoomPrice = doubleRoomFeeStr,
  15110. //SuiteRoomCount = item.SuiteRoomCount,
  15111. SuiteRoomPrice = suiteRoomFeeStr,
  15112. OtherRoomPrice = otherRoomFeeStr,
  15113. //OtherRoomCount = item.OtherRoomCount,
  15114. BreakfastPrice = breakfastPriceStr,
  15115. GovernmentRent = governmentRentStr,
  15116. CityTax = cityTaxStr,
  15117. RoomExplanation = item.RoomExplanation,
  15118. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15119. PayTime = roomInfo?.ConsumptionDate,
  15120. BankNo = roomInfo?.BankNo,
  15121. PayMoney = payMoneyStr,
  15122. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15123. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15124. CardPrice = cardPriceStr,
  15125. Remark = ccpInfo.Remark
  15126. });
  15127. }
  15128. #endregion
  15129. //载入模板
  15130. WorkbookDesigner designer = new WorkbookDesigner();
  15131. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15132. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15133. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15134. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15135. var rateDatas1 = rateDatas.Distinct();
  15136. var rateStr = string.Empty;
  15137. foreach (var item in rateDatas1)
  15138. {
  15139. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  15140. }
  15141. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  15142. designer.SetDataSource("Opertor", userInfo.CnName);
  15143. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15144. dt.TableName = "ViewMyHotelReservations";
  15145. designer.SetDataSource(dt);
  15146. designer.Process();
  15147. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15148. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15149. designer.Workbook.Save(serverPath);
  15150. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15151. #region 删除指定行
  15152. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15153. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15154. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15155. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15156. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15157. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15158. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15159. cssIndex = dt.Columns["CityTax"].Ordinal,
  15160. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15161. remarkIndex = dt.Columns["Remark"].Ordinal;
  15162. //删除指定列
  15163. foreach (DataRow item in dt.Rows)
  15164. {
  15165. string singleStr = item["SingleRoomPrice"].ToString();
  15166. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15167. if (containsDigitButNotZero1) singleDel = false;
  15168. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15169. string doubleStr = item["DoubleRoomPrice"].ToString();
  15170. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15171. if (containsDigitButNotZero2) doubleDel = false;
  15172. string suiteStr = item["SuiteRoomPrice"].ToString();
  15173. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15174. if (containsDigitButNotZero3) suiteDel = false;
  15175. string otherStr = item["OtherRoomPrice"].ToString();
  15176. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15177. if (containsDigitButNotZero4) otherDel = false;
  15178. string zcStr = item["BreakfastPrice"].ToString();
  15179. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15180. if (containsDigitButNotZero5) zcDel = false;
  15181. string dsStr = item["GovernmentRent"].ToString();
  15182. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15183. if (containsDigitButNotZero6) dsDel = false;
  15184. string cssStr = item["CityTax"].ToString();
  15185. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15186. if (containsDigitButNotZero7) cssDel = false;
  15187. string cpStr = item["ConsumptionPatterns"].ToString();
  15188. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15189. string remarkStr = item["Remark"].ToString();
  15190. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15191. }
  15192. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15193. DeleteColumn(serverPath, cpIndex, cpDel);
  15194. DeleteColumn(serverPath, dsIndex, dsDel);
  15195. DeleteColumn(serverPath, cssIndex, cssDel);
  15196. DeleteColumn(serverPath, zcIndex, zcDel);
  15197. DeleteColumn(serverPath, otherIndex, otherDel);
  15198. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15199. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15200. DeleteColumn(serverPath, singleIndex, singleDel);
  15201. #endregion
  15202. //只保留第一个表格
  15203. DeleteSheet(serverPath);
  15204. return Ok(JsonView(true, "操作成功", url = rst));
  15205. }
  15206. else
  15207. {
  15208. _currency = _GroupCostParameter.Currency;
  15209. bool isIntType = int.TryParse(_currency, out int currId);
  15210. if (isIntType)
  15211. {
  15212. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15213. }
  15214. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15215. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15216. if (currInfo == null)
  15217. {
  15218. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15219. }
  15220. if (!_currency.ToUpper().Equals("CNY"))
  15221. {
  15222. _rate = _GroupCostParameter.Rate;
  15223. }
  15224. _rate = currInfo.Rate;
  15225. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15226. //string strFileName = "HotelStatement/";
  15227. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15228. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15229. #region 数据处理
  15230. foreach (var item in hrDtas)
  15231. {
  15232. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15233. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15234. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15235. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15236. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15237. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15238. string singleRoomFeeStr = string.Empty,
  15239. doubleRoomFeeStr = string.Empty,
  15240. suiteRoomFeeStr = string.Empty,
  15241. otherRoomFeeStr = string.Empty,
  15242. payMoneyStr = string.Empty,
  15243. cardPriceStr = string.Empty;
  15244. if (roomCurr.Equals(_currency))
  15245. {
  15246. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  15247. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  15248. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  15249. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  15250. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  15251. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  15252. }
  15253. else
  15254. {
  15255. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15256. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15257. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15258. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15259. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15260. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15261. }
  15262. string breakfastPriceStr = string.Empty,
  15263. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15264. governmentRentStr = string.Empty,
  15265. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15266. cityTaxStrStr = string.Empty,
  15267. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15268. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  15269. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  15270. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  15271. int payDId = roomInfo?.PayDId ?? 0;
  15272. pcfds.Add(new HotelReservations_PCFD_View()
  15273. {
  15274. City = item.City,
  15275. HotelName = item.HotelName,
  15276. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15277. // SingleRoomCount = item.SingleRoomCount,
  15278. SingleRoomPrice = singleRoomFeeStr,
  15279. // DoubleRoomCount = item.DoubleRoomCount,
  15280. DoubleRoomPrice = doubleRoomFeeStr,
  15281. //SuiteRoomCount = item.SuiteRoomCount,
  15282. SuiteRoomPrice = suiteRoomFeeStr,
  15283. OtherRoomPrice = otherRoomFeeStr,
  15284. //OtherRoomCount = item.OtherRoomCount,
  15285. BreakfastPrice = breakfastPriceStr,
  15286. GovernmentRent = governmentRentStr,
  15287. CityTax = cityTaxStrStr,
  15288. RoomExplanation = item.RoomExplanation,
  15289. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15290. PayTime = roomInfo?.ConsumptionDate,
  15291. BankNo = roomInfo?.BankNo,
  15292. PayMoney = payMoneyStr,
  15293. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15294. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15295. CardPrice = cardPriceStr,
  15296. Remark = ccpInfo.Remark
  15297. });
  15298. }
  15299. #endregion
  15300. //载入模板
  15301. WorkbookDesigner designer = new WorkbookDesigner();
  15302. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15303. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15304. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15305. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15306. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  15307. designer.SetDataSource("Opertor", userInfo.CnName);
  15308. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15309. dt.TableName = "ViewMyHotelReservations";
  15310. designer.SetDataSource(dt);
  15311. designer.Process();
  15312. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15313. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15314. designer.Workbook.Save(serverPath);
  15315. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15316. #region 删除指定行
  15317. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15318. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15319. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15320. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15321. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15322. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15323. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15324. cssIndex = dt.Columns["CityTax"].Ordinal,
  15325. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15326. remarkIndex = dt.Columns["Remark"].Ordinal;
  15327. //删除指定列
  15328. foreach (DataRow item in dt.Rows)
  15329. {
  15330. string singleStr = item["SingleRoomPrice"].ToString();
  15331. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15332. if (containsDigitButNotZero1) singleDel = false;
  15333. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15334. string doubleStr = item["DoubleRoomPrice"].ToString();
  15335. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15336. if (containsDigitButNotZero2) doubleDel = false;
  15337. string suiteStr = item["SuiteRoomPrice"].ToString();
  15338. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15339. if (containsDigitButNotZero3) suiteDel = false;
  15340. string otherStr = item["OtherRoomPrice"].ToString();
  15341. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15342. if (containsDigitButNotZero4) otherDel = false;
  15343. string zcStr = item["BreakfastPrice"].ToString();
  15344. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15345. if (containsDigitButNotZero5) zcDel = false;
  15346. string dsStr = item["GovernmentRent"].ToString();
  15347. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15348. if (containsDigitButNotZero6) dsDel = false;
  15349. string cssStr = item["CityTax"].ToString();
  15350. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15351. if (containsDigitButNotZero7) cssDel = false;
  15352. string cpStr = item["ConsumptionPatterns"].ToString();
  15353. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15354. string remarkStr = item["Remark"].ToString();
  15355. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15356. }
  15357. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15358. DeleteColumn(serverPath, cpIndex, cpDel);
  15359. DeleteColumn(serverPath, dsIndex, dsDel);
  15360. DeleteColumn(serverPath, cssIndex, cssDel);
  15361. DeleteColumn(serverPath, zcIndex, zcDel);
  15362. DeleteColumn(serverPath, otherIndex, otherDel);
  15363. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15364. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15365. DeleteColumn(serverPath, singleIndex, singleDel);
  15366. #endregion
  15367. //只保留第一个表格
  15368. DeleteSheet(serverPath);
  15369. return Ok(JsonView(true, "操作成功", url = rst));
  15370. }
  15371. return Ok(JsonView(false));
  15372. }
  15373. /// <summary>
  15374. /// 删除指定列
  15375. /// </summary>
  15376. /// <param name="file"></param>
  15377. /// <param name="columnIndex"></param>
  15378. /// <param name="isDel"></param>
  15379. private void DeleteColumn(string file, int columnIndex, bool isDel)
  15380. {
  15381. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15382. //wb.Save(file);
  15383. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  15384. if (sheet1 != null)
  15385. {
  15386. if (isDel)
  15387. {
  15388. Cells cells = sheet1.Cells;
  15389. cells.DeleteColumn(columnIndex);
  15390. }
  15391. }
  15392. wb.Save(file);
  15393. }
  15394. /// <summary>
  15395. /// 删除sheet
  15396. /// </summary>
  15397. /// <param name="file"></param>
  15398. /// <param name="sheetName"></param>
  15399. private void DeleteSheet(string file, string sheetName = "")
  15400. {
  15401. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15402. //wb.Save(file);
  15403. List<string> sheets = new List<string>();
  15404. foreach (var item in wb.Worksheets)
  15405. {
  15406. sheets.Add(item.Name);
  15407. }
  15408. if (sheets.Count > 0)
  15409. {
  15410. sheets.RemoveAt(0);//不删除第一个sheet
  15411. foreach (var item in sheets)
  15412. {
  15413. wb.Worksheets.RemoveAt(item);
  15414. }
  15415. }
  15416. wb.Save(file);
  15417. }
  15418. /// <summary>
  15419. /// 酒店预订
  15420. /// 确认单
  15421. /// </summary>
  15422. /// <param name="_dto"></param>
  15423. /// <returns></returns>
  15424. [HttpPost]
  15425. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15426. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  15427. {
  15428. try
  15429. {
  15430. #region 参数验证
  15431. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15432. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15433. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15434. #region 团组操作权限验证 76 酒店预定模块
  15435. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15436. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15437. #endregion
  15438. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15439. #region 页面操作权限验证
  15440. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15441. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15442. #endregion
  15443. #endregion
  15444. //团组信息
  15445. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  15446. //酒店数据
  15447. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  15448. if (listhoteldata.Count < 0)
  15449. {
  15450. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  15451. }
  15452. //利datatable存储
  15453. DataTable dt = new DataTable();
  15454. dt.Columns.Add("CheckInDate", typeof(string));
  15455. dt.Columns.Add("City", typeof(string));
  15456. dt.Columns.Add("Hotel", typeof(string));
  15457. dt.Columns.Add("Room", typeof(string));
  15458. for (int i = 0; i < listhoteldata.Count; i++)
  15459. {
  15460. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  15461. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  15462. while (dayStart < dayEnd)
  15463. {
  15464. string temp = "";
  15465. DataRow row = dt.NewRow();
  15466. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  15467. row["City"] = listhoteldata[i].City;
  15468. row["Hotel"] = listhoteldata[i].HotelName;
  15469. if (listhoteldata[i].SingleRoomCount > 0)
  15470. {
  15471. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  15472. }
  15473. if (listhoteldata[i].DoubleRoomCount > 0)
  15474. {
  15475. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  15476. }
  15477. if (listhoteldata[i].SuiteRoomCount > 0)
  15478. {
  15479. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  15480. }
  15481. if (listhoteldata[i].OtherRoomCount > 0)
  15482. {
  15483. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  15484. }
  15485. row["Room"] = temp;
  15486. dt.Rows.Add(row);
  15487. dayStart = dayStart.AddDays(1);
  15488. }
  15489. }
  15490. Dictionary<string, string> dic = new Dictionary<string, string>();
  15491. dic.Add("Dele", di.TeamName);
  15492. dic.Add("City", di.VisitCountry);
  15493. //模板路径
  15494. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  15495. //载入模板
  15496. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  15497. DocumentBuilder builder = new DocumentBuilder(doc);
  15498. foreach (var key in dic.Keys)
  15499. {
  15500. builder.MoveToBookmark(key);
  15501. builder.Write(dic[key]);
  15502. }
  15503. //获取word里所有表格
  15504. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15505. //获取所填表格的序数
  15506. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  15507. var rowStart = tableOne.Rows[0]; //获取第1行
  15508. //循环赋值
  15509. for (int i = 0; i < dt.Rows.Count; i++)
  15510. {
  15511. builder.MoveToCell(0, i + 1, 0, 0);
  15512. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  15513. builder.MoveToCell(0, i + 1, 1, 0);
  15514. builder.Write(dt.Rows[i]["City"].ToString());
  15515. builder.MoveToCell(0, i + 1, 2, 0);
  15516. builder.Write(dt.Rows[i]["Hotel"].ToString());
  15517. builder.MoveToCell(0, i + 1, 3, 0);
  15518. builder.Write(dt.Rows[i]["Room"].ToString());
  15519. }
  15520. //删除多余行
  15521. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  15522. {
  15523. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  15524. }
  15525. string strFileName = di.TeamName + "酒店确认单.doc";
  15526. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  15527. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  15528. return Ok(JsonView(true, "成功", url));
  15529. }
  15530. catch (Exception ex)
  15531. {
  15532. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  15533. }
  15534. }
  15535. #endregion
  15536. #region 团组状态
  15537. /// <summary>
  15538. /// 团组状态列表 Page
  15539. /// </summary>
  15540. /// <param name="dto">团组列表请求dto</param>
  15541. /// <returns></returns>
  15542. [HttpPost]
  15543. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15544. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  15545. {
  15546. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15547. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  15548. {
  15549. string sqlWhere = string.Empty;
  15550. if (dto.IsSure == 0) //未完成
  15551. {
  15552. sqlWhere += string.Format(@" And IsSure = 0");
  15553. }
  15554. else if (dto.IsSure == 1) //已完成
  15555. {
  15556. sqlWhere += string.Format(@" And IsSure = 1");
  15557. }
  15558. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  15559. {
  15560. string tj = dto.SearchCriteria;
  15561. 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}%')",
  15562. tj, tj, tj, tj, tj);
  15563. }
  15564. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  15565. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  15566. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  15567. From (
  15568. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  15569. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  15570. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  15571. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  15572. From Grp_DelegationInfo gdi
  15573. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  15574. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  15575. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  15576. Where gdi.IsDel = 0 {0}
  15577. ) temp ", sqlWhere);
  15578. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  15579. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  15580. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  15581. }
  15582. else
  15583. {
  15584. return Ok(JsonView(false, "查询失败"));
  15585. }
  15586. }
  15587. /// <summary>
  15588. /// 团组状态
  15589. /// 设置操作完成
  15590. /// </summary>
  15591. /// <param name="dto">团组列表请求dto</param>
  15592. /// <returns></returns>
  15593. [HttpPost]
  15594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15595. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  15596. {
  15597. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15598. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  15599. {
  15600. Id = dto.Id,
  15601. IsSure = 1
  15602. };
  15603. var result = await _sqlSugar.Updateable(_DelegationInfo)
  15604. .UpdateColumns(it => new { it.IsSure })
  15605. .WhereColumns(it => new { it.Id })
  15606. .ExecuteCommandAsync();
  15607. if (result > 0)
  15608. {
  15609. return Ok(JsonView(true, "操作完成!"));
  15610. }
  15611. return Ok(JsonView(false, "操作失败!"));
  15612. }
  15613. #endregion
  15614. #region 保险费用录入
  15615. /// <summary>
  15616. /// 根据团组Id查询保险费用列表
  15617. /// </summary>
  15618. /// <param name="dto"></param>
  15619. /// <returns></returns>
  15620. [HttpPost]
  15621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15622. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  15623. {
  15624. Result groupData = await _customersRep.CustomersByDiId(dto);
  15625. if (groupData.Code != 0)
  15626. {
  15627. return Ok(JsonView(false, groupData.Msg));
  15628. }
  15629. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15630. }
  15631. /// <summary>
  15632. /// 根据保险费用Id查询保险费用详细
  15633. /// </summary>
  15634. /// <param name="dto"></param>
  15635. /// <returns></returns>
  15636. [HttpPost]
  15637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15638. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  15639. {
  15640. try
  15641. {
  15642. Result groupData = await _customersRep.CustomersById(dto);
  15643. if (groupData.Code != 0)
  15644. {
  15645. return Ok(JsonView(false, groupData.Msg));
  15646. }
  15647. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15648. }
  15649. catch (Exception ex)
  15650. {
  15651. return Ok(JsonView(false, ex.Message));
  15652. }
  15653. }
  15654. /// <summary>
  15655. /// 保险费用录入页面初始化绑定
  15656. /// </summary>
  15657. /// <param name="dto"></param>
  15658. /// <returns></returns>
  15659. [HttpPost]
  15660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15661. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  15662. {
  15663. try
  15664. {
  15665. Result groupData = await _customersRep.CustomersInitialize(dto);
  15666. if (groupData.Code != 0)
  15667. {
  15668. return Ok(JsonView(false, groupData.Msg));
  15669. }
  15670. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15671. }
  15672. catch (Exception ex)
  15673. {
  15674. return Ok(JsonView(false, ex.Message));
  15675. }
  15676. }
  15677. /// <summary>
  15678. /// 保险费用操作(Status:1.新增,2.修改)
  15679. /// </summary>
  15680. /// <param name="dto"></param>
  15681. /// <returns></returns>
  15682. [HttpPost]
  15683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15684. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  15685. {
  15686. Result groupData = await _customersRep.OpCustomers(dto);
  15687. if (groupData.Code != 0)
  15688. {
  15689. return Ok(JsonView(false, groupData.Msg));
  15690. }
  15691. #region 应用推送
  15692. try
  15693. {
  15694. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  15695. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  15696. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  15697. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  15698. //自动审核
  15699. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  15700. //2024-10-21 新增LZ UID
  15701. var userIds = new List<int>() { 21 };
  15702. string title = $"系统通知";
  15703. var diId = dto.DiId;
  15704. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15705. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15706. string content = "";
  15707. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15708. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15709. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  15710. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  15711. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  15712. }
  15713. catch (Exception ex)
  15714. {
  15715. }
  15716. #endregion
  15717. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15718. }
  15719. /// <summary>
  15720. /// 保险文件上传
  15721. /// </summary>
  15722. /// <param name="file"></param>
  15723. /// <returns></returns>
  15724. [HttpPost]
  15725. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15726. public async Task<IActionResult> UploadCus(IFormFile file)
  15727. {
  15728. try
  15729. {
  15730. if (file != null)
  15731. {
  15732. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15733. //文件名称
  15734. string projectFileName = file.FileName;
  15735. //上传的文件的路径
  15736. string filePath = "";
  15737. if (!Directory.Exists(fileDir))
  15738. {
  15739. Directory.CreateDirectory(fileDir);
  15740. }
  15741. //上传的文件的路径
  15742. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  15743. using (FileStream fs = System.IO.File.Create(filePath))
  15744. {
  15745. file.CopyTo(fs);
  15746. fs.Flush();
  15747. }
  15748. return Ok(JsonView(true, "上传成功!", projectFileName));
  15749. }
  15750. else
  15751. {
  15752. return Ok(JsonView(false, "上传失败!"));
  15753. }
  15754. }
  15755. catch (Exception ex)
  15756. {
  15757. return Ok(JsonView(false, "程序错误!"));
  15758. throw;
  15759. }
  15760. }
  15761. /// <summary>
  15762. /// 保险删除指定文件
  15763. /// </summary>
  15764. /// <param name="dto"></param>
  15765. /// <returns></returns>
  15766. [HttpPost]
  15767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15768. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  15769. {
  15770. try
  15771. {
  15772. string filePath = "";
  15773. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15774. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  15775. //int id = 0;
  15776. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  15777. // 删除该文件
  15778. try
  15779. {
  15780. System.IO.File.Delete(filePath);
  15781. 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()
  15782. {
  15783. Attachment = "",
  15784. }).ExecuteCommandAsync();
  15785. if (result != 0)
  15786. {
  15787. return Ok(JsonView(true, "成功!"));
  15788. }
  15789. else
  15790. {
  15791. return Ok(JsonView(false, "失败!"));
  15792. }
  15793. }
  15794. catch (Exception)
  15795. {
  15796. 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()
  15797. {
  15798. Attachment = "",
  15799. }).ExecuteCommandAsync();
  15800. if (result != 0)
  15801. {
  15802. return Ok(JsonView(true, "成功!"));
  15803. }
  15804. else
  15805. {
  15806. return Ok(JsonView(false, "失败!"));
  15807. }
  15808. }
  15809. }
  15810. catch (Exception ex)
  15811. {
  15812. return Ok(JsonView(false, "程序错误!"));
  15813. throw;
  15814. }
  15815. }
  15816. /// <summary>
  15817. /// 保险费用操作(删除)
  15818. /// </summary>
  15819. /// <param name="dto"></param>
  15820. /// <returns></returns>
  15821. [HttpPost]
  15822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15823. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  15824. {
  15825. try
  15826. {
  15827. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  15828. if (!res)
  15829. {
  15830. return Ok(JsonView(false, "删除失败"));
  15831. }
  15832. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  15833. {
  15834. IsDel = 1,
  15835. DeleteUserId = dto.DeleteUserId,
  15836. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  15837. }).ExecuteCommandAsync();
  15838. return Ok(JsonView(true, "删除成功!"));
  15839. }
  15840. catch (Exception ex)
  15841. {
  15842. return Ok(JsonView(false, "程序错误!"));
  15843. throw;
  15844. }
  15845. }
  15846. #endregion
  15847. #region 接团客户名单 PageId 104
  15848. /// <summary>
  15849. /// 接团客户名单
  15850. /// 迁移数据(慎用!)
  15851. /// </summary>
  15852. /// <param name="dto"></param>
  15853. /// <returns></returns>
  15854. [HttpPost]
  15855. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15856. public async Task<IActionResult> PostTourClientListChange()
  15857. {
  15858. try
  15859. {
  15860. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  15861. //var groupClinetData1
  15862. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  15863. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  15864. int updateCount = 0;
  15865. if (oldOAClientList.Count > 0)
  15866. {
  15867. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  15868. _sqlSugar.BeginTran();
  15869. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  15870. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  15871. foreach (var item in oldOAClientList)
  15872. {
  15873. int comId = 0;
  15874. string format = "yyyy-MM-dd HH:mm:ss";
  15875. string data11 = "1990-01-01 00:00";
  15876. var data1 = IsValidDate(item.OPdate, format);
  15877. if (data1) data11 = item.OPdate;
  15878. //客户公司验证
  15879. if (!string.IsNullOrEmpty(item.Company))
  15880. {
  15881. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  15882. if (clientComInfo == null) // add
  15883. {
  15884. var addInfo = new Crm_CustomerCompany()
  15885. {
  15886. CompanyAbbreviation = "",
  15887. CompanyFullName = item.Company,
  15888. Address = "",
  15889. PostCodes = "",
  15890. LastedOpUserId = item.OPer,
  15891. LastedOpDt = Convert.ToDateTime(data11),
  15892. CreateUserId = item.OPer,
  15893. CreateTime = Convert.ToDateTime(data11),
  15894. IsDel = 0
  15895. };
  15896. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  15897. if (comId1 > 0) comId = comId1;
  15898. }
  15899. else comId = clientComInfo.Id;
  15900. }
  15901. //客户人员验证
  15902. int clientId = 0;
  15903. string name = item.LastName + item.Name;
  15904. if (!string.IsNullOrEmpty(name))
  15905. {
  15906. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  15907. if (clientInfo == null)
  15908. {
  15909. DateTime? dateTime = null;
  15910. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  15911. if (isDt) dateTime = birthDayDt;
  15912. var addInfo1 = new Crm_DeleClient()
  15913. {
  15914. CrmCompanyId = comId,
  15915. DiId = -1,
  15916. LastName = item.LastName,
  15917. FirstName = item.Name,
  15918. OldName = "",
  15919. Pinyin = item.Pinyin,
  15920. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  15921. Marriage = 0,
  15922. Phone = item.Phone,
  15923. Job = item.Job,
  15924. BirthDay = dateTime
  15925. };
  15926. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  15927. if (clientId1 > 0) clientId = clientId1;
  15928. }
  15929. else clientId = clientInfo.Id;
  15930. }
  15931. if (clientId < 1)
  15932. {
  15933. continue;
  15934. }
  15935. int airType = 0;
  15936. if (item.AirType == "超经舱") airType = 459;
  15937. else if (item.AirType == "公务舱") airType = 458;
  15938. else if (item.AirType == "经济舱") airType = 460;
  15939. else if (item.AirType == "其他") airType = 565;
  15940. else if (item.AirType == "头等舱") airType = 457;
  15941. var _TourClientListEntity = new Grp_TourClientList()
  15942. {
  15943. DiId = item.Diid,
  15944. ClientId = clientId,
  15945. CreateUserId = item.OPer,
  15946. CreateTime = Convert.ToDateTime(data11),
  15947. Remark = item.Remark,
  15948. IsDel = item.Isdel,
  15949. ShippingSpaceTypeId = airType,
  15950. ShippingSpaceSpecialNeeds = item.AirRemark,
  15951. HotelSpecialNeeds = item.RoomType
  15952. };
  15953. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  15954. if (_TourClientList > 0)
  15955. {
  15956. updateCount++;
  15957. }
  15958. }
  15959. _sqlSugar.CommitTran();
  15960. }
  15961. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  15962. }
  15963. catch (Exception ex)
  15964. {
  15965. _sqlSugar.RollbackTran();
  15966. return Ok(JsonView(false, ex.Message));
  15967. }
  15968. return Ok(JsonView(true));
  15969. }
  15970. private bool IsValidDate(string dateString, string format)
  15971. {
  15972. DateTime dateValue;
  15973. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  15974. return valid;
  15975. }
  15976. /// <summary>
  15977. /// 接团客户名单
  15978. /// 根据团组Id查询List
  15979. /// </summary>
  15980. /// <param name="dto"></param>
  15981. /// <returns></returns>
  15982. [HttpPost]
  15983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15984. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  15985. {
  15986. #region 参数验证
  15987. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  15988. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  15989. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  15990. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15991. #region 页面操作权限验证
  15992. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15993. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15994. #endregion
  15995. #endregion
  15996. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  15997. if (viewData.Code != 0)
  15998. {
  15999. return Ok(JsonView(false, viewData.Msg));
  16000. }
  16001. return Ok(JsonView(viewData.Data));
  16002. }
  16003. /// <summary>
  16004. /// 接团客户名单
  16005. /// 基础数据 Init
  16006. /// </summary>
  16007. /// <param name="_dto"></param>
  16008. /// <returns></returns>
  16009. [HttpPost]
  16010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16011. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  16012. {
  16013. #region 参数验证
  16014. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16015. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16016. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16017. #region 页面操作权限验证
  16018. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16019. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16020. #endregion
  16021. #endregion
  16022. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  16023. }
  16024. /// <summary>
  16025. /// 接团客户名单
  16026. /// 根据 Id查询 Details
  16027. /// </summary>
  16028. /// <param name="_dto"></param>
  16029. /// <returns></returns>
  16030. [HttpPost]
  16031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16032. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  16033. {
  16034. #region 参数验证
  16035. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16036. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16037. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16038. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16039. #region 页面操作权限验证
  16040. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16041. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16042. #endregion
  16043. #endregion
  16044. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  16045. if (viewData.Code != 0)
  16046. {
  16047. return Ok(JsonView(false, viewData.Msg));
  16048. }
  16049. return Ok(JsonView(viewData.Data));
  16050. }
  16051. /// <summary>
  16052. /// 接团客户名单
  16053. /// Add Or Edit
  16054. /// </summary>
  16055. /// <param name="_dto"></param>
  16056. /// <returns></returns>
  16057. [HttpPost]
  16058. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16059. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  16060. {
  16061. #region 参数验证
  16062. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16063. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16064. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16065. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16066. #region 页面操作权限验证
  16067. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16068. if (_dto.Id == 0) //添加
  16069. {
  16070. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16071. }
  16072. else if (_dto.Id >= 0) //修改
  16073. {
  16074. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16075. }
  16076. #endregion
  16077. #endregion
  16078. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  16079. if (viewData.Code != 0)
  16080. {
  16081. return Ok(JsonView(false, viewData.Msg));
  16082. }
  16083. return Ok(JsonView(true));
  16084. }
  16085. /// <summary>
  16086. /// 接团客户名单
  16087. /// json字符串 AddMultiple(添加多个)
  16088. /// </summary>
  16089. /// <param name="_dto"></param>
  16090. /// <returns></returns>
  16091. [HttpPost]
  16092. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16093. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  16094. {
  16095. #region 参数验证
  16096. string jsonLabel = _dto.JsonLabel;
  16097. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16098. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16099. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16100. #region 页面操作权限验证
  16101. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16102. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16103. #endregion
  16104. #endregion
  16105. var request = new TourClientListAddMultipleDto();
  16106. request.DiId = _dto.DiId;
  16107. request.UserId = _dto.UserId;
  16108. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  16109. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  16110. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  16111. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  16112. var infos = new List<TourClientListInfo>();
  16113. foreach (var data in datas)
  16114. {
  16115. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  16116. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  16117. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  16118. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  16119. {
  16120. continue;
  16121. }
  16122. infos.Add(new TourClientListInfo() {
  16123. IsAccompany = 1,
  16124. LastName = lastName,
  16125. FirstName = firstName,
  16126. Pinyin = lastNameEn + @"/" + firstNameEn,
  16127. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女")? 1:2,
  16128. CompanyFullName = data.CompanyFullName,
  16129. Job = data.Job
  16130. });
  16131. }
  16132. if (infos.Any())
  16133. {
  16134. var viewData = await _tourClientListRep._AddMultiple(request);
  16135. if (viewData.Code != 0)
  16136. {
  16137. return Ok(JsonView(false, viewData.Msg));
  16138. }
  16139. return Ok(JsonView(true));
  16140. }
  16141. return Ok(JsonView(false));
  16142. }
  16143. /// <summary>
  16144. /// 接团客户名单
  16145. /// AddMultiple(添加多个)
  16146. /// </summary>
  16147. /// <param name="_dto"></param>
  16148. /// <returns></returns>
  16149. [HttpPost]
  16150. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16151. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  16152. {
  16153. #region 参数验证
  16154. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16155. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16156. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16157. #region 页面操作权限验证
  16158. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16159. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16160. #endregion
  16161. #endregion
  16162. var viewData = await _tourClientListRep._AddMultiple(_dto);
  16163. if (viewData.Code != 0)
  16164. {
  16165. return Ok(JsonView(false, viewData.Msg));
  16166. }
  16167. return Ok(JsonView(true));
  16168. }
  16169. /// <summary>
  16170. /// 接团客户名单
  16171. /// Del
  16172. /// </summary>
  16173. /// <param name="_dto"></param>
  16174. /// <returns></returns>
  16175. [HttpPost]
  16176. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16177. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  16178. {
  16179. #region 参数验证
  16180. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16181. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16182. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16183. #region 页面操作权限验证
  16184. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16185. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16186. #endregion
  16187. #endregion
  16188. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  16189. if (viewData.Code != 0)
  16190. {
  16191. return Ok(JsonView(false, viewData.Msg));
  16192. }
  16193. return Ok(JsonView(true));
  16194. }
  16195. /// <summary>
  16196. /// 接团客户名单
  16197. /// 文件下载 客户名单
  16198. /// </summary>
  16199. /// <param name="_dto"></param>
  16200. /// <returns></returns>
  16201. [HttpPost]
  16202. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16203. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  16204. {
  16205. #region 参数验证
  16206. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16207. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16208. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  16209. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16210. #region 页面操作权限验证
  16211. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16212. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16213. #endregion
  16214. #endregion
  16215. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  16216. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  16217. From Grp_TourClientList tcl
  16218. Left Join
  16219. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  16220. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  16221. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  16222. From Crm_DeleClient dc
  16223. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  16224. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  16225. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  16226. Where dc.IsDel = 0) temp
  16227. On temp.DcId =tcl.ClientId
  16228. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  16229. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  16230. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  16231. //载入模板
  16232. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  16233. if (_dto.Language == 1)
  16234. {
  16235. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  16236. }
  16237. //载入模板
  16238. var doc = new Document(tempPath);
  16239. DocumentBuilder builder = new DocumentBuilder(doc);
  16240. //获取word里所有表格
  16241. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16242. //获取所填表格的序数
  16243. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16244. var rowStart = tableOne.Rows[0]; //获取第1行
  16245. if (_dto.Language == 0)
  16246. {
  16247. //循环赋值
  16248. for (int i = 0; i < DcList.Count; i++)
  16249. {
  16250. EncryptionProcessor.DecryptProperties(DcList[i]);
  16251. builder.MoveToCell(0, i + 1, 0, 0);
  16252. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  16253. builder.MoveToCell(0, i + 1, 1, 0);
  16254. int sex = DcList[i].Sex;
  16255. string sexStr = string.Empty;
  16256. if (sex == 0) sexStr = "男";
  16257. else if (sex == 1) sexStr = "女";
  16258. else sexStr = "未设置";
  16259. builder.Write(sexStr);
  16260. builder.MoveToCell(0, i + 1, 2, 0);
  16261. string birthDay = DcList[i].BirthDay;
  16262. string birthDayStr = string.Empty;
  16263. if (!string.IsNullOrEmpty(birthDay))
  16264. {
  16265. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  16266. }
  16267. builder.Write(birthDayStr);
  16268. builder.MoveToCell(0, i + 1, 3, 0);
  16269. string company = "";
  16270. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16271. {
  16272. company = DcList[i].CompanyFullName.ToString();
  16273. }
  16274. builder.Write(company);
  16275. builder.MoveToCell(0, i + 1, 4, 0);
  16276. builder.Write(DcList[i].Job);
  16277. }
  16278. }
  16279. else if (_dto.Language == 1)
  16280. {
  16281. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  16282. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  16283. List<string> transArrayStr = new List<string>();
  16284. string transStrRes1 = "";
  16285. for (int i = 0; i < DcList.Count; i++)
  16286. {
  16287. var dc = DcList[i];
  16288. EncryptionProcessor.DecryptProperties(dc);
  16289. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  16290. if (dc.Job.Equals("暂无")) dc.Job = "-";
  16291. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  16292. if (DcList.Count - 1 == i) transStrRes1 += str1;
  16293. else transStrRes1 += $"{str1}|";
  16294. }
  16295. //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";
  16296. string transStrRes = "";
  16297. if (transStrRes1.Length > 0)
  16298. {
  16299. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  16300. }
  16301. //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
  16302. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  16303. //List<string> transArray = new List<string> { };
  16304. List<TranslateInfo> transArray = new List<TranslateInfo>();
  16305. if (transStrRes.Contains("|"))
  16306. {
  16307. string[] transArray1 = transStrRes.Split('|');
  16308. if (transArray1.Length > 0)
  16309. {
  16310. foreach (var item in transArray1)
  16311. {
  16312. if (item.Contains("&"))
  16313. {
  16314. string[] transArray2 = item.Split('&');
  16315. int index = 0;
  16316. string companyName = "", job = "";
  16317. if (transArray2.Length > 0)
  16318. {
  16319. bool success = int.TryParse(transArray2[0].Trim(), out index);
  16320. if (1 < transArray2.Length) companyName = transArray2[1];
  16321. if (2 < transArray2.Length) job = transArray2[2];
  16322. }
  16323. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  16324. }
  16325. }
  16326. }
  16327. }
  16328. //循环赋值
  16329. for (int i = 0; i < DcList.Count; i++)
  16330. {
  16331. string PYName = "";
  16332. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  16333. {
  16334. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  16335. string PY_First = DcList[i].Pinyin.Split('/')[1];
  16336. PYName = PY_First + " " + PY_Last;
  16337. }
  16338. else
  16339. {
  16340. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  16341. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  16342. PYName = PY_First + " " + PY_Last;
  16343. }
  16344. builder.MoveToCell(0, i + 1, 0, 0);
  16345. builder.Write(PYName);
  16346. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  16347. builder.MoveToCell(0, i + 1, 1, 0);
  16348. builder.Write(sex);
  16349. DateTime birthDt;
  16350. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  16351. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  16352. builder.MoveToCell(0, i + 1, 2, 0);
  16353. builder.Write(birthday);
  16354. string company = string.Empty, job = string.Empty;
  16355. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  16356. if (dcTransInfo != null)
  16357. {
  16358. company = dcTransInfo.CompanyName;
  16359. job = dcTransInfo.Job;
  16360. }
  16361. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16362. {
  16363. //查询对照表
  16364. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  16365. if (tempCec != null)
  16366. {
  16367. company = tempCec.enName;
  16368. }
  16369. //翻译
  16370. else
  16371. {
  16372. }
  16373. }
  16374. builder.MoveToCell(0, i + 1, 3, 0);
  16375. builder.Write(company);
  16376. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  16377. {
  16378. //查询对照表
  16379. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  16380. if (tempPec != null)
  16381. {
  16382. job = tempPec.enName;
  16383. }
  16384. //翻译
  16385. else
  16386. {
  16387. }
  16388. }
  16389. builder.MoveToCell(0, i + 1, 4, 0);
  16390. builder.Write(job);
  16391. }
  16392. }
  16393. //删除多余行
  16394. while (tableOne.Rows.Count > DcList.Count + 1)
  16395. {
  16396. tableOne.Rows.RemoveAt(DcList.Count + 1);
  16397. }
  16398. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  16399. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  16400. doc.Save(fileDir);
  16401. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  16402. return Ok(JsonView(true, "操作成功!", Url));
  16403. }
  16404. private class TranslateInfo
  16405. {
  16406. public int Index { get; set; }
  16407. public string CompanyName { get; set; }
  16408. public string Job { get; set; }
  16409. }
  16410. #endregion
  16411. #region 团组倒推表
  16412. /// <summary>
  16413. /// 倒推表基础数据
  16414. /// Init
  16415. /// </summary>
  16416. /// <param name="dto"></param>
  16417. /// <returns></returns>
  16418. [HttpPost]
  16419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16420. public async Task<IActionResult> PostInvertedListInit()
  16421. {
  16422. var viewData = await _invertedListRep._Init();
  16423. if (viewData.Code != 0)
  16424. {
  16425. return Ok(JsonView(false, viewData.Msg));
  16426. }
  16427. return Ok(JsonView(viewData.Data));
  16428. }
  16429. /// <summary>
  16430. /// 倒推表
  16431. /// Info
  16432. /// </summary>
  16433. /// <param name="dto"></param>
  16434. /// <returns></returns>
  16435. [HttpPost]
  16436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16437. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  16438. {
  16439. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  16440. if (viewData.Code != 0)
  16441. {
  16442. return Ok(JsonView(false, viewData.Msg));
  16443. }
  16444. return Ok(JsonView(viewData.Data));
  16445. }
  16446. /// <summary>
  16447. /// 倒推表
  16448. /// Create
  16449. /// </summary>
  16450. /// <param name="dto"></param>
  16451. /// <returns></returns>
  16452. [HttpPost]
  16453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16454. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  16455. {
  16456. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  16457. if (viewData.Code != 0)
  16458. {
  16459. return Ok(JsonView(false, viewData.Msg));
  16460. }
  16461. return Ok(JsonView(viewData.Data));
  16462. }
  16463. /// <summary>
  16464. /// 倒推表
  16465. /// Update
  16466. /// </summary>
  16467. /// <param name="dto"></param>
  16468. /// <returns></returns>
  16469. [HttpPost]
  16470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16471. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  16472. {
  16473. var viewData = await _invertedListRep._Update(dto);
  16474. if (viewData.Code != 0)
  16475. {
  16476. return Ok(JsonView(false, viewData.Msg));
  16477. }
  16478. return Ok(JsonView(viewData.Data));
  16479. }
  16480. /// <summary>
  16481. /// 倒推表
  16482. /// File Download
  16483. /// </summary>
  16484. /// <param name="dto"></param>
  16485. /// <returns></returns>
  16486. [HttpPost]
  16487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16488. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  16489. {
  16490. var info2 = await _invertedListRep._Info(1, dto.DiId);
  16491. if (info2.Code != 0)
  16492. {
  16493. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  16494. }
  16495. var info1 = info2.Data as InvertedListInfoView;
  16496. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  16497. string teamName = "";
  16498. if (info != null) teamName = info.TeamName;
  16499. //载入模板
  16500. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  16501. DocumentBuilder builder = new DocumentBuilder(doc);
  16502. //利用键值对存放数据
  16503. Dictionary<string, string> dic = new Dictionary<string, string>();
  16504. dic.Add("TeamName", teamName);
  16505. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  16506. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  16507. dic.Add("BPRemark", info1.ApprovalDataRemark);
  16508. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  16509. dic.Add("SQRemark", info1.ApprovalRemark);
  16510. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  16511. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  16512. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  16513. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  16514. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  16515. dic.Add("QZRemark", info1.VisaInformationRemark);
  16516. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  16517. dic.Add("SQQZRemark", info1.SendVisaRemark);
  16518. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  16519. dic.Add("CQRemark", info1.IssueVisaRemark);
  16520. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  16521. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  16522. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  16523. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  16524. #region 填充word模板书签内容
  16525. foreach (var key in dic.Keys)
  16526. {
  16527. builder.MoveToBookmark(key);
  16528. builder.Write(dic[key]);
  16529. }
  16530. #endregion
  16531. var fileDir = AppSettingsHelper.Get("WordBasePath");
  16532. string fileName = $"{teamName}团出行准备流程表.doc";
  16533. string filePath = fileDir + $@"InvertedList/{fileName}";
  16534. doc.Save(filePath);
  16535. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  16536. return Ok(JsonView(true, "操作成功!", Url));
  16537. }
  16538. #endregion
  16539. #region 三公签证费用(签证费、代办费)
  16540. /// <summary>
  16541. /// 三公签证费用(签证费、代办费)
  16542. /// List
  16543. /// </summary>
  16544. /// <returns></returns>
  16545. [HttpPost]
  16546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16547. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  16548. {
  16549. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  16550. if (_view.Code != 0)
  16551. {
  16552. return Ok(JsonView(false, _view.Msg));
  16553. }
  16554. return Ok(JsonView(true, "操作成功!", _view.Data));
  16555. }
  16556. /// <summary>
  16557. /// 三公签证费用(签证费、代办费)
  16558. /// Add Or Update
  16559. /// </summary>
  16560. /// <returns></returns>
  16561. [HttpPost]
  16562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16563. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  16564. {
  16565. var _view = await _visaFeeInfoRep._Update(_dto);
  16566. if (_view.Code != 0)
  16567. {
  16568. return Ok(JsonView(false, _view.Msg));
  16569. }
  16570. return Ok(JsonView(true, _view.Msg));
  16571. }
  16572. #endregion
  16573. #region 酒店询价
  16574. /// <summary>
  16575. /// 酒店询价
  16576. /// Init
  16577. /// </summary>
  16578. /// <param name="dto"></param>
  16579. /// <returns></returns>
  16580. [HttpPost]
  16581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16582. public async Task<IActionResult> PostHotelInquiryInit()
  16583. {
  16584. var res = await _hotelInquiryRep._Init();
  16585. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16586. return Ok(JsonView(true, res.Msg, res.Data));
  16587. }
  16588. /// <summary>
  16589. /// 酒店询价
  16590. /// page Item
  16591. /// </summary>
  16592. /// <param name="_dto"></param>
  16593. /// <returns></returns>
  16594. [HttpPost]
  16595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16596. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  16597. {
  16598. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  16599. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16600. var view = res.Data as PageDataViewBase;
  16601. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  16602. }
  16603. /// <summary>
  16604. /// 酒店询价
  16605. /// info
  16606. /// </summary>
  16607. /// <param name="_dto"></param>
  16608. /// <returns></returns>
  16609. [HttpPost]
  16610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16611. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  16612. {
  16613. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  16614. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16615. return Ok(JsonView(true, res.Msg, res.Data));
  16616. }
  16617. /// <summary>
  16618. /// 酒店询价
  16619. /// Add Or Edit
  16620. /// </summary>
  16621. /// <param name="_dto"></param>
  16622. /// <returns></returns>
  16623. [HttpPost]
  16624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16625. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  16626. {
  16627. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  16628. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16629. return Ok(JsonView(true, res.Msg, res.Data));
  16630. }
  16631. /// <summary>
  16632. /// 酒店询价
  16633. /// Del
  16634. /// </summary>
  16635. /// <param name="_dto"></param>
  16636. /// <returns></returns>
  16637. [HttpPost]
  16638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16639. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  16640. {
  16641. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  16642. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16643. return Ok(JsonView(true, res.Msg, res.Data));
  16644. }
  16645. #endregion
  16646. #region 下载匹配op行程单
  16647. /// <summary>
  16648. /// 匹配op行程单
  16649. /// Init
  16650. /// </summary>
  16651. /// <param name="dto">团组列表请求dto</param>
  16652. /// <returns></returns>
  16653. [HttpPost]
  16654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16655. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  16656. {
  16657. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  16658. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  16659. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  16660. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  16661. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  16662. .Where(it => it.IsDel == 0)
  16663. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  16664. .OrderByDescending(it => it.CreateUserId)
  16665. .ToList();
  16666. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  16667. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  16668. var diids = groupInfos.Select(it => it.Id).ToList();
  16669. List<string> countrys = new List<string>();
  16670. foreach (var item in country)
  16671. {
  16672. var data = _groupRepository.FormartTeamName(item);
  16673. var dataArray = _groupRepository.GroupSplitCountry(data);
  16674. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  16675. }
  16676. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  16677. List<string> areaArray = new List<string>(); //GetGroupCityLine
  16678. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  16679. foreach (var item in areaItem)
  16680. {
  16681. string areaStr = item.Value;
  16682. if (!string.IsNullOrEmpty(areaStr))
  16683. {
  16684. string[] str1 = areaStr.Split("-");
  16685. if (str1.Length > 0)
  16686. {
  16687. areaArray.AddRange(str1);
  16688. }
  16689. }
  16690. }
  16691. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  16692. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  16693. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  16694. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  16695. .ToList();
  16696. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  16697. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  16698. .Where(it => countriesIds.Contains(it.Id))
  16699. .Select(it => new { it.Id, Name = it.Name_CN })
  16700. .ToList();
  16701. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  16702. .Select(it => it.TeamName).ToList();
  16703. stopwatch.Stop();
  16704. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  16705. }
  16706. ///// <summary>
  16707. ///// 匹配op行程单
  16708. ///// Init 查询区域数据
  16709. ///// </summary>
  16710. ///// <param name="dto">团组列表请求dto</param>
  16711. ///// <returns></returns>
  16712. //[HttpPost]
  16713. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16714. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  16715. //{
  16716. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  16717. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  16718. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  16719. // if (string.IsNullOrEmpty(countriesDataStr))
  16720. // {
  16721. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  16722. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  16723. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  16724. // }
  16725. // else
  16726. // {
  16727. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  16728. // }
  16729. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  16730. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  16731. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  16732. // List<dynamic> childList = new List<dynamic>();
  16733. // int parentId = dto.CountriesId;
  16734. // if (provinceData.Count > 1)
  16735. // {
  16736. // foreach (var item1 in provinceData)
  16737. // {
  16738. // List<dynamic> childList1 = new List<dynamic>();
  16739. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  16740. // foreach (var item2 in citiesData1)
  16741. // {
  16742. // List<dynamic> childList2 = new List<dynamic>();
  16743. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  16744. // foreach (var item3 in countiesData1)
  16745. // {
  16746. // childList2.Add(new
  16747. // {
  16748. // id = item3.Id,
  16749. // parentId = item2.Id,
  16750. // level = "district",
  16751. // name = item3.Name_CN,
  16752. // });
  16753. // }
  16754. // childList1.Add(new
  16755. // {
  16756. // id = item2.Id,
  16757. // parentId = item1.Id,
  16758. // level = "city",
  16759. // name = item2.Name_CN,
  16760. // childList = childList2
  16761. // });
  16762. // }
  16763. // childList.Add(new
  16764. // {
  16765. // id = item1.Id,
  16766. // parentId = parentId,
  16767. // level = "province",
  16768. // name = item1.Name_CN,
  16769. // childList = childList1
  16770. // });
  16771. // }
  16772. // //城市
  16773. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  16774. // foreach (var item2 in citiesData2)
  16775. // {
  16776. // List<dynamic> childList22 = new List<dynamic>();
  16777. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  16778. // foreach (var item3 in countiesData1)
  16779. // {
  16780. // childList22.Add(new
  16781. // {
  16782. // id = item3.Id,
  16783. // parentId = item2.Id,
  16784. // level = "district",
  16785. // name = item3.Name_CN,
  16786. // });
  16787. // }
  16788. // childList.Add(new
  16789. // {
  16790. // id = item2.Id,
  16791. // parentId = parentId,
  16792. // level = "city",
  16793. // name = item2.Name_CN,
  16794. // childList = childList22
  16795. // });
  16796. // }
  16797. // }
  16798. // else
  16799. // {
  16800. // foreach (var item2 in citiesData)
  16801. // {
  16802. // string cname = item2.Name_CN;
  16803. // List<dynamic> childList1 = new List<dynamic>();
  16804. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  16805. // foreach (var item3 in countiesData1)
  16806. // {
  16807. // childList1.Add(new
  16808. // {
  16809. // Id = item3.Id,
  16810. // parentId = item2.Id,
  16811. // level = "district",
  16812. // name = item3.Name_CN
  16813. // });
  16814. // }
  16815. // childList.Add(new
  16816. // {
  16817. // id = item2.Id,
  16818. // parentId = parentId,
  16819. // level = "city",
  16820. // name = item2.Name_CN,
  16821. // childList = childList1
  16822. // });
  16823. // }
  16824. // }
  16825. // stopwatch.Stop();
  16826. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  16827. //}
  16828. /// <summary>
  16829. /// 匹配op行程单
  16830. /// 接团信息列表 Page
  16831. /// </summary>
  16832. /// <param name="dto">团组列表请求dto</param>
  16833. /// <returns></returns>
  16834. [HttpPost]
  16835. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16836. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  16837. {
  16838. var swatch = new Stopwatch();
  16839. swatch.Start();
  16840. #region 参数验证
  16841. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16842. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  16843. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16844. #region 页面操作权限验证
  16845. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  16846. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  16847. #endregion
  16848. #endregion
  16849. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  16850. {
  16851. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  16852. string sqlWhere = "";
  16853. if (!string.IsNullOrEmpty(dto.Country))
  16854. {
  16855. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  16856. }
  16857. if (!string.IsNullOrEmpty(dto.Area))
  16858. {
  16859. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  16860. }
  16861. if (!string.IsNullOrEmpty(dto.TeamName))
  16862. {
  16863. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  16864. }
  16865. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  16866. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  16867. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  16868. swatch.Stop();
  16869. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  16870. }
  16871. else
  16872. {
  16873. return Ok(JsonView(false, "查询失败"));
  16874. }
  16875. }
  16876. /// <summary>
  16877. /// 匹配op行程单
  16878. /// 行程单下载
  16879. /// </summary>
  16880. /// <param name="dto">团组列表请求dto</param>
  16881. /// <returns></returns>
  16882. [HttpPost]
  16883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16884. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  16885. {
  16886. #region 参数验证
  16887. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16888. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  16889. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16890. #region 页面操作权限验证
  16891. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  16892. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  16893. #endregion
  16894. #endregion
  16895. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  16896. {
  16897. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  16898. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  16899. }
  16900. else
  16901. {
  16902. return Ok(JsonView(false, "下载失败!"));
  16903. }
  16904. }
  16905. #endregion
  16906. #region 国家信息 数据 注释
  16907. //[HttpPost]
  16908. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  16909. //{
  16910. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  16911. // foreach (var item in dto)
  16912. // {
  16913. // infos.Add(new Grp_GroupsTaskAssignment()
  16914. // {
  16915. // DIId = item,
  16916. // CTId = 82,
  16917. // UId = 248,
  16918. // IsEnable = 1,
  16919. // CreateUserId = 233,
  16920. // CreateTime = DateTime.Now,
  16921. // IsDel = 0
  16922. // });
  16923. // infos.Add(new Grp_GroupsTaskAssignment()
  16924. // {
  16925. // DIId = item,
  16926. // CTId = 82,
  16927. // UId = 286,
  16928. // IsEnable = 1,
  16929. // CreateUserId = 233,
  16930. // CreateTime = DateTime.Now,
  16931. // IsDel = 0
  16932. // });
  16933. // }
  16934. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  16935. // return Ok("操作成功");
  16936. //}
  16937. //public class paramJsonDto
  16938. //{
  16939. // public List<CountriesInfo> str { get; set; }
  16940. //}
  16941. //[HttpPost]
  16942. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  16943. //{
  16944. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  16945. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  16946. // List<Sys_Cities> cities = new List<Sys_Cities>();
  16947. // List<Sys_Cities> districts = new List<Sys_Cities>();
  16948. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  16949. // _sqlSugar.BeginTran();
  16950. // int countitiesIndex = 0;
  16951. // foreach (var item in dto.str)
  16952. // {
  16953. // dynamic data = item.c;
  16954. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  16955. // if (data != null)
  16956. // {
  16957. // countitiesIndex++;
  16958. // foreach (var item1 in data)
  16959. // {
  16960. // string cnname = item1.cn;
  16961. // string enname = item1.en;
  16962. // Sys_Cities provinceInfo = new Sys_Cities()
  16963. // {
  16964. // CountriesId = countriesId,
  16965. // Name_CN = cnname,
  16966. // Name_EN = enname,
  16967. // ParentId = 0,
  16968. // IsCapital = 1,
  16969. // CreateUserId = 208,
  16970. // CreateTime = DateTime.Now,
  16971. // IsDel = 0
  16972. // };
  16973. // if (item1.lv == "province") //省份
  16974. // {
  16975. // provinceInfo.Level = 1;
  16976. // int provinceId = 0;
  16977. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  16978. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  16979. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  16980. // var data1 = item1.c;
  16981. // foreach (var item2 in data1)
  16982. // {
  16983. // if (item2.lv == "city")
  16984. // {
  16985. // string citycnname = item2.cn;
  16986. // string cityenname = item2.en;
  16987. // Sys_Cities cityInfo = new Sys_Cities()
  16988. // {
  16989. // CountriesId = countriesId,
  16990. // ParentId = provinceId,
  16991. // Level = 2,
  16992. // Name_CN = citycnname,
  16993. // Name_EN = cityenname,
  16994. // IsCapital = 1,
  16995. // CreateUserId = 208,
  16996. // CreateTime = DateTime.Now,
  16997. // IsDel = 0
  16998. // };
  16999. // if (item2.c != null)
  17000. // {
  17001. // int cityId = 0;
  17002. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  17003. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17004. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  17005. // foreach (var item3 in item2.c)
  17006. // {
  17007. // if (item3.lv == "district")
  17008. // {
  17009. // var districtInfo = new Sys_Cities()
  17010. // {
  17011. // CountriesId = countriesId,
  17012. // Name_CN = item3.cn,
  17013. // Name_EN = item3.en,
  17014. // Level = 3,
  17015. // ParentId = cityId,
  17016. // IsCapital = 1,
  17017. // CreateUserId = 208,
  17018. // CreateTime = DateTime.Now,
  17019. // IsDel = 0
  17020. // };
  17021. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17022. // //{
  17023. // districts.Add(districtInfo);
  17024. // //}
  17025. // }
  17026. // }
  17027. // }
  17028. // else
  17029. // {
  17030. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  17031. // //{
  17032. // cities.Add(cityInfo);
  17033. // //}
  17034. // }
  17035. // }
  17036. // }
  17037. // }
  17038. // else if (item1.lv == "city")//城市
  17039. // {
  17040. // provinceInfo.Level = 2;
  17041. // if (item1.c != null)
  17042. // {
  17043. // int cityId = 0;
  17044. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  17045. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17046. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17047. // foreach (var item3 in item1.c)
  17048. // {
  17049. // if (item3.lv == "district")
  17050. // {
  17051. // var districtInfo = new Sys_Cities()
  17052. // {
  17053. // CountriesId = countriesId,
  17054. // Name_CN = item3.cn,
  17055. // Name_EN = item3.en,
  17056. // Level = 3,
  17057. // ParentId = cityId,
  17058. // IsCapital = 1,
  17059. // CreateUserId = 208,
  17060. // CreateTime = DateTime.Now,
  17061. // IsDel = 0
  17062. // };
  17063. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17064. // //{
  17065. // districts.Add(districtInfo);
  17066. // //}
  17067. // }
  17068. // }
  17069. // }
  17070. // else
  17071. // {
  17072. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  17073. // //{
  17074. // cities.Add(provinceInfo);
  17075. // //}
  17076. // }
  17077. // }
  17078. // }
  17079. // }
  17080. // }
  17081. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  17082. // cities = cities.Distinct().ToList();
  17083. // districts = districts.Distinct().ToList();
  17084. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  17085. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  17086. // cities.AddRange(districts);
  17087. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  17088. // //_sqlSugar.RollbackTran();
  17089. // _sqlSugar.CommitTran();
  17090. // return Ok(JsonView(false, "操作成功!"));
  17091. //}
  17092. //[HttpPost]
  17093. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  17094. //{
  17095. // List<CountitiesInfo> infos = dto.MyProperty;
  17096. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  17097. // _sqlSugar.BeginTran();
  17098. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17099. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  17100. // foreach (var item in infos)
  17101. // {
  17102. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  17103. // if (countryInfo != null)
  17104. // {
  17105. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  17106. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  17107. // if (cityInfo1 != null)
  17108. // {
  17109. // cityInfo1.IsCapital = 0;
  17110. // cityInfos.Add(cityInfo1);
  17111. // }
  17112. // }
  17113. // }
  17114. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  17115. // .UpdateColumns(it => it.IsCapital)
  17116. // .WhereColumns(it => it.Id)
  17117. // .ExecuteCommand();
  17118. // //_sqlSugar.RollbackTran();
  17119. // _sqlSugar.CommitTran();
  17120. // return Ok(JsonView(false, "操作成功!"));
  17121. //}
  17122. //public class CounrtiesDto
  17123. //{
  17124. // public List<CountitiesInfo> MyProperty { get; set; }
  17125. //}
  17126. //public class CountitiesInfo
  17127. //{
  17128. // /// <summary>
  17129. // /// 圣约翰
  17130. // /// </summary>
  17131. // public string capital_name_chinese { get; set; }
  17132. // /// <summary>
  17133. // ///
  17134. // /// </summary>
  17135. // public string capital_name { get; set; }
  17136. // /// <summary>
  17137. // ///
  17138. // /// </summary>
  17139. // public string country_type { get; set; }
  17140. // /// <summary>
  17141. // /// 安提瓜和巴布达
  17142. // /// </summary>
  17143. // public string country_name_chinese { get; set; }
  17144. // /// <summary>
  17145. // /// 安提瓜和巴布达
  17146. // /// </summary>
  17147. // public string country_name_chinese_short { get; set; }
  17148. // /// <summary>
  17149. // /// 安提瓜和巴布达
  17150. // /// </summary>
  17151. // public string country_name_chinese_UN { get; set; }
  17152. // /// <summary>
  17153. // ///
  17154. // /// </summary>
  17155. // public string country_name_english_abbreviation { get; set; }
  17156. // /// <summary>
  17157. // ///
  17158. // /// </summary>
  17159. // public string country_name_english_formal { get; set; }
  17160. // /// <summary>
  17161. // ///
  17162. // /// </summary>
  17163. // public string country_name_english_UN { get; set; }
  17164. // /// <summary>
  17165. // ///
  17166. // /// </summary>
  17167. // public string continent_name { get; set; }
  17168. // /// <summary>
  17169. // ///
  17170. // /// </summary>
  17171. // public string subregion_name { get; set; }
  17172. // /// <summary>
  17173. // ///
  17174. // /// </summary>
  17175. // public string country_code2 { get; set; }
  17176. // /// <summary>
  17177. // ///
  17178. // /// </summary>
  17179. // public string country_code3 { get; set; }
  17180. // /// <summary>
  17181. // ///
  17182. // /// </summary>
  17183. // public string phone_code { get; set; }
  17184. //}
  17185. //public class CountriesInfo : BasicInfo
  17186. //{
  17187. // public List<CitiesInfo> c { get; set; }
  17188. //}
  17189. //public class CitiesInfo : BasicInfo
  17190. //{
  17191. // public List<AreaInfo> c { get; set; }
  17192. //}
  17193. //public class AreaInfo : BasicInfo
  17194. //{
  17195. // public List<AreaInfo> c { get; set; }
  17196. //}
  17197. //public class BasicInfo
  17198. //{
  17199. // public string code { get; set; }
  17200. // public string cn { get; set; }
  17201. // public string lv { get; set; }
  17202. // public string en { get; set; }
  17203. //}
  17204. #endregion
  17205. #region 查看邀请方
  17206. /// <summary>
  17207. /// 查看邀请方
  17208. /// 邀请方信息 Init
  17209. /// </summary>
  17210. /// <param name="dto"></param>
  17211. /// <returns></returns>
  17212. [HttpPost]
  17213. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17214. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  17215. {
  17216. string sqlWhere = string.Empty;
  17217. if (!string.IsNullOrEmpty(dto.Search))
  17218. {
  17219. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  17220. }
  17221. string sql = string.Format($@"Select
  17222. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  17223. Id,
  17224. UnitName
  17225. From Res_InvitationOfficialActivityData
  17226. Where IsDel = 0
  17227. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  17228. RefAsync<int> total = 0;
  17229. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17230. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  17231. }
  17232. /// <summary>
  17233. /// 查看邀请方
  17234. /// 国家信息 Init
  17235. /// </summary>
  17236. /// <param name="dto"></param>
  17237. /// <returns></returns>
  17238. [HttpPost]
  17239. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17240. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  17241. {
  17242. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  17243. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17244. var diids = groupInfos.Select(it => it.Id).ToList();
  17245. List<string> countrys = new List<string>();
  17246. foreach (var item in country)
  17247. {
  17248. var data = _groupRepository.FormartTeamName(item);
  17249. var dataArray = _groupRepository.GroupSplitCountry(data);
  17250. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17251. }
  17252. countrys = countrys.Distinct().ToList();
  17253. for (int i = 0; i < countrys.Count; i++)
  17254. {
  17255. string item = countrys[i];
  17256. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  17257. {
  17258. countrys.Remove(item);
  17259. i--;
  17260. }
  17261. }
  17262. RefAsync<int> total = 0;
  17263. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  17264. .Where(it => countrys.Contains(it.Name_CN))
  17265. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17266. .Select(it => new { id = it.Id, name = it.Name_CN })
  17267. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17268. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17269. }
  17270. /// <summary>
  17271. /// 查看邀请方
  17272. /// 城市信息 Init
  17273. /// </summary>
  17274. /// <param name="dto"></param>
  17275. /// <returns></returns>
  17276. [HttpPost]
  17277. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17278. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  17279. {
  17280. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  17281. RefAsync<int> total = 0;
  17282. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  17283. .Where(it => it.CountriesId == dto.CountiesId)
  17284. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17285. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  17286. .Select(it => new { id = it.Id, name = it.Name_CN })
  17287. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17288. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17289. }
  17290. /// <summary>
  17291. /// 查看邀请方
  17292. /// 团组名称 Init
  17293. /// </summary>
  17294. /// <param name="dto"></param>
  17295. /// <returns></returns>
  17296. [HttpPost]
  17297. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17298. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  17299. {
  17300. var watch = new Stopwatch();
  17301. watch.Start();
  17302. RefAsync<int> total = 0;
  17303. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  17304. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  17305. .Where((oa, di) => oa.IsDel == 0)
  17306. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  17307. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  17308. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  17309. .Distinct()
  17310. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17311. watch.Stop();
  17312. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  17313. }
  17314. /// <summary>
  17315. /// 查看邀请方
  17316. /// 团组 & 邀请方信息
  17317. /// </summary>
  17318. /// <param name="dto"></param>
  17319. /// <returns></returns>
  17320. [HttpPost]
  17321. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17322. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  17323. {
  17324. var watch = new Stopwatch();
  17325. watch.Start();
  17326. RefAsync<int> total = 0;
  17327. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  17328. .AS("Grp_DelegationInfo")
  17329. .Includes(x => x.InvitingInfos)
  17330. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  17331. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  17332. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  17333. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  17334. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  17335. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  17336. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17337. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  17338. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  17339. infos.ForEach(x =>
  17340. {
  17341. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  17342. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  17343. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  17344. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  17345. });
  17346. watch.Stop();
  17347. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  17348. }
  17349. #endregion
  17350. #region 报批行程
  17351. /// <summary>
  17352. /// 报批行程初始化
  17353. /// </summary>
  17354. /// <param name="dto"></param>
  17355. /// <returns></returns>
  17356. [HttpPost]
  17357. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  17358. {
  17359. const int chiNumber = 5;
  17360. var jw = JsonView(false);
  17361. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  17362. var group = groupList.First();
  17363. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  17364. group = groupList.First(x => x.Id == diid);
  17365. if (group == null)
  17366. {
  17367. jw.Msg = "暂无团组!";
  17368. return Ok(jw);
  17369. }
  17370. var data = new
  17371. {
  17372. groupList = groupList.Select(x => new
  17373. {
  17374. x.TeamName,
  17375. x.Id
  17376. }),
  17377. content = new ArrayList(),
  17378. groupInfo = new
  17379. {
  17380. group.VisitDays,
  17381. group.TourCode,
  17382. group.VisitPNumber,
  17383. group.TeamName,
  17384. group.Id,
  17385. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  17386. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  17387. },
  17388. };
  17389. var resultArr = new ArrayList();
  17390. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  17391. if (content.Count == 0)
  17392. {
  17393. var stay = "-";
  17394. var cityPath = "-";
  17395. //添加城市路径以及住宿地
  17396. //黑屏代码数据
  17397. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  17398. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17399. {
  17400. jw = JsonView(true, "黑屏代码有误!", data);
  17401. return Ok(jw);
  17402. }
  17403. foreach (DataRow row in dtBlack.Rows)
  17404. {
  17405. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17406. {
  17407. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  17408. return Ok(jw);
  17409. }
  17410. }
  17411. //黑屏代码获取时间区间
  17412. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  17413. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  17414. _sqlSugar.BeginTran();
  17415. for (int i = 0; i < timeArr.Count; i++)
  17416. {
  17417. stay = "-";
  17418. cityPath = "-";
  17419. DateTime NewData = DateTime.Parse(timeArr[i]);
  17420. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  17421. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  17422. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  17423. if (tbSelect.Length > 0)
  17424. {
  17425. List<string> threeCodeStr = new List<string>();
  17426. foreach (var item in tbSelect)
  17427. {
  17428. var threeCode = item["Three"].ToString() ?? "";
  17429. if (threeCode.Length == 6)
  17430. {
  17431. var start = threeCode.Substring(0, 3);
  17432. var end = threeCode.Substring(3, 3);
  17433. if (threeCodeStr.Count == 0)
  17434. {
  17435. threeCodeStr.Add(start);
  17436. threeCodeStr.Add(end);
  17437. }
  17438. else
  17439. {
  17440. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  17441. {
  17442. threeCodeStr.Add(end);
  17443. }
  17444. else
  17445. {
  17446. threeCodeStr.Add(start);
  17447. threeCodeStr.Add(end);
  17448. }
  17449. }
  17450. }
  17451. }
  17452. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  17453. var last = threeCodeStr.Last();
  17454. foreach (var item in threeCodeStr)
  17455. {
  17456. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  17457. if (item.Equals(last))
  17458. {
  17459. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  17460. }
  17461. }
  17462. cityPath = cityPath.Trim('-');
  17463. }
  17464. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  17465. appro.Diid = diid ?? -1;
  17466. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  17467. appro.Id = thisId;
  17468. appro.CreateUserId = dto.UserId;
  17469. appro.CreateTime = DateTime.Now;
  17470. content.Add(appro);
  17471. }
  17472. _sqlSugar.CommitTran();
  17473. }
  17474. foreach (var x in content)
  17475. {
  17476. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  17477. if (chiList.Count < chiNumber)
  17478. {
  17479. for (int i = chiList.Count; i < chiNumber; i++)
  17480. {
  17481. chiList.Add(new Grp_ApprovalTravelDetails());
  17482. }
  17483. }
  17484. resultArr.Add(new
  17485. {
  17486. x.Id,
  17487. x.Date,
  17488. x.Diid,
  17489. chiList = chiList.Select(x1 => new
  17490. {
  17491. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  17492. x1.Details,
  17493. x1.ParentId,
  17494. x1.Id
  17495. })
  17496. });
  17497. }
  17498. data = data with
  17499. {
  17500. content = resultArr,
  17501. };
  17502. jw = JsonView(true, "获取成功!", data);
  17503. return Ok(jw);
  17504. }
  17505. /// <summary>
  17506. /// 报批行程删除
  17507. /// </summary>
  17508. /// <param name="dto"></param>
  17509. /// <returns></returns>
  17510. [HttpPost]
  17511. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  17512. {
  17513. var jw = JsonView(false);
  17514. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17515. if (group == null)
  17516. {
  17517. jw.Msg = "团组参数有误!";
  17518. return Ok(jw);
  17519. }
  17520. try
  17521. {
  17522. _sqlSugar.BeginTran();
  17523. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  17524. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  17525. {
  17526. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17527. DeleteUserId = dto.uesrId,
  17528. IsDel = 1
  17529. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  17530. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  17531. {
  17532. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17533. DeleteUserId = dto.uesrId,
  17534. IsDel = 1
  17535. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  17536. _sqlSugar.CommitTran();
  17537. jw = JsonView(true, "删除成功");
  17538. }
  17539. catch (Exception ex)
  17540. {
  17541. jw = JsonView(false, ex.Message);
  17542. }
  17543. return Ok(jw);
  17544. }
  17545. /// <summary>
  17546. /// 报批行程保存
  17547. /// </summary>
  17548. /// <param name="dto"></param>
  17549. /// <returns></returns>
  17550. [HttpPost]
  17551. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  17552. {
  17553. var jw = JsonView(false);
  17554. var Find = dto.Arr.Find(x => x.id == 0);
  17555. if (Find != null)
  17556. {
  17557. jw.Msg = "生成的ID为0!";
  17558. return Ok(jw);
  17559. }
  17560. foreach (var item in dto.Arr)
  17561. {
  17562. foreach (var chi in item.chiList)
  17563. {
  17564. if (chi.parentId == 0)
  17565. {
  17566. chi.parentId = item.id;
  17567. }
  17568. }
  17569. }
  17570. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  17571. _sqlSugar.BeginTran();
  17572. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  17573. {
  17574. var parentIds = dto.Arr.Select(x => x.id).ToList();
  17575. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  17576. {
  17577. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17578. DeleteUserId = dto.UserId,
  17579. IsDel = 1
  17580. }).ExecuteCommand();
  17581. }
  17582. try
  17583. {
  17584. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  17585. {
  17586. CreateTime = DateTime.Now,
  17587. CreateUserId = dto.UserId,
  17588. Details = x.details,
  17589. ParentId = x.parentId,
  17590. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17591. Remark = "",
  17592. IsDel = 0
  17593. }).ToList()).ExecuteCommand();
  17594. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  17595. {
  17596. Id = x.id,
  17597. Details = x.details,
  17598. ParentId = x.parentId,
  17599. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17600. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  17601. {
  17602. Details = x.Details,
  17603. ParentId = x.ParentId,
  17604. Time = x.Time
  17605. }).ExecuteCommand();
  17606. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  17607. {
  17608. Id = x.id,
  17609. Date = x.date,
  17610. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  17611. {
  17612. Date = x.Date
  17613. }).ExecuteCommand();
  17614. _sqlSugar.CommitTran();
  17615. jw = JsonView(true, "保存成功!");
  17616. }
  17617. catch (Exception ex)
  17618. {
  17619. _sqlSugar.RollbackTran();
  17620. jw = JsonView(false, "保存失败!" + ex.Message);
  17621. }
  17622. return Ok(jw);
  17623. }
  17624. /// <summary>
  17625. /// 报批行程生成
  17626. /// </summary>
  17627. /// <param name="dto"></param>
  17628. /// <returns></returns>
  17629. [HttpPost]
  17630. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  17631. {
  17632. var jw = JsonView(false);
  17633. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17634. if (group == null)
  17635. {
  17636. jw.Msg = "暂无该团组!";
  17637. return Ok(jw);
  17638. }
  17639. //黑屏代码数据
  17640. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  17641. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17642. {
  17643. jw.Msg = "黑屏代码有误!";
  17644. return Ok(jw);
  17645. }
  17646. foreach (DataRow row in dtBlack.Rows)
  17647. {
  17648. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17649. {
  17650. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  17651. return Ok(jw);
  17652. }
  17653. }
  17654. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  17655. var resultArr = new ArrayList();
  17656. if (officialActivitiesArr.Count == 0)
  17657. {
  17658. jw.Msg = "暂无公务出访信息!";
  17659. return Ok(jw);
  17660. }
  17661. try
  17662. {
  17663. _sqlSugar.BeginTran();
  17664. DeleteApprovalJourney(new
  17665. Domain.Dtos.Groups.DeleteApprovalJourney
  17666. {
  17667. Diid = dto.Diid,
  17668. uesrId = dto.Userid
  17669. });
  17670. var stay = "-";
  17671. var cityPath = "-";
  17672. //添加城市路径以及住宿地
  17673. //黑屏代码获取时间区间
  17674. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  17675. var empty = "【未收入该三字码!请机票同事录入】";
  17676. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  17677. for (int i = 0; i < timeArr.Count; i++)
  17678. {
  17679. stay = "-";
  17680. cityPath = "-";
  17681. var chiarr = new List<Grp_ApprovalTravelDetails>();
  17682. DateTime NewData = DateTime.Parse(timeArr[i]);
  17683. 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();
  17684. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  17685. if (tbSelect.Length > 0)
  17686. {
  17687. List<string> threeCodeStr = new List<string>();
  17688. bool isTrade = false;
  17689. string trip = string.Empty;
  17690. var rowLast = tbSelect.Last();
  17691. var rowFirst = tbSelect.First();
  17692. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  17693. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  17694. var takeOffTime = DateTime.Parse(timeArr[i]);
  17695. var fallToTime = DateTime.Parse(timeArr[i]);
  17696. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  17697. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  17698. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  17699. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  17700. foreach (var item in tbSelect)
  17701. {
  17702. var start = string.Empty;
  17703. var end = string.Empty;
  17704. var threeCode = item["Three"].ToString() ?? "";
  17705. if (threeCode.Length == 6)
  17706. {
  17707. start = threeCode.Substring(0, 3);
  17708. end = threeCode.Substring(3, 3);
  17709. if (threeCodeStr.Count == 0)
  17710. {
  17711. threeCodeStr.Add(start);
  17712. threeCodeStr.Add(end);
  17713. }
  17714. else
  17715. {
  17716. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  17717. {
  17718. threeCodeStr.Add(end);
  17719. }
  17720. else
  17721. {
  17722. threeCodeStr.Add(start);
  17723. threeCodeStr.Add(end);
  17724. }
  17725. }
  17726. }
  17727. //处理机票信息
  17728. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  17729. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  17730. if (start_Object == null)
  17731. {
  17732. start_Object = new Res_ThreeCode()
  17733. {
  17734. AirPort = empty,
  17735. AirPort_En = empty,
  17736. City = empty,
  17737. Country = empty,
  17738. Four = empty,
  17739. Three = empty,
  17740. };
  17741. }
  17742. if (end_Object == null)
  17743. {
  17744. end_Object = new Res_ThreeCode()
  17745. {
  17746. AirPort = empty,
  17747. AirPort_En = empty,
  17748. City = empty,
  17749. Country = empty,
  17750. Four = empty,
  17751. Three = empty,
  17752. };
  17753. }
  17754. //机型判断
  17755. string airModel = item["AirModel"].ToString();
  17756. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  17757. string flightTime = item["FlightTime"].ToString();
  17758. if (flightTime!.Contains(":"))
  17759. {
  17760. flightTime = flightTime.Replace(":", "小时");
  17761. flightTime += "分钟";
  17762. }
  17763. if (flightTime.Contains("H"))
  17764. {
  17765. flightTime = flightTime.Replace("H", "小时");
  17766. }
  17767. if (flightTime.Contains("M"))
  17768. {
  17769. flightTime = flightTime.Replace("M", "分钟");
  17770. }
  17771. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  17772. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  17773. {
  17774. flightTime = flightDataTime.Hour > 0
  17775. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  17776. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  17777. ? flightDataTime.Minute.ToString() + "分钟" : "";
  17778. }
  17779. //航班号
  17780. string flightcode = item["Fliagtcode"].ToString();
  17781. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  17782. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  17783. if (aircompany == null)
  17784. {
  17785. aircompany = new Res_AirCompany
  17786. {
  17787. CnName = hsEmpty,
  17788. EnName = hsEmpty,
  17789. ShortCode = hsEmpty,
  17790. };
  17791. }
  17792. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  17793. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  17794. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  17795. if (isTrade)
  17796. {
  17797. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  17798. }
  17799. else
  17800. {
  17801. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  17802. }
  17803. }
  17804. chiarr.Add(new Grp_ApprovalTravelDetails
  17805. {
  17806. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  17807. CreateTime = DateTime.Now,
  17808. CreateUserId = dto.Userid,
  17809. ParentId = 0,
  17810. Details = trip
  17811. });
  17812. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  17813. var last = threeCodeStr.Last();
  17814. foreach (var item in threeCodeStr)
  17815. {
  17816. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  17817. if (item.Equals(last))
  17818. {
  17819. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  17820. }
  17821. }
  17822. cityPath = cityPath.Trim('-');
  17823. }
  17824. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  17825. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  17826. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  17827. appro.Diid = dto.Diid;
  17828. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  17829. appro.Id = thisId;
  17830. appro.CreateUserId = dto.Userid;
  17831. appro.CreateTime = DateTime.Now;
  17832. foreach (var item in gwinfo)
  17833. {
  17834. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  17835. chi.Details = "拜访" + item.Client;
  17836. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  17837. {
  17838. chi.Details += "," + item.ReqSample;
  17839. }
  17840. chi.ParentId = thisId;
  17841. chi.Time = item.Time;
  17842. chiarr.Add(chi);
  17843. }
  17844. if (chiarr.Count < 5)
  17845. {
  17846. for (int j = chiarr.Count; j < 5; j++)
  17847. {
  17848. chiarr.Add(new
  17849. Grp_ApprovalTravelDetails());
  17850. }
  17851. }
  17852. resultArr.Add(new
  17853. {
  17854. appro.Id,
  17855. appro.Date,
  17856. appro.Diid,
  17857. chiList = chiarr.Select(x1 => new
  17858. {
  17859. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  17860. x1.Details,
  17861. x1.ParentId,
  17862. x1.Id
  17863. })
  17864. });
  17865. }
  17866. _sqlSugar.CommitTran();
  17867. jw = JsonView(true, "生成成功!", resultArr);
  17868. }
  17869. catch (Exception ex)
  17870. {
  17871. jw.Code = 400;
  17872. jw.Msg = "生成失败!" + ex.Message;
  17873. }
  17874. return Ok(jw);
  17875. }
  17876. /// <summary>
  17877. /// 报批行程word导出
  17878. /// </summary>
  17879. /// <param name="dto"></param>
  17880. /// <returns></returns>
  17881. [HttpPost]
  17882. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  17883. {
  17884. var jw = JsonView(false);
  17885. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17886. if (group == null)
  17887. {
  17888. jw.Msg = "暂无该团组!";
  17889. return Ok(jw);
  17890. }
  17891. //模板路径
  17892. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  17893. //载入模板
  17894. Document doc = new Document(tempPath);
  17895. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17896. //获取所填表格的序数
  17897. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  17898. Aspose.Words.Tables.Row titleRowClone = null;
  17899. Aspose.Words.Tables.Row CenterRowClone = null;
  17900. int index = 0;
  17901. int indexChi = 0;
  17902. int SetIndex = 0;
  17903. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  17904. //获取数据,放到datatable
  17905. foreach (var item in ApprovalTravelArr)
  17906. {
  17907. if (index > 0)
  17908. {
  17909. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  17910. tableOne.AppendChild(titleRowClone);
  17911. }
  17912. var textTime = item.Date;
  17913. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  17914. SetCells(tableOne, doc, SetIndex, 0, textTime);
  17915. SetIndex++;
  17916. if (ChiRep.Count > 0)
  17917. {
  17918. foreach (var itemChi in ChiRep)
  17919. {
  17920. var txtTime = itemChi.Time;
  17921. var txtDetail = itemChi.Details;
  17922. if (indexChi > 0)
  17923. {
  17924. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  17925. tableOne.AppendChild(CenterRowClone);
  17926. }
  17927. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  17928. {
  17929. SetCells(tableOne, doc, SetIndex, 0, "");
  17930. SetCells(tableOne, doc, SetIndex, 1, "");
  17931. indexChi++;
  17932. SetIndex++;
  17933. break;
  17934. }
  17935. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  17936. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  17937. indexChi++;
  17938. SetIndex++;
  17939. }
  17940. }
  17941. else
  17942. {
  17943. if (indexChi > 0)
  17944. {
  17945. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  17946. tableOne.AppendChild(CenterRowClone);
  17947. }
  17948. SetCells(tableOne, doc, SetIndex, 0, "");
  17949. SetCells(tableOne, doc, SetIndex, 1, "");
  17950. indexChi++;
  17951. SetIndex++;
  17952. }
  17953. index++;
  17954. }
  17955. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  17956. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  17957. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  17958. jw.Code = 200;
  17959. jw.Msg = "";
  17960. return Ok(jw);
  17961. }
  17962. private string intToString(int numberVal)
  17963. {
  17964. string numberval = numberVal.ToString();
  17965. Dictionary<char, string> Number = new Dictionary<char, string>();
  17966. Number.Add('1', "一");
  17967. Number.Add('2', "二");
  17968. Number.Add('3', "三");
  17969. Number.Add('4', "四");
  17970. Number.Add('5', "五");
  17971. Number.Add('6', "六");
  17972. Number.Add('7', "七");
  17973. Number.Add('8', "八");
  17974. Number.Add('9', "九");
  17975. string stringNumberVal = string.Empty;
  17976. for (int i = 0; i < numberval.Length; i++)
  17977. {
  17978. if (i == 0)
  17979. {
  17980. stringNumberVal += Number[numberval[i]];
  17981. }
  17982. else if (i >= 1)
  17983. {
  17984. if (numberval[i] == '0')
  17985. {
  17986. stringNumberVal = "十";
  17987. }
  17988. else
  17989. {
  17990. stringNumberVal += "十" + Number[numberval[i]];
  17991. }
  17992. }
  17993. }
  17994. return stringNumberVal;
  17995. }
  17996. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  17997. {
  17998. //获取table中的某个单元格,从0开始
  17999. Cell lshCell = table.Rows[rows].Cells[cells];
  18000. //将单元格中段落移除
  18001. foreach (Node item in lshCell.Paragraphs)
  18002. {
  18003. lshCell.Paragraphs.Remove(item);
  18004. }
  18005. if (val.Contains("\r\n"))
  18006. {
  18007. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  18008. foreach (var item in spArr)
  18009. {
  18010. //新建一个段落
  18011. Paragraph p = new Paragraph(doc);
  18012. var r = new Run(doc, item);
  18013. //把设置的值赋给之前新建的段落
  18014. p.AppendChild(r);
  18015. //将此段落加到单元格内
  18016. lshCell.AppendChild(p);
  18017. }
  18018. }
  18019. else
  18020. {
  18021. //新建一个段落
  18022. Paragraph p = new Paragraph(doc);
  18023. var r = new Run(doc, val);
  18024. //把设置的值赋给之前新建的段落
  18025. p.AppendChild(r);
  18026. //将此段落加到单元格内
  18027. lshCell.AppendChild(p);
  18028. }
  18029. }
  18030. [HttpPost]
  18031. public async Task<IActionResult> ServerHttp(string paramStr)
  18032. {
  18033. paramStr = paramStr.TrimEnd('\'');
  18034. paramStr = paramStr.TrimStart('\'');
  18035. JsonView jw = JsonView(false);
  18036. JObject param = JObject.Parse(paramStr);
  18037. if (!param.ContainsKey("url"))
  18038. {
  18039. jw.Msg = "url null";
  18040. return Ok(jw);
  18041. }
  18042. string url = param["url"]!.ToString();
  18043. var methon = "get";
  18044. Dictionary<string, string> headValues = null;
  18045. string bodyStr = string.Empty;
  18046. if (param.ContainsKey("methon"))
  18047. {
  18048. methon = param["methon"]!.ToString().ToLower();
  18049. }
  18050. if (param.ContainsKey("header"))
  18051. {
  18052. var header = param["header"]!.ToString();
  18053. JObject headerJobject = JObject.Parse(header);
  18054. headValues = new Dictionary<string, string>();
  18055. foreach (JProperty item in headerJobject.Properties())
  18056. {
  18057. var value = item.Value.ToString();
  18058. var head = item.Path;
  18059. headValues.Add(head, value);
  18060. }
  18061. }
  18062. HttpClient client = new HttpClient();
  18063. string responseString = string.Empty;
  18064. StringContent content = null;
  18065. if (headValues != null)
  18066. {
  18067. foreach (var item in headValues.Keys)
  18068. {
  18069. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  18070. {
  18071. if (param.ContainsKey("body"))
  18072. {
  18073. bodyStr = param["body"]!.ToString();
  18074. }
  18075. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  18076. }
  18077. else
  18078. {
  18079. client.DefaultRequestHeaders.Add(item, headValues[item]);
  18080. }
  18081. }
  18082. }
  18083. try
  18084. {
  18085. if (methon == "get")
  18086. {
  18087. responseString = await client.GetStringAsync(url);
  18088. }
  18089. else if (methon == "post")
  18090. {
  18091. var request = new HttpRequestMessage(HttpMethod.Post, url)
  18092. {
  18093. Content = content
  18094. };
  18095. var response = await client.SendAsync(request);
  18096. try
  18097. {
  18098. Stream responseStream = await response.Content.ReadAsStreamAsync();
  18099. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  18100. {
  18101. using (StreamReader reader = new StreamReader(gzipStream))
  18102. {
  18103. responseString = await reader.ReadToEndAsync();
  18104. }
  18105. }
  18106. }
  18107. catch (Exception)
  18108. {
  18109. responseString = await response.Content.ReadAsStringAsync();
  18110. }
  18111. }
  18112. else
  18113. {
  18114. responseString = "methon error";
  18115. }
  18116. jw = JsonView(true, "success", responseString);
  18117. }
  18118. catch (Exception ex)
  18119. {
  18120. jw.Msg = "error " + ex.Message;
  18121. jw.Data = ex.StackTrace;
  18122. }
  18123. finally
  18124. {
  18125. client.Dispose();
  18126. }
  18127. return Ok(jw);
  18128. }
  18129. #endregion
  18130. #region 团组接待意见调查
  18131. /// <summary>
  18132. /// 团组接待意见调查 - 信息管理
  18133. /// 基础数据(团组)
  18134. /// </summary>
  18135. /// <param name="dto"></param>
  18136. /// <returns></returns>
  18137. [HttpGet]
  18138. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18139. public async Task<IActionResult> OpinionaireInit()
  18140. {
  18141. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  18142. .Select(x => new
  18143. {
  18144. x.Id,
  18145. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  18146. })
  18147. .OrderByDescending(x => x.Id)
  18148. .ToListAsync();
  18149. return Ok(JsonView(groupData, groupData.Count));
  18150. }
  18151. /// <summary>
  18152. /// 团组接待意见调查 - 信息管理
  18153. /// 列表
  18154. /// </summary>
  18155. /// <param name="groupId"></param>
  18156. /// <returns></returns>
  18157. [HttpGet("{groupId}")]
  18158. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18159. public async Task<IActionResult> OpinionaireManageList(int groupId)
  18160. {
  18161. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18162. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  18163. .Select(x => new
  18164. {
  18165. x.Id,
  18166. x.TourGuideName,
  18167. x.CityName,
  18168. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  18169. x.CreateTime
  18170. })
  18171. .OrderBy(x => x.Id)
  18172. .ToListAsync();
  18173. return Ok(JsonView(data));
  18174. }
  18175. /// <summary>
  18176. /// 团组接待意见调查 - 信息管理
  18177. /// 保存
  18178. /// </summary>
  18179. /// <param name="dto"></param>
  18180. /// <returns></returns>
  18181. [HttpPost]
  18182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18183. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  18184. {
  18185. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18186. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18187. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18188. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  18189. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  18190. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  18191. _opinionaireRep.BeginTran();
  18192. if (addData != null && addData.Count > 0)
  18193. {
  18194. foreach (var item in addData)
  18195. {
  18196. item.CreateUserId = currUserInfo.UserId;
  18197. item.DiId = dto.DiId;
  18198. }
  18199. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  18200. }
  18201. if (updData != null && updData.Count > 0)
  18202. {
  18203. var upd = await _opinionaireRep._sqlSugar
  18204. .Updateable(updData)
  18205. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  18206. .WhereColumns(x => new { x.Id })
  18207. .ExecuteCommandAsync();
  18208. }
  18209. _opinionaireRep.CommitTran();
  18210. return Ok(JsonView("操作成功!"));
  18211. }
  18212. /// <summary>
  18213. /// 团组接待意见调查 - 信息管理
  18214. /// 删除
  18215. /// </summary>
  18216. /// <param name="id"></param>
  18217. /// <returns></returns>
  18218. [HttpDelete("{id}")]
  18219. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18220. public async Task<IActionResult> OpinionaireManageDel(int id)
  18221. {
  18222. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18223. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18224. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  18225. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  18226. if (!del) return Ok(JsonView("操作失败!"));
  18227. return Ok(JsonView("操作成功!"));
  18228. }
  18229. /// <summary>
  18230. /// 团组接待意见调查 - 用户
  18231. /// 列表
  18232. /// </summary>
  18233. /// <param name="id"></param>
  18234. /// <returns></returns>
  18235. [HttpGet("{diId}")]
  18236. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18237. public async Task<IActionResult> OpinionaireUserList(int diId)
  18238. {
  18239. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18240. var sql = string.Format(@"
  18241. SELECT
  18242. o.Id,
  18243. o.DiId,
  18244. di.TeamName AS 'GroupName',
  18245. di.VisitPNumber AS 'PeopleNumber',
  18246. di.ClientName AS 'LeadGroup',
  18247. di.VisitCountry AS 'Travel',
  18248. di.VisitDays AS 'Days',
  18249. o.CityName,
  18250. o.TourGuideName,
  18251. o.Catering,
  18252. o.CateringReason,
  18253. o.Stay,
  18254. o.StayReason,
  18255. o.[Route],
  18256. o.RouteReason,
  18257. o.OfficialActivity,
  18258. o.OfficialActivityReason,
  18259. o.TourGuide,
  18260. o.TourGuideReason,
  18261. o.[Translate],
  18262. o.TranslateReason,
  18263. o.Trip,
  18264. o.TripReason,
  18265. o.ESFileName,
  18266. o.SignatureDate,
  18267. o.Remark
  18268. FROM
  18269. Grp_Opinionaire o
  18270. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  18271. WHERE
  18272. o.IsDel = 0
  18273. AND o.DiId = {0}
  18274. ORDER BY
  18275. o.Id ASC", diId);
  18276. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  18277. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  18278. return Ok(JsonView(data));
  18279. }
  18280. /// <summary>
  18281. /// 团组接待意见调查 - 用户
  18282. /// 保存
  18283. /// </summary>
  18284. /// <param name="id"></param>
  18285. /// <returns></returns>
  18286. [HttpPost]
  18287. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18288. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  18289. {
  18290. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  18291. foreach (var item in dto)
  18292. {
  18293. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  18294. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  18295. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  18296. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  18297. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  18298. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  18299. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  18300. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  18301. }
  18302. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  18303. if (!Directory.Exists(filePathBase))
  18304. {
  18305. Directory.CreateDirectory(filePathBase);
  18306. }
  18307. #region 上传文件
  18308. var filePaths = new List<string>();
  18309. foreach (var item in dto)
  18310. {
  18311. var file = item.File;
  18312. // 将文件保存到指定位置
  18313. var filePath = Path.Combine(filePathBase, file.FileName);
  18314. using (var stream = new FileStream(filePath, FileMode.Create))
  18315. {
  18316. await file.CopyToAsync(stream);
  18317. }
  18318. //验证文件是否上传成功
  18319. if (!System.IO.File.Exists(filePath))
  18320. {
  18321. foreach (var filePathStr in filePaths)
  18322. {
  18323. System.IO.File.Delete(filePathStr);
  18324. }
  18325. return Ok(JsonView(false, "文件上传失败!"));
  18326. }
  18327. item.ESFileName = file.FileName;
  18328. }
  18329. #endregion
  18330. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  18331. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  18332. .UpdateColumns(x => new
  18333. {
  18334. x.Catering,
  18335. x.CateringReason,
  18336. x.Stay,
  18337. x.StayReason,
  18338. x.Route,
  18339. x.RouteReason,
  18340. x.OfficialActivity,
  18341. x.OfficialActivityReason,
  18342. x.TourGuide,
  18343. x.TourGuideReason,
  18344. x.Translate,
  18345. x.TranslateReason,
  18346. x.Trip,
  18347. x.TripReason,
  18348. x.ESFileName,
  18349. x.SignatureDate,
  18350. x.Remark
  18351. })
  18352. .WhereColumns(x => new { x.Id })
  18353. .ExecuteCommandAsync();
  18354. if (upd < 1)
  18355. {
  18356. foreach (var filePathStr in filePaths)
  18357. {
  18358. System.IO.File.Delete(filePathStr);
  18359. }
  18360. return Ok(JsonView(false));
  18361. }
  18362. return Ok(JsonView(true));
  18363. }
  18364. #endregion
  18365. #region 团组餐厅相关信息
  18366. /// <summary>
  18367. /// 团组相关餐厅信息
  18368. /// 基础数据(团组)
  18369. /// </summary>
  18370. /// <returns></returns>
  18371. [HttpGet]
  18372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18373. public async Task<IActionResult> RestaurantInit()
  18374. {
  18375. return Ok(await _restaurantRep.InitAsync());
  18376. }
  18377. /// <summary>
  18378. /// 团组相关餐厅信息
  18379. /// Item
  18380. /// </summary>
  18381. /// <param name="dto"></param>
  18382. /// <returns></returns>
  18383. [HttpPost]
  18384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18385. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  18386. {
  18387. int portType = dto.PortType,
  18388. groupId = dto.GroupId;
  18389. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false,MsgTips.Port));
  18390. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18391. return Ok(await _restaurantRep.ItemAsync(portType,groupId));
  18392. }
  18393. /// <summary>
  18394. /// 团组相关餐厅信息
  18395. /// List
  18396. /// </summary>
  18397. /// <param name="dto"></param>
  18398. /// <returns></returns>
  18399. [HttpPost]
  18400. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18401. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  18402. {
  18403. int portType = dto.PortType,
  18404. groupId = dto.GroupId;
  18405. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18406. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18407. var sql = string.Format(@" SELECT
  18408. ri.Id,
  18409. ri.GroupId,
  18410. ri.Date,
  18411. ri.StartTime,
  18412. ri.EndTime,
  18413. CASE WHEN ri.Type = 1 THEN '早餐'
  18414. WHEN ri.Type = 2 THEN '午餐'
  18415. WHEN ri.Type = 3 THEN '晚餐'
  18416. ELSE '其他'
  18417. END AS 'Type',
  18418. ri.Name,
  18419. ri.Address,
  18420. ri.Tel,
  18421. ri.Remark,
  18422. ri.CreateTime,
  18423. u.CnName AS CreateUserName
  18424. FROM
  18425. Grp_RestaurantInfo ri
  18426. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  18427. WHERE
  18428. ri.IsDel = 0
  18429. AND ri.GroupId = {0}
  18430. ORDER BY
  18431. ri.Date ASC
  18432. ", groupId);
  18433. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  18434. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  18435. return Ok(JsonView(infos));
  18436. }
  18437. /// <summary>
  18438. /// 团组相关餐厅信息
  18439. /// Info
  18440. /// </summary>
  18441. /// <param name="dto"></param>
  18442. /// <returns></returns>
  18443. [HttpPost]
  18444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18445. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  18446. {
  18447. int portType = dto.PortType,
  18448. id = dto.Id;
  18449. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18450. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18451. return Ok(await _restaurantRep.InfoAsync(portType, id));
  18452. }
  18453. /// <summary>
  18454. /// 团组相关餐厅信息
  18455. /// Op
  18456. /// </summary>
  18457. /// <param name="dto"></param>
  18458. /// <returns></returns>
  18459. [HttpPost]
  18460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18461. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  18462. {
  18463. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18464. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18465. if ( string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  18466. return Ok(await _restaurantRep.OpAsync(dto));
  18467. }
  18468. /// <summary>
  18469. /// 团组相关餐厅信息
  18470. /// Del
  18471. /// </summary>
  18472. /// <param name="dto"></param>
  18473. /// <returns></returns>
  18474. [HttpPost]
  18475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18476. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  18477. {
  18478. int userId = dto.DeleteUserId;
  18479. var id = dto.Id;
  18480. if (userId < 1) return Ok( JsonView(false, MsgTips.UserId));
  18481. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18482. return Ok(await _restaurantRep.DelAsync(dto));
  18483. }
  18484. #endregion
  18485. // /// <summary>
  18486. // ///
  18487. // /// </summary>
  18488. // /// <param name="_dto"></param>
  18489. // /// <returns></returns>
  18490. // [HttpPost]
  18491. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18492. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18493. // {
  18494. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18495. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  18496. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  18497. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18498. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  18499. // dic_psg.Add("客人", 974);
  18500. // dic_psg.Add("司机", 975);
  18501. // dic_psg.Add("导游", 976);
  18502. // dic_psg.Add("公司内部人员", 977);
  18503. // dic_psg.Add("司机/导游/公司内部人员", 978);
  18504. // foreach (var item in list_visa)
  18505. // {
  18506. // Grp_VisaInfo temp = new Grp_VisaInfo();
  18507. // temp.Id = item.Id;
  18508. // temp.DIId = item.DIId;
  18509. // temp.VisaClient = item.VisaClient;
  18510. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  18511. // temp.VisaCurrency = item.VisaCurrency;
  18512. // temp.IsThird = item.IsThird;
  18513. // if (dic_psg.ContainsKey(item.PassengerType))
  18514. // {
  18515. // temp.PassengerType = dic_psg[item.PassengerType];
  18516. // }
  18517. // else {
  18518. // temp.PassengerType = -1;
  18519. // }
  18520. // temp.VisaNumber = item.VisaNumber;
  18521. // temp.VisaFreeNumber = item.VisaFreeNumber;
  18522. // temp.CreateUserId = item.Operators;
  18523. // DateTime dt_ct;
  18524. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  18525. // if (b_ct)
  18526. // {
  18527. // temp.CreateTime = dt_ct;
  18528. // }
  18529. // else
  18530. // {
  18531. // temp.CreateTime = DateTime.Now;
  18532. // }
  18533. // temp.DeleteTime = "";
  18534. // temp.DeleteUserId = 0;
  18535. // temp.Remark = item.Remark;
  18536. // if (string.IsNullOrEmpty(temp.Remark)) {
  18537. // temp.Remark = "";
  18538. // }
  18539. // temp.IsDel = item.IsDel;
  18540. // temp.VisaDescription = item.VisaAttachment;
  18541. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  18542. //([Id]
  18543. // ,[DIId]
  18544. // ,[VisaClient]
  18545. // ,[VisaPrice]
  18546. // ,[VisaCurrency]
  18547. // ,[IsThird]
  18548. // ,[PassengerType]
  18549. // ,[VisaNumber]
  18550. // ,[VisaFreeNumber]
  18551. // ,[CreateUserId]
  18552. // ,[CreateTime]
  18553. // ,[DeleteTime]
  18554. // ,[DeleteUserId]
  18555. // ,[Remark]
  18556. // ,[IsDel]
  18557. // ,[visaDescription])
  18558. // VALUES
  18559. // ({0},{1},'{2}',{3},{4}
  18560. //,{5},{6},{7},{8},{9}
  18561. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  18562. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  18563. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  18564. //);
  18565. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  18566. // }
  18567. // return Ok(JsonView(true, "操作成功!"));
  18568. // }
  18569. /// <summary>
  18570. /// 123132123
  18571. /// </summary>
  18572. /// <param name="_dto"></param>
  18573. /// <returns></returns>
  18574. [HttpPost]
  18575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18576. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18577. {
  18578. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18579. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  18580. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  18581. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18582. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  18583. dicDetail.Add(789, 1034);
  18584. dicDetail.Add(790, 1035);
  18585. dicDetail.Add(791, 1036);
  18586. dicDetail.Add(792, 1037);
  18587. dicDetail.Add(793, 1038);
  18588. dicDetail.Add(794, 1039);
  18589. dicDetail.Add(795, 1040);
  18590. dicDetail.Add(796, 1041);
  18591. dicDetail.Add(797, 1042);
  18592. dicDetail.Add(798, 1043);
  18593. dicDetail.Add(801, 1044);
  18594. dicDetail.Add(802, 1045);
  18595. dicDetail.Add(803, 1046);
  18596. Dictionary<int, int> dic = new Dictionary<int, int>();
  18597. dic.Add(806, 1027);
  18598. dic.Add(807, 1028);
  18599. dic.Add(808, 1029);
  18600. dic.Add(809, 1030);
  18601. dic.Add(810, 1031);
  18602. dic.Add(811, 1032);
  18603. dic.Add(812, 1033);
  18604. foreach (var item in list_visa)
  18605. {
  18606. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  18607. temp.Coefficient = item.coefficient;
  18608. DateTime dtCrt;
  18609. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  18610. if (b1)
  18611. {
  18612. temp.CreateTime = dtCrt;
  18613. }
  18614. else
  18615. {
  18616. temp.CreateTime = DateTime.Now;
  18617. }
  18618. temp.CreateUserId = item.Operators;
  18619. temp.DeleteTime = "";
  18620. temp.DeleteUserId = 0;
  18621. temp.DiId = int.Parse(item.DIID);
  18622. temp.FilePath = item.FilePath;
  18623. temp.IsDel = item.IsDel;
  18624. temp.Price = item.Price;
  18625. temp.PriceCount = 1;
  18626. temp.PriceCurrency = item.Currency;
  18627. int detailId = 0;
  18628. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  18629. {
  18630. detailId = dicDetail[item.PriceTypeDetail];
  18631. }
  18632. temp.PriceDetailType = detailId;
  18633. temp.PriceDt = DateTime.Now;
  18634. temp.PriceName = item.PriceName;
  18635. temp.PriceSum = item.Price;
  18636. int tid = 0;
  18637. if (dic.ContainsKey(item.PriceType))
  18638. {
  18639. tid = dic[item.PriceType];
  18640. }
  18641. temp.PriceType = tid;
  18642. temp.Remark = item.Remark;
  18643. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  18644. }
  18645. return Ok(JsonView(true, "操作成功!"));
  18646. }
  18647. [HttpPost]
  18648. public IActionResult TimeTest()
  18649. {
  18650. var jw = JsonView(false, "error");
  18651. _sqlSugar.BeginTran();
  18652. try
  18653. {
  18654. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  18655. .Select(x => new Crm_NewClientData
  18656. {
  18657. Id = x.Id,
  18658. Client = x.Client,
  18659. Contact = x.Contact,
  18660. Location = x.Location,
  18661. })
  18662. .ToList();
  18663. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x=>x.Id).ToList();
  18664. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  18665. Stopwatch stopwatch = new Stopwatch();
  18666. // 开始计时
  18667. stopwatch.Start();
  18668. foreach (var item in clientList)
  18669. {
  18670. EncryptionProcessor.DecryptProperties(item);
  18671. }
  18672. stopwatch.Stop();
  18673. jw.Code = 200;
  18674. jw.Data = stopwatch.ElapsedMilliseconds;
  18675. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  18676. }
  18677. catch (Exception ex)
  18678. {
  18679. jw.Code = 400;
  18680. jw.Msg = ex.Message;
  18681. }
  18682. return Ok(jw);
  18683. }
  18684. }
  18685. }