GroupsController.cs 1022 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092
  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 MySqlX.XDevAPI.Relational;
  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.Attributes;
  23. using OASystem.Domain.Dtos.CRM;
  24. using OASystem.Domain.Dtos.FileDto;
  25. using OASystem.Domain.Dtos.Financial;
  26. using OASystem.Domain.Dtos.Groups;
  27. using OASystem.Domain.Entities.Customer;
  28. using OASystem.Domain.Entities.Financial;
  29. using OASystem.Domain.Entities.Groups;
  30. using OASystem.Domain.ViewModels.Financial;
  31. using OASystem.Domain.ViewModels.Groups;
  32. using OASystem.Infrastructure.Repositories.CRM;
  33. using OASystem.Infrastructure.Repositories.Financial;
  34. using OASystem.Infrastructure.Repositories.Groups;
  35. using OASystem.Infrastructure.Tools;
  36. using Quartz.Util;
  37. using SqlSugar.Extensions;
  38. using System.Collections;
  39. using System.Data;
  40. using System.Diagnostics;
  41. using System.Globalization;
  42. using System.IO.Compression;
  43. using System.Text.Json;
  44. using TencentCloud.Ocr.V20181119.Models;
  45. using static OASystem.API.OAMethodLib.JWTHelper;
  46. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  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. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  105. /// <summary>
  106. /// 构造函数
  107. /// </summary>
  108. /// <param name="logger"></param>
  109. /// <param name="mapper"></param>
  110. /// <param name="hubContext"></param>
  111. /// <param name="sqlSugar"></param>
  112. /// <param name="grpScheduleRep"></param>
  113. /// <param name="groupRepository"></param>
  114. /// <param name="taskAssignmentRep"></param>
  115. /// <param name="airTicketResRep"></param>
  116. /// <param name="decreasePaymentsRep"></param>
  117. /// <param name="InvitationOfficialActivitiesRep"></param>
  118. /// <param name="delegationEnDataRep"></param>
  119. /// <param name="enterExitCostRep"></param>
  120. /// <param name="delegationVisaRep"></param>
  121. /// <param name="message"></param>
  122. /// <param name="visaPriceRep"></param>
  123. /// <param name="carTouristGuideGroundRep"></param>
  124. /// <param name="checkBoxs"></param>
  125. /// <param name="GroupCostRepository"></param>
  126. /// <param name="CostTypeHotelNumberRepository"></param>
  127. /// <param name="GroupCostParameterRepository"></param>
  128. /// <param name="hotelPriceRep"></param>
  129. /// <param name="customersRep"></param>
  130. /// <param name="setDataRep"></param>
  131. /// <param name="tourClientListRep"></param>
  132. /// <param name="teamRateRep"></param>
  133. /// <param name="usersRep"></param>
  134. /// <param name="juHeApi"></param>
  135. /// <param name="invertedListRep"></param>
  136. /// <param name="visaFeeInfoRep"></param>
  137. /// <param name="ticketBlackCodeRep"></param>
  138. /// <param name="hotelInquiryRep"></param>
  139. /// <param name="threeCodeRepository"></param>
  140. /// <param name="feeAuditRep"></param>
  141. /// <param name="visaCommissionRep"></param>
  142. /// <param name="ffrRep"></param>
  143. /// <param name="opinionaireRep"></param>
  144. /// <param name="tableorRep"></param>
  145. /// <param name="enterExitCostDraftRep"></param>
  146. /// <param name="restaurantRep"></param>
  147. /// <param name="enterExitCostQuoteRep"></param>
  148. public GroupsController(
  149. ILogger<GroupsController> logger,
  150. IMapper mapper,
  151. IHubContext<ChatHub, IChatClient> hubContext,
  152. SqlSugarClient sqlSugar,
  153. GrpScheduleRepository grpScheduleRep,
  154. DelegationInfoRepository groupRepository,
  155. TaskAssignmentRepository taskAssignmentRep,
  156. AirTicketResRepository airTicketResRep,
  157. DecreasePaymentsRepository decreasePaymentsRep,
  158. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  159. DelegationEnDataRepository delegationEnDataRep,
  160. EnterExitCostRepository enterExitCostRep,
  161. DelegationVisaRepository delegationVisaRep,
  162. MessageRepository message,
  163. VisaPriceRepository visaPriceRep,
  164. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  165. CheckBoxsRepository checkBoxs,
  166. GroupCostRepository GroupCostRepository,
  167. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  168. GroupCostParameterRepository GroupCostParameterRepository,
  169. HotelPriceRepository hotelPriceRep,
  170. CustomersRepository customersRep,
  171. SetDataRepository setDataRep,
  172. TourClientListRepository tourClientListRep,
  173. TeamRateRepository teamRateRep,
  174. UsersRepository usersRep, IJuHeApiService juHeApi,
  175. InvertedListRepository invertedListRep,
  176. VisaFeeInfoRepository visaFeeInfoRep,
  177. TicketBlackCodeRepository ticketBlackCodeRep,
  178. HotelInquiryRepository hotelInquiryRep,
  179. ThreeCodeRepository threeCodeRepository,
  180. FeeAuditRepository feeAuditRep,
  181. VisaCommissionRepository visaCommissionRep,
  182. ForeignReceivablesRepository ffrRep,
  183. OpinionaireRepository opinionaireRep,
  184. TableOperationRecordRepository tableorRep,
  185. EnterExitCostDraftRepository enterExitCostDraftRep,
  186. RestaurantRepository restaurantRep,
  187. EnterExitCostQuoteRepository enterExitCostQuoteRep
  188. )
  189. {
  190. _logger = logger;
  191. _mapper = mapper;
  192. _grpScheduleRep = grpScheduleRep;
  193. _groupRepository = groupRepository;
  194. _taskAssignmentRep = taskAssignmentRep;
  195. _airTicketResRep = airTicketResRep;
  196. _sqlSugar = sqlSugar;
  197. url = AppSettingsHelper.Get("ExcelBaseUrl");
  198. path = AppSettingsHelper.Get("ExcelBasePath");
  199. if (!System.IO.Directory.Exists(path))
  200. {
  201. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  202. }
  203. _decreasePaymentsRep = decreasePaymentsRep;
  204. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  205. _delegationEnDataRep = delegationEnDataRep;
  206. _enterExitCostRep = enterExitCostRep;
  207. _delegationVisaRep = delegationVisaRep;
  208. _message = message;
  209. _visaPriceRep = visaPriceRep;
  210. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  211. _checkBoxs = checkBoxs;
  212. _GroupCostRepository = GroupCostRepository;
  213. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  214. _GroupCostParameterRepository = GroupCostParameterRepository;
  215. _hotelPriceRep = hotelPriceRep;
  216. _customersRep = customersRep;
  217. _setDataRep = setDataRep;
  218. _tourClientListRep = tourClientListRep;
  219. _teamRateRep = teamRateRep;
  220. _hubContext = hubContext;
  221. _usersRep = usersRep;
  222. _juHeApi = juHeApi;
  223. _invertedListRep = invertedListRep;
  224. _visaFeeInfoRep = visaFeeInfoRep;
  225. _ticketBlackCodeRep = ticketBlackCodeRep;
  226. _hotelInquiryRep = hotelInquiryRep;
  227. _threeCodeRepository = threeCodeRepository;
  228. _feeAuditRep = feeAuditRep;
  229. _visaCommissionRep = visaCommissionRep;
  230. _ffrRep = ffrRep;
  231. _opinionaireRep = opinionaireRep;
  232. _currencyInit = new List<CurrencyInfo>()
  233. {
  234. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  235. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  236. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  237. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  238. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  239. };
  240. _portTypeData = new List<int>() { 2, 3 };
  241. _tableorRep = tableorRep;
  242. _enterExitCostDraftRep = enterExitCostDraftRep;
  243. _restaurantRep = restaurantRep;
  244. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  245. }
  246. #region 流程管控
  247. /// <summary>
  248. /// 获取团组流程管控信息
  249. /// </summary>
  250. /// <param name="_jsonDto"></param>
  251. /// <returns></returns>
  252. [HttpPost]
  253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  254. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  255. {
  256. if (string.IsNullOrEmpty(_jsonDto.Paras))
  257. {
  258. return Ok(JsonView(false, "参数为空"));
  259. }
  260. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  261. if (_ScheduleDto != null)
  262. {
  263. if (_ScheduleDto.SearchType == 2)//获取列表
  264. {
  265. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  266. return Ok(JsonView(_grpScheduleViewList));
  267. }
  268. else//获取对象
  269. {
  270. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  271. if (_grpScheduleView != null)
  272. {
  273. return Ok(JsonView(_grpScheduleView));
  274. }
  275. }
  276. }
  277. else
  278. {
  279. return Ok(JsonView(false, "参数反序列化失败"));
  280. }
  281. return Ok(JsonView(false, "暂无数据!"));
  282. }
  283. /// <summary>
  284. /// 修改团组流程管控详细表数据
  285. /// </summary>
  286. /// <param name="dto"></param>
  287. /// <returns></returns>
  288. [HttpPost]
  289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  290. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  291. {
  292. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  293. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  294. .SetColumns(it => it.Duty == _detail.Duty)
  295. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  296. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  297. .SetColumns(it => it.JobContent == _detail.JobContent)
  298. .SetColumns(it => it.Remark == _detail.Remark)
  299. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  300. .Where(s => s.Id == dto.Id)
  301. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  302. .ExecuteCommandAsync();
  303. if (result > 0)
  304. {
  305. return Ok(JsonView(true, "保存成功!"));
  306. }
  307. return Ok(JsonView(false, "保存失败!"));
  308. }
  309. /// <summary>
  310. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  311. /// </summary>
  312. /// <param name="dto"></param>
  313. /// <returns></returns>
  314. [HttpPost]
  315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  316. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  317. {
  318. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  319. _detail.IsDel = 1;
  320. _detail.DeleteUserId = dto.Duty;
  321. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  322. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  323. .SetColumns(it => it.IsDel == _detail.IsDel)
  324. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  325. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  326. .Where(it => it.Id == dto.Id)
  327. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  328. //.WhereColumns(s => s.Id == dto.Id)
  329. .ExecuteCommandAsync();
  330. if (result > 0)
  331. {
  332. return Ok(JsonView(true, "删除成功!"));
  333. }
  334. return Ok(JsonView(false, "删除失败!"));
  335. }
  336. /// <summary>
  337. /// 增加团组流程管控详细表数据
  338. /// </summary>
  339. /// <param name="dto"></param>
  340. /// <returns></returns>
  341. [HttpPost]
  342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  343. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  344. {
  345. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  346. if (DateTime.Now < _detail.ExpectBeginDt)
  347. {
  348. _detail.StepStatus = 0;
  349. }
  350. else
  351. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  352. _detail.StepStatus = 1;
  353. }
  354. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  355. if (result > 0)
  356. {
  357. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  358. return Ok(JsonView(true, "添加成功!", _result));
  359. }
  360. return Ok(JsonView(false, "添加失败!"));
  361. }
  362. #endregion
  363. #region 团组基本信息
  364. /// <summary>
  365. /// 接团信息列表
  366. /// </summary>
  367. /// <param name="dto">团组列表请求dto</param>
  368. /// <returns></returns>
  369. [HttpPost]
  370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  371. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  372. {
  373. var groupData = await _groupRepository.GetGroupList(dto);
  374. if (groupData.Code != 0)
  375. {
  376. return Ok(JsonView(false, groupData.Msg));
  377. }
  378. return Ok(JsonView(groupData.Data));
  379. }
  380. /// <summary>
  381. /// 分页查询团组列表
  382. /// </summary>
  383. /// <param name="dto"></param>
  384. /// <returns></returns>
  385. [HttpPost]
  386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  387. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  388. {
  389. var watch = new Stopwatch();
  390. watch.Start();
  391. RefAsync<int> total = 0;
  392. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  393. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  394. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  395. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  396. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  397. .Distinct()
  398. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  399. watch.Stop();
  400. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  401. }
  402. /// <summary>
  403. /// 接团信息列表 Page Init
  404. /// </summary>
  405. /// <returns></returns>
  406. [HttpPost]
  407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  408. public async Task<IActionResult> PostGroupPageListInit()
  409. {
  410. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  411. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  412. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  413. var _view = new
  414. {
  415. depData = depDatas,
  416. rankData = rankDatas
  417. };
  418. return Ok(JsonView(true, "查询成功!", _view));
  419. }
  420. /// <summary>
  421. /// 接团信息列表 Page
  422. /// </summary>
  423. /// <param name="dto">团组列表请求dto</param>
  424. /// <returns></returns>
  425. [HttpPost]
  426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  427. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  428. {
  429. #region 参数验证
  430. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  431. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  432. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  433. #region 页面操作权限验证
  434. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  435. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  436. #endregion
  437. #endregion
  438. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  439. {
  440. string sqlWhere = string.Empty;
  441. if (dto.IsSure == 0) //未完成
  442. {
  443. sqlWhere += string.Format(@" And IsSure = 0");
  444. }
  445. else if (dto.IsSure == 1) //已完成
  446. {
  447. sqlWhere += string.Format(@" And IsSure = 1");
  448. }
  449. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  450. {
  451. string tj = dto.SearchCriteria;
  452. 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}%')",
  453. tj, tj, tj, tj, tj);
  454. }
  455. if (int.TryParse(dto.Rank, out int rankId))
  456. {
  457. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  458. }
  459. string sqlWhere1 = string.Empty;
  460. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  461. {
  462. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  463. }
  464. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  465. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  466. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  467. JietuanOperator,IsSure,CreateTime,IsBid
  468. From (
  469. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  470. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  471. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  472. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  473. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  474. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  475. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  476. From Grp_DelegationInfo gdi
  477. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  478. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  479. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  480. Where gdi.IsDel = 0 {0}
  481. ) temp {1}", sqlWhere, sqlWhere1);
  482. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  483. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  484. var _view = new
  485. {
  486. PageFuncAuth = pageFunAuthView,
  487. Data = _DelegationList
  488. };
  489. return Ok(JsonView(true, "查询成功!", _view, total));
  490. }
  491. else
  492. {
  493. return Ok(JsonView(false, "查询失败"));
  494. }
  495. }
  496. /// <summary>
  497. /// 团组列表
  498. /// </summary>
  499. /// <returns></returns>
  500. [HttpPost]
  501. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  502. {
  503. #region 参数验证
  504. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  505. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  506. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  507. #region 页面操作权限验证
  508. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  509. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  510. #endregion
  511. #endregion
  512. if (dto.PortType != 1 && dto.PortType != 2)
  513. {
  514. return Ok(JsonView(false, "查询失败!"));
  515. }
  516. string orderbyStr = "order by gdi.CreateTime Desc";
  517. string sqlWhere = string.Empty;
  518. if (dto.IsSure == 0) //未完成
  519. {
  520. sqlWhere += string.Format(@" And IsSure = 0");
  521. }
  522. else if (dto.IsSure == 1) //已完成
  523. {
  524. sqlWhere += string.Format(@" And IsSure = 1");
  525. }
  526. //团组类型
  527. if (dto.TeamDid > 0)
  528. {
  529. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  530. }
  531. //团组名称
  532. if (!string.IsNullOrEmpty(dto.TeamName))
  533. {
  534. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  535. }
  536. //客户名称
  537. if (!string.IsNullOrEmpty(dto.ClientName))
  538. {
  539. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  540. }
  541. //客户单位
  542. if (!string.IsNullOrEmpty(dto.ClientUnit))
  543. {
  544. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  545. }
  546. //出访时间
  547. if (!string.IsNullOrEmpty(dto.visitDataTime))
  548. {
  549. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  550. orderbyStr = "order by gdi.VisitDate";
  551. }
  552. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  553. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  554. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  555. JietuanOperator,IsSure,CreateTime
  556. From (
  557. Select row_number() over({0}) as Row_Number,
  558. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  559. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  560. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  561. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  562. From Grp_DelegationInfo gdi
  563. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  564. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  565. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  566. Where gdi.IsDel = 0 {1}
  567. ) temp ", orderbyStr, sqlWhere);
  568. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  569. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  570. #region 处理所属部门
  571. /*
  572. * 1.sq 和 gyy 等显示 市场部
  573. * 2.王鸽和主管及张总还有管理员号统一国交部
  574. * 2-1. 4 管理员 ,21 张海麟
  575. */
  576. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  577. List<int> userIds1 = new List<int>() { 4, 21 };
  578. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  579. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  580. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  581. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  582. .ToList();
  583. foreach (var item in _DelegationList)
  584. {
  585. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  586. }
  587. #endregion
  588. var _view = new
  589. {
  590. PageFuncAuth = pageFunAuthView,
  591. Data = _DelegationList
  592. };
  593. return Ok(JsonView(true, "查询成功!", _view, total));
  594. }
  595. /// <summary>
  596. /// 接团信息详情
  597. /// </summary>
  598. /// <param name="dto">团组info请求dto</param>
  599. /// <returns></returns>
  600. [HttpPost]
  601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  602. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  603. {
  604. var groupData = await _groupRepository.GetGroupInfo(dto);
  605. if (groupData.Code != 0)
  606. {
  607. return Ok(JsonView(false, groupData.Msg));
  608. }
  609. return Ok(JsonView(groupData.Data));
  610. }
  611. /// <summary>
  612. /// 接团信息 编辑添加
  613. /// 基础信息数据源
  614. /// </summary>
  615. /// <param name="dto"></param>
  616. /// <returns></returns>
  617. [HttpPost]
  618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  619. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  620. {
  621. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  622. if (groupData.Code != 0)
  623. {
  624. return Ok(JsonView(false, groupData.Msg));
  625. }
  626. return Ok(JsonView(groupData.Data));
  627. }
  628. /// <summary>
  629. /// 接团信息 操作(增改)
  630. /// </summary>
  631. /// <param name="dto"></param>
  632. /// <returns></returns>
  633. [HttpPost]
  634. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  635. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  636. {
  637. // 创建 Stopwatch 实例
  638. Stopwatch stopwatch = Stopwatch.StartNew();
  639. decimal ffrPrice = 0.00M;
  640. DateTime? visitDt = null;
  641. if (dto.Status == 2)
  642. {
  643. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  644. if (groupInfo != null)
  645. {
  646. ffrPrice = groupInfo.PaymentMoney;
  647. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  648. }
  649. }
  650. var groupData = await _groupRepository.GroupOperation(dto);
  651. if (groupData.Code != 0)
  652. {
  653. return Ok(JsonView(false, groupData.Msg));
  654. }
  655. int diId = 0;
  656. try
  657. {
  658. //添加时 默认加入团组汇率
  659. if (dto.Status == 1) //添加
  660. {
  661. diId = groupData.Data;
  662. //添加默认币种
  663. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  664. //默认分配权限
  665. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  666. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  667. var _managerIds = new List<int>() { 22, 32, 21 };
  668. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  669. if (userIds.Count > 0)
  670. {
  671. userIds.Add(208);
  672. //创建团组管控
  673. GroupStepForDelegation.CreateWorkStep(diId);
  674. //发送消息
  675. string groupName = dto.TeamName;
  676. string createGroupUser = string.Empty;
  677. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  678. if (userInfo != null) createGroupUser = userInfo.CnName;
  679. string title = $"系统通知";
  680. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  681. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  682. }
  683. //默认创建倒推表
  684. await _invertedListRep._Create(dto.UserId, diId);
  685. }
  686. else if (dto.Status == 2)
  687. {
  688. diId = dto.Id;
  689. }
  690. #region 签证人员团组时间通知
  691. #region 计算出访起止时间
  692. var startTime = new DateTime();
  693. var endTime = new DateTime();
  694. if (DateTime.TryParse(dto.VisitDate, out startTime))
  695. {
  696. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  697. }
  698. #endregion
  699. #endregion
  700. #region 团组操作默认添加/修改收款账单
  701. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  702. {
  703. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  704. .Where(x => x.IsDel == 0 &&
  705. x.Diid == diId &&
  706. x.Remark.Equals("预付款")
  707. )
  708. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  709. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  710. .FirstAsync();
  711. ffrInfo = new Fin_ForeignReceivables()
  712. {
  713. Diid = diId,
  714. PriceName = dto.ClientUnit,
  715. Price = dto.PaymentMoney,
  716. Count = 1,
  717. Unit = $"元",
  718. ItemSumPrice = dto.PaymentMoney,
  719. Rate = 1.0000M,
  720. Currency = 836,
  721. AddingWay = 0,
  722. CreateUserId = dto.UserId,
  723. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  724. Remark = $"预付款"
  725. };
  726. if (ffrInfo == null) //Add
  727. {
  728. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  729. }
  730. else //修改
  731. {
  732. await _sqlSugar.Updateable(ffrInfo)
  733. .UpdateColumns(x => new
  734. {
  735. x.PriceName,
  736. x.Price,
  737. x.ItemSumPrice,
  738. x.CreateTime,
  739. x.CreateUserId
  740. })
  741. .WhereColumns(x => x.Id)
  742. .ExecuteCommandAsync();
  743. }
  744. }
  745. #endregion
  746. if (diId > 0)
  747. {
  748. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  749. }
  750. // 停止计时
  751. stopwatch.Stop();
  752. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  753. }
  754. catch (Exception ex)
  755. {
  756. // 停止计时
  757. stopwatch.Stop();
  758. Logs("[response]" + JsonConvert.SerializeObject(dto));
  759. Logs(ex.Message);
  760. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  761. }
  762. // 停止计时
  763. stopwatch.Stop();
  764. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  765. }
  766. /// <summary>
  767. /// 接团流程操作(增改)
  768. /// 安卓端使用 建团时添加客户名单
  769. /// </summary>
  770. /// <param name="dto"></param>
  771. /// <returns></returns>
  772. [HttpPost]
  773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  774. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  775. {
  776. #region 参数验证
  777. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  778. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  779. #region 页面操作权限验证
  780. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  781. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  782. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  783. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  784. #endregion
  785. #endregion
  786. try
  787. {
  788. //_sqlSugar.BeginTran();
  789. decimal ffrPrice = 0.00M;
  790. DateTime? visitDt = null;
  791. if (dto.Status == 2)
  792. {
  793. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  794. if (groupInfo != null)
  795. {
  796. ffrPrice = groupInfo.PaymentMoney;
  797. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  798. }
  799. }
  800. var _dto = new GroupOperationDto();
  801. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  802. var groupData = await _groupRepository.GroupOperation(_dto);
  803. if (groupData.Code != 0)
  804. {
  805. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  806. }
  807. int diId = 0;
  808. //添加时 默认加入团组汇率
  809. if (dto.Status == 1) //添加
  810. {
  811. diId = groupData.Data;
  812. //添加默认币种
  813. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  814. //默认分配权限
  815. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  816. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  817. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  818. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  819. if (userIds.Count > 0)
  820. {
  821. userIds.Add(208);
  822. //创建团组管控
  823. GroupStepForDelegation.CreateWorkStep(diId);
  824. //发送消息
  825. string groupName = dto.TeamName;
  826. string createGroupUser = string.Empty;
  827. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  828. if (userInfo != null) createGroupUser = userInfo.CnName;
  829. string title = $"系统通知";
  830. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  831. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  832. }
  833. #region 应用推送
  834. try
  835. {
  836. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  837. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  838. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  839. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  840. {
  841. List<string> userList = new List<string>() { users.QiyeChatUserId };
  842. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  843. }
  844. }
  845. catch (Exception ex)
  846. {
  847. }
  848. #endregion
  849. //默认创建倒推表
  850. await _invertedListRep._Create(dto.UserId, diId);
  851. }
  852. if (dto.Status == 2)
  853. {
  854. diId = dto.Id;
  855. if (diId == 0)
  856. {
  857. //_sqlSugar.RollbackTran();
  858. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  859. }
  860. }
  861. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  862. if (viewData.Code != 0)
  863. {
  864. //_sqlSugar.RollbackTran();
  865. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  866. }
  867. #region 团组操作默认添加/修改收款账单
  868. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  869. {
  870. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  871. .Where(x => x.IsDel == 0 &&
  872. x.Diid == diId &&
  873. x.Remark.Equals("预付款")
  874. )
  875. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  876. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  877. .FirstAsync();
  878. ffrInfo = new Fin_ForeignReceivables()
  879. {
  880. Diid = diId,
  881. PriceName = dto.ClientUnit,
  882. Price = dto.PaymentMoney,
  883. Count = 1,
  884. Unit = $"元",
  885. ItemSumPrice = dto.PaymentMoney,
  886. Rate = 1.0000M,
  887. Currency = 836,
  888. AddingWay = 0,
  889. CreateUserId = dto.UserId,
  890. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  891. Remark = $"预付款"
  892. };
  893. if (ffrInfo == null) //Add
  894. {
  895. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  896. }
  897. else //修改
  898. {
  899. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  900. .UpdateColumns(x => new
  901. {
  902. x.PriceName,
  903. x.Price,
  904. x.ItemSumPrice,
  905. x.CreateTime,
  906. x.CreateUserId
  907. })
  908. .WhereColumns(x => x.Id)
  909. .ExecuteCommandAsync();
  910. }
  911. }
  912. #endregion
  913. #region 签证人员团组时间通知
  914. #region 计算出访起止时间
  915. var startTime = new DateTime();
  916. var endTime = new DateTime();
  917. if (DateTime.TryParse(dto.VisitDate, out startTime))
  918. {
  919. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  920. }
  921. #endregion
  922. if (diId > 0)
  923. {
  924. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  925. }
  926. #endregion
  927. //_sqlSugar.CommitTran();
  928. return Ok(JsonView(true, "添加成功"));
  929. }
  930. catch (Exception ex)
  931. {
  932. _sqlSugar.RollbackTran();
  933. return Ok(JsonView(false, ex.Message));
  934. }
  935. }
  936. /// <summary>
  937. /// 接团流程操作(增改)
  938. /// 安卓端使用 建团时添加客户名单
  939. /// </summary>
  940. /// <param name="dto"></param>
  941. /// <returns></returns>
  942. [HttpPost]
  943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  944. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  945. {
  946. #region 参数验证
  947. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  948. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  949. #region 页面操作权限验证
  950. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  951. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  952. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  953. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  954. #endregion
  955. #endregion
  956. _sqlSugar.BeginTran();
  957. decimal ffrPrice = 0.00M;
  958. DateTime? visitDt = null;
  959. if (dto.Status == 2)
  960. {
  961. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  962. if (groupInfo != null)
  963. {
  964. ffrPrice = groupInfo.PaymentMoney;
  965. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  966. }
  967. }
  968. var _dto = new GroupOperationDto();
  969. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  970. var groupData = await _groupRepository.GroupOperation(_dto);
  971. if (groupData.Code != 0)
  972. {
  973. _sqlSugar.RollbackTran();
  974. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  975. }
  976. try
  977. {
  978. int diId = 0;
  979. //添加时 默认加入团组汇率
  980. if (dto.Status == 1) //添加
  981. {
  982. diId = groupData.Data;
  983. //添加默认币种
  984. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  985. //默认分配权限
  986. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  987. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  988. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  989. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  990. if (userIds.Count > 0)
  991. {
  992. userIds.Add(208);
  993. //创建团组管控
  994. GroupStepForDelegation.CreateWorkStep(diId);
  995. //发送消息
  996. string groupName = dto.TeamName;
  997. string createGroupUser = string.Empty;
  998. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  999. if (userInfo != null) createGroupUser = userInfo.CnName;
  1000. string title = $"系统通知";
  1001. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1002. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1003. }
  1004. #region 应用推送
  1005. try
  1006. {
  1007. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1008. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1009. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1010. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1011. {
  1012. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1013. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1014. }
  1015. }
  1016. catch (Exception ex)
  1017. {
  1018. _sqlSugar.CommitTran();
  1019. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1020. }
  1021. #endregion
  1022. //默认创建倒推表
  1023. await _invertedListRep._Create(dto.UserId, diId);
  1024. }
  1025. else if (dto.Status == 2)
  1026. {
  1027. diId = dto.Id;
  1028. if (diId == 0)
  1029. {
  1030. _sqlSugar.RollbackTran();
  1031. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1032. }
  1033. }
  1034. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1035. if (viewData.Code != 0)
  1036. {
  1037. _sqlSugar.RollbackTran();
  1038. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1039. }
  1040. #region 团组操作默认添加/修改收款账单
  1041. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1042. {
  1043. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1044. .Where(x => x.IsDel == 0 &&
  1045. x.Diid == diId &&
  1046. x.Remark.Equals("预付款")
  1047. )
  1048. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1049. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1050. .FirstAsync();
  1051. ffrInfo = new Fin_ForeignReceivables()
  1052. {
  1053. Diid = diId,
  1054. PriceName = dto.ClientUnit,
  1055. Price = dto.PaymentMoney,
  1056. Count = 1,
  1057. Unit = $"元",
  1058. ItemSumPrice = dto.PaymentMoney,
  1059. Rate = 1.0000M,
  1060. Currency = 836,
  1061. AddingWay = 0,
  1062. CreateUserId = dto.UserId,
  1063. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1064. Remark = $"预付款"
  1065. };
  1066. if (ffrInfo == null) //Add
  1067. {
  1068. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1069. }
  1070. else //修改
  1071. {
  1072. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1073. .UpdateColumns(x => new
  1074. {
  1075. x.PriceName,
  1076. x.Price,
  1077. x.ItemSumPrice,
  1078. x.CreateTime,
  1079. x.CreateUserId
  1080. })
  1081. .WhereColumns(x => x.Id)
  1082. .ExecuteCommandAsync();
  1083. }
  1084. }
  1085. #endregion
  1086. #region 签证人员团组时间通知
  1087. #region 计算出访起止时间
  1088. var startTime = new DateTime();
  1089. var endTime = new DateTime();
  1090. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1091. {
  1092. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1093. }
  1094. #endregion
  1095. if (diId > 0)
  1096. {
  1097. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1098. }
  1099. #endregion
  1100. _sqlSugar.CommitTran();
  1101. return Ok(JsonView(true));
  1102. }
  1103. catch (Exception ex)
  1104. {
  1105. _sqlSugar.RollbackTran();
  1106. return Ok(JsonView(false, ex.Message));
  1107. }
  1108. }
  1109. /// <summary>
  1110. /// 接团信息 操作(删除)
  1111. /// </summary>
  1112. /// <param name="dto"></param>
  1113. /// <returns></returns>
  1114. [HttpPost]
  1115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1116. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1117. {
  1118. var diId = dto.Id;
  1119. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1120. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1121. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1122. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1123. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1124. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1125. #endregion
  1126. var groupData = await _groupRepository.GroupDel(dto);
  1127. if (groupData.Code != 0)
  1128. {
  1129. return Ok(JsonView(false, groupData.Msg));
  1130. }
  1131. return Ok(JsonView(true));
  1132. }
  1133. /// <summary>
  1134. /// 获取团组销售报价号
  1135. /// 团组添加时 使用
  1136. /// </summary>
  1137. /// <returns></returns>
  1138. [HttpPost]
  1139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1140. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1141. {
  1142. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1143. if (groupData.Code != 0)
  1144. {
  1145. return Ok(JsonView(false, groupData.Msg));
  1146. }
  1147. object salesQuoteNo = new
  1148. {
  1149. SalesQuoteNo = groupData.Data
  1150. };
  1151. return Ok(JsonView(salesQuoteNo));
  1152. }
  1153. /// <summary>
  1154. /// 设置确认出团
  1155. /// </summary>
  1156. /// <param name="dto"></param>
  1157. /// <returns></returns>
  1158. [HttpPost]
  1159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1160. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1161. {
  1162. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1163. if (groupData.Code != 0)
  1164. {
  1165. return Ok(JsonView(false, groupData.Msg));
  1166. }
  1167. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1168. #region OA消息推送
  1169. try
  1170. {
  1171. string groupName = groupInfo.TeamName;
  1172. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1173. string title = $"系统通知";
  1174. string content = $"团组[{groupName}]已确认出团!";
  1175. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1176. }
  1177. catch (Exception ex)
  1178. {
  1179. }
  1180. #endregion
  1181. #region 应用推送
  1182. try
  1183. {
  1184. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1185. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1186. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1187. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1188. {
  1189. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1190. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1191. }
  1192. }
  1193. catch (Exception ex)
  1194. {
  1195. }
  1196. #endregion
  1197. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1198. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1199. }
  1200. /// <summary>
  1201. /// 获取团组名称data And 签证国别Data
  1202. /// </summary>
  1203. /// <param name="dto"></param>
  1204. /// <returns></returns>
  1205. [HttpPost]
  1206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1207. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1208. {
  1209. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1210. if (groupData.Code != 0)
  1211. {
  1212. return Ok(JsonView(false, groupData.Msg));
  1213. }
  1214. return Ok(JsonView(groupData.Data));
  1215. }
  1216. /// <summary>
  1217. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1218. /// </summary>
  1219. /// <returns></returns>
  1220. [HttpPost]
  1221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1222. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1223. {
  1224. try
  1225. {
  1226. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1227. if (groupData.Code != 0)
  1228. {
  1229. return Ok(JsonView(false, groupData.Msg));
  1230. }
  1231. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1232. }
  1233. catch (Exception ex)
  1234. {
  1235. return Ok(JsonView(false, "程序错误!"));
  1236. throw;
  1237. }
  1238. }
  1239. /// <summary>
  1240. /// 团组清单 Excel
  1241. /// </summary>
  1242. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1243. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1244. /// <returns></returns>
  1245. [HttpGet]
  1246. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1247. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1248. {
  1249. DateTime _beginDt, _endDt;
  1250. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1251. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1252. if (!beginBool && !endBool)
  1253. {
  1254. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1255. }
  1256. string sql = string.Format(@"
  1257. SELECT
  1258. ROW_NUMBER,
  1259. Id,
  1260. SalesQuoteNo,
  1261. TourCode,
  1262. TeamTypeId,
  1263. TeamType,
  1264. TeamLevId,
  1265. TeamLev,
  1266. TeamName,
  1267. ClientName,
  1268. ClientUnit,
  1269. VisitDate,
  1270. VisitDays,
  1271. VisitPNumber,
  1272. JietuanOperatorId,
  1273. JietuanOperator,
  1274. IsSure,
  1275. CreateUserName,
  1276. IsBid
  1277. FROM
  1278. (
  1279. SELECT
  1280. ROW_NUMBER() OVER(
  1281. ORDER BY
  1282. gdi.CreateTime Desc
  1283. ) AS ROW_NUMBER,
  1284. gdi.Id,
  1285. SalesQuoteNo,
  1286. TourCode,
  1287. ssd.Id TeamTypeId,
  1288. ssd.Name TeamType,
  1289. ssd1.Id TeamLevId,
  1290. ssd1.Name TeamLev,
  1291. TeamName,
  1292. ClientName,
  1293. ClientUnit,
  1294. VisitDate,
  1295. VisitDays,
  1296. VisitPNumber,
  1297. JietuanOperator JietuanOperatorId,
  1298. su.CnName JietuanOperator,
  1299. IsSure,
  1300. gdi.CreateTime,
  1301. su1.CnName As CreateUserName,
  1302. gdi.IsBid
  1303. FROM
  1304. Grp_DelegationInfo gdi
  1305. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1306. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1307. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1308. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1309. WHERE
  1310. gdi.IsDel = 0
  1311. AND gdi.IsBid = 0
  1312. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1313. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1314. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1315. #region 处理所属部门
  1316. /*
  1317. * 1.sq 和 gyy 等显示 市场部
  1318. * 2.王鸽和主管及张总还有管理员号统一国交部
  1319. * 2-1. 4 管理员 ,21 张海麟
  1320. */
  1321. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1322. List<int> userIds1 = new List<int>() { 4, 21 };
  1323. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1324. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1325. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1326. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1327. .ToListAsync();
  1328. var droupIds = groupList.Select(it => it.Id).ToList();
  1329. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1330. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1331. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1332. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1333. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1334. {
  1335. DiId = tcl.DiId,
  1336. LastName = dc.LastName,
  1337. FirstName = dc.FirstName,
  1338. Sex = dc.Sex,
  1339. Birthday = dc.BirthDay,
  1340. Company = cc.CompanyFullName,
  1341. Job = dc.Job,
  1342. CreateTime = tcl.CreateTime,
  1343. })
  1344. .ToList();
  1345. foreach (var item in groupList)
  1346. {
  1347. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1348. string groupFirstName = "";
  1349. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1350. if (currDatas.Any())
  1351. {
  1352. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1353. }
  1354. item.GroupFirst = groupFirstName;
  1355. }
  1356. #endregion
  1357. #region Excel
  1358. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1359. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1360. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1361. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1362. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1363. //载入模板
  1364. WorkbookDesigner designer = new WorkbookDesigner();
  1365. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1366. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1367. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1368. dt.TableName = "GroupList";
  1369. designer.SetDataSource(dt);
  1370. designer.Process();
  1371. if (!Directory.Exists(savePath))
  1372. {
  1373. Directory.CreateDirectory(savePath);
  1374. }
  1375. string serverPath = $"{savePath}{fileName}";
  1376. designer.Workbook.Save(serverPath);
  1377. string rst = $"{servicePath}{ftpPath}{fileName}";
  1378. #endregion
  1379. return Ok(JsonView(true, "操作成功!", rst));
  1380. }
  1381. #endregion
  1382. #region 团组&签证
  1383. /// <summary>
  1384. /// 根据团组Id获取签证客户信息List
  1385. /// </summary>
  1386. /// <param name="dto">请求dto</param>
  1387. /// <returns></returns>
  1388. [HttpPost]
  1389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1390. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1391. {
  1392. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1393. if (groupData.Code != 0)
  1394. {
  1395. return Ok(JsonView(false, groupData.Msg));
  1396. }
  1397. return Ok(JsonView(groupData.Data));
  1398. }
  1399. /// <summary>
  1400. /// IOS获取团组签证拍照上传进度01(团组列表)
  1401. /// </summary>
  1402. /// <param name="dto">请求dto</param>
  1403. /// <returns></returns>
  1404. [HttpPost]
  1405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1406. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1407. {
  1408. if (dto == null)
  1409. {
  1410. return Ok(JsonView(false, "参数为空"));
  1411. }
  1412. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1413. return Ok(JsonView(visaList));
  1414. }
  1415. /// <summary>
  1416. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1417. /// </summary>
  1418. /// <returns></returns>
  1419. [HttpPost]
  1420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1421. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1422. {
  1423. if (dto == null)
  1424. {
  1425. return Ok(JsonView(false, "请求错误:"));
  1426. }
  1427. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1428. return Ok(JsonView(list));
  1429. }
  1430. /// <summary>
  1431. /// IOS获取团组签证拍照上传进度03(相册)
  1432. /// </summary>
  1433. /// <returns></returns>
  1434. [HttpPost]
  1435. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1436. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1437. {
  1438. if (dto == null)
  1439. {
  1440. return Ok(JsonView(false, "请求错误:"));
  1441. }
  1442. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1443. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1444. list.ForEach(s => s.url = url);
  1445. return Ok(JsonView(list));
  1446. }
  1447. /// <summary>
  1448. /// IOS获取团组签证拍照上传进度04(图片上传)
  1449. /// </summary>
  1450. /// <param name="dto"></param>
  1451. /// <returns></returns>
  1452. [HttpPost]
  1453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1454. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1455. {
  1456. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1457. //if (!string.IsNullOrEmpty(result))
  1458. //{
  1459. //}
  1460. //else {
  1461. // return Ok(JsonView(false, "上传失败"));
  1462. //}
  1463. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1464. int sucNum = 0;
  1465. try
  1466. {
  1467. foreach (var item in dto.base64DataList)
  1468. {
  1469. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1470. string result = DecodeBase64ToImage(item, imageName);
  1471. if (!string.IsNullOrEmpty(result))
  1472. {
  1473. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1474. pic.CreateUserId = dto.CreateUserId;
  1475. pic.PicName = imageName;
  1476. pic.PicPath = result;
  1477. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1478. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1479. if (insertResult > 0)
  1480. {
  1481. sucNum++;
  1482. }
  1483. }
  1484. }
  1485. }
  1486. catch (Exception ex)
  1487. {
  1488. return Ok(JsonView(false, ex.Message));
  1489. }
  1490. string msg = string.Format(@"成功上传{0}张", sucNum);
  1491. return Ok(JsonView(true, msg));
  1492. }
  1493. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  1494. {
  1495. string filename = "";//声明一个string类型的相对路径
  1496. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1497. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1498. try//会有异常抛出,try,catch一下
  1499. {
  1500. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1501. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1502. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1503. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1504. //文件名称
  1505. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1506. //上传的文件的路径
  1507. string filePath = "";
  1508. if (!Directory.Exists(fileDir))
  1509. {
  1510. Directory.CreateDirectory(fileDir);
  1511. }
  1512. //上传的文件的路径
  1513. filePath = fileDir + filename;
  1514. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1515. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1516. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1517. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1518. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1519. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1520. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1521. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1522. bitmap.Dispose();
  1523. }
  1524. catch (Exception e)
  1525. {
  1526. string massage = e.Message;
  1527. Logs("IOS图片上传Error:" + massage);
  1528. //filename = e.Message;
  1529. }
  1530. return filename;//返回相对路径
  1531. }
  1532. /// <summary>
  1533. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1534. /// </summary>
  1535. /// <param name="dto"></param>
  1536. /// <returns></returns>
  1537. [HttpPost]
  1538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1539. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1540. {
  1541. if (dto == null)
  1542. {
  1543. return Ok(JsonView(false, "请求错误:"));
  1544. }
  1545. string msg = "参数错误";
  1546. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1547. {
  1548. try
  1549. {
  1550. //_delegationVisaRep.BeginTran();
  1551. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1552. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1553. .Where(s => s.Id == dto.visaProgressCustomerId)
  1554. .ExecuteCommandAsync();
  1555. if (updCount > 0 && dto.publishCode == 1)
  1556. {
  1557. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1558. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1559. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1560. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1561. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1562. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1563. if (groupData == null)
  1564. {
  1565. _delegationVisaRep.RollbackTran();
  1566. }
  1567. string title = string.Format(@"[签证进度更新]");
  1568. string content = string.Format(@"测试文本");
  1569. bool rst = await _message.AddMsg(new MessageDto()
  1570. {
  1571. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1572. IssuerId = dto.publisher,
  1573. Title = title,
  1574. Content = content,
  1575. ReleaseTime = DateTime.Now,
  1576. UIdList = new List<int> {
  1577. 234
  1578. }
  1579. });
  1580. if (rst)
  1581. {
  1582. return Ok(JsonView(true, "发送通知成功"));
  1583. }
  1584. }
  1585. //_delegationVisaRep.CommitTran();
  1586. }
  1587. catch (Exception)
  1588. {
  1589. //_delegationVisaRep.RollbackTran();
  1590. }
  1591. }
  1592. return Ok(JsonView(true, msg));
  1593. }
  1594. #endregion
  1595. #region 团组任务分配
  1596. /// <summary>
  1597. /// 团组任务分配初始化
  1598. /// </summary>
  1599. /// <returns></returns>
  1600. [HttpPost]
  1601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1602. public async Task<IActionResult> GetTaskAssignmen()
  1603. {
  1604. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1605. if (groupData.Code != 0)
  1606. {
  1607. return Ok(JsonView(false, groupData.Msg));
  1608. }
  1609. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1610. }
  1611. /// <summary>
  1612. /// 团组任务分配查询
  1613. /// </summary>
  1614. /// <param name="dto"></param>
  1615. /// <returns></returns>
  1616. [HttpPost]
  1617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1618. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1619. {
  1620. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1621. if (groupData.Code != 0)
  1622. {
  1623. return Ok(JsonView(false, groupData.Msg));
  1624. }
  1625. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1626. }
  1627. /// <summary>
  1628. /// 团组任务分配操作
  1629. /// </summary>
  1630. /// <param name="dto"></param>
  1631. /// <returns></returns>
  1632. [HttpPost]
  1633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1634. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1635. {
  1636. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1637. if (groupData.Code != 0)
  1638. {
  1639. return Ok(JsonView(false, groupData.Msg));
  1640. }
  1641. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1642. }
  1643. /// <summary>
  1644. /// 团组任务分配
  1645. /// 批量分配
  1646. /// 查询团组
  1647. /// </summary>
  1648. /// <param name="dto"></param>
  1649. /// <returns></returns>
  1650. [HttpPost]
  1651. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1652. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1653. {
  1654. //参数验证
  1655. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1656. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1657. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1658. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1659. }
  1660. /// <summary>
  1661. /// 团组任务分配
  1662. /// 批量分配
  1663. /// </summary>
  1664. /// <param name="dto"></param>
  1665. /// <returns></returns>
  1666. [HttpPost]
  1667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1668. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1669. {
  1670. //参数验证
  1671. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1672. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1673. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1674. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1675. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1676. }
  1677. #endregion
  1678. #region 团组费用审核
  1679. /// <summary>
  1680. /// 费用审核
  1681. /// 团组列表 Page
  1682. /// </summary>
  1683. /// <param name="_dto">团组列表请求dto</param>
  1684. /// <returns></returns>
  1685. [HttpPost]
  1686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1687. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1688. {
  1689. #region 参数验证
  1690. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1691. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1692. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1693. #region 页面操作权限验证
  1694. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1695. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1696. #endregion
  1697. #endregion
  1698. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1699. {
  1700. string sqlWhere = string.Empty;
  1701. if (_dto.IsSure == 0) //未完成
  1702. {
  1703. sqlWhere += string.Format(@" And IsSure = 0");
  1704. }
  1705. else if (_dto.IsSure == 1) //已完成
  1706. {
  1707. sqlWhere += string.Format(@" And IsSure = 1");
  1708. }
  1709. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1710. {
  1711. string tj = _dto.SearchCriteria;
  1712. 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}%')",
  1713. tj, tj, tj, tj, tj);
  1714. }
  1715. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1716. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1717. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1718. From (
  1719. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1720. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1721. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1722. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1723. From Grp_DelegationInfo gdi
  1724. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1725. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1726. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1727. Where gdi.IsDel = 0 {0}
  1728. ) temp ", sqlWhere);
  1729. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1730. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1731. var _view = new
  1732. {
  1733. PageFuncAuth = pageFunAuthView,
  1734. Data = _DelegationList
  1735. };
  1736. return Ok(JsonView(true, "查询成功!", _view, total));
  1737. }
  1738. else
  1739. {
  1740. return Ok(JsonView(false, "查询失败"));
  1741. }
  1742. }
  1743. /// <summary>
  1744. /// 获取团组费用审核
  1745. /// </summary>
  1746. /// <param name="_dto"></param>
  1747. /// <returns></returns>
  1748. [HttpPost]
  1749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1750. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1751. {
  1752. try
  1753. {
  1754. #region 参数验证
  1755. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1756. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1757. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1758. #region 页面操作权限验证
  1759. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1760. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1761. #endregion
  1762. #endregion
  1763. var _view = new Grp_CreditCardPaymentView();
  1764. var clientNameList = getSimplClientList(_dto.DiId);
  1765. #region 费用清单
  1766. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1767. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1768. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1769. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1770. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1771. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1772. /*
  1773. * 76://酒店预订
  1774. */
  1775. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1776. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1777. /*
  1778. * 79://车/导游地接
  1779. */
  1780. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1781. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1782. /*
  1783. * 80: //签证
  1784. */
  1785. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1786. /*
  1787. *81: //邀请/公务活动
  1788. */
  1789. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1790. /*
  1791. * 82: //团组客户保险
  1792. */
  1793. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1794. /*
  1795. * Lable = 85 机票预订
  1796. */
  1797. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1798. /*
  1799. * 85 机票预定
  1800. */
  1801. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1802. /*
  1803. * 98 其他款项
  1804. */
  1805. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1806. /*
  1807. * 285:收款退还
  1808. */
  1809. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1810. /*
  1811. * 1015: //超支费用
  1812. */
  1813. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1814. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1815. /*
  1816. * 币种信息
  1817. */
  1818. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  1819. /*
  1820. * 车/导游地接 费用类型
  1821. */
  1822. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  1823. /*
  1824. * 车/导游地接 费用类型
  1825. */
  1826. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  1827. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1828. /*
  1829. * 用户信息
  1830. */
  1831. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  1832. /*
  1833. * 费用模块
  1834. */
  1835. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  1836. string priceModule = string.Empty;
  1837. if (sdPriceName != null)
  1838. {
  1839. priceModule = sdPriceName.Name;
  1840. }
  1841. /*
  1842. * 成本信息
  1843. */
  1844. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1845. decimal _groupRate = 0.0000M;
  1846. string _groupCurrencyCode = "-";
  1847. if (groupCost != null)
  1848. {
  1849. _groupRate = groupCost.Rate;
  1850. if (int.TryParse(groupCost.Currency, out int _currency))
  1851. {
  1852. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1853. }
  1854. else _groupCurrencyCode = groupCost.Currency;
  1855. }
  1856. string costContentSql = $"Select * From Grp_GroupCost";
  1857. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1858. //处理日期为空的天数
  1859. for (int i = 0; i < groupCostDetails.Count; i++)
  1860. if (i != 0)
  1861. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1862. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1863. /*
  1864. * 处理详情数据
  1865. */
  1866. foreach (var entity in entityList)
  1867. {
  1868. var _detail = new Grp_CreditCardPaymentDetailView();
  1869. _detail.Id = entity.Id;
  1870. _detail.PriceName = priceModule;
  1871. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1872. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1873. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1874. //处理金额
  1875. if (entity.CTable == 1015)
  1876. {
  1877. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1878. if (czInfo != null)
  1879. {
  1880. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1881. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1882. }
  1883. }
  1884. /*
  1885. * 应付款金额
  1886. */
  1887. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1888. string PaymentCurrency_WaitPay = "Unknown";
  1889. string hotelCurrncyCode = "Unknown";
  1890. string hotelCurrncyName = "Unknown";
  1891. if (sdPaymentCurrency_WaitPay != null)
  1892. {
  1893. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1894. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1895. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1896. if (hotelCurrncyCode.Equals("CNY"))
  1897. {
  1898. entity.DayRate = 1.0000M;
  1899. }
  1900. }
  1901. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1902. /*
  1903. * 此次付款金额
  1904. */
  1905. decimal CurrPayStr = 0.00M,
  1906. OriginalCurrPay = 0.00M;
  1907. if (entity.PayPercentage == 0)
  1908. {
  1909. if (entity.PayThenMoney != 0)
  1910. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1911. }
  1912. else
  1913. {
  1914. if (entity.PayMoney != 0)
  1915. {
  1916. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1917. }
  1918. }
  1919. //if (_dto.Label == 79)
  1920. //{
  1921. // string original = string.Empty;
  1922. // if (hotelCurrncyCode.Equals("CNY"))
  1923. // {
  1924. // OriginalCurrPay = CurrPayStr;
  1925. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1926. // }
  1927. // else
  1928. // {
  1929. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1930. // //760 EUR(7600.00 CNY)
  1931. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1932. // }
  1933. //}
  1934. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1935. string original = string.Empty;
  1936. if (hotelCurrncyCode.Equals("CNY"))
  1937. {
  1938. OriginalCurrPay = CurrPayStr;
  1939. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1940. }
  1941. else
  1942. {
  1943. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1944. //760 EUR(7600.00 CNY)
  1945. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1946. }
  1947. /*
  1948. * 剩余尾款
  1949. */
  1950. decimal BalanceStr = 0;
  1951. if (CurrPayStr != 0)
  1952. {
  1953. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1954. BalanceStr = 0;
  1955. else
  1956. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1957. }
  1958. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1959. /*
  1960. * Bus名称
  1961. */
  1962. _detail.BusName = "待增加";
  1963. /*
  1964. *费用所属
  1965. */
  1966. switch (entity.CTable)
  1967. {
  1968. case 76://酒店预订
  1969. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1970. if (hotelReservations != null)
  1971. {
  1972. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1973. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1974. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1975. string roomFeeStr = "", roomFeestr1 = "";
  1976. //是否比较房型价格
  1977. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1978. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1979. roomFeeStr += $"<br/>";
  1980. var roomTotal = 0.00M;
  1981. if (hotelReservations.SingleRoomPrice > 0)
  1982. {
  1983. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  1984. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1985. //__isSingle = true;
  1986. roomTotal += fee;
  1987. }
  1988. if (hotelReservations.DoubleRoomPrice > 0)
  1989. {
  1990. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  1991. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1992. // __isDouble = true;
  1993. roomTotal += fee;
  1994. }
  1995. if (hotelReservations.SuiteRoomPrice > 0)
  1996. {
  1997. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  1998. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1999. //__isSuite = true;
  2000. roomTotal += fee;
  2001. }
  2002. if (hotelReservations.OtherRoomPrice > 0)
  2003. {
  2004. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2005. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2006. //__isOther = true;
  2007. roomTotal += fee;
  2008. }
  2009. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2010. else roomFeeStr += " 0.00 * 0";
  2011. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2012. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2013. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2014. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2015. /*
  2016. * 费用类型
  2017. * 1:房费
  2018. * 2:早餐
  2019. * 3:地税
  2020. * 4:城市税
  2021. * </summary>
  2022. */
  2023. //地税
  2024. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2025. if (governmentRentData != null)
  2026. {
  2027. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2028. governmentRentFee = governmentRentData.Price;
  2029. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2030. if (governmentRentCurrData != null)
  2031. {
  2032. governmentRentCode = governmentRentCurrData.Name;
  2033. governmentRentName = $"({governmentRentCurrData.Remark})";
  2034. }
  2035. }
  2036. //城市税
  2037. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2038. if (cityTaxData != null)
  2039. {
  2040. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2041. cityTaxFee = cityTaxData.Price;
  2042. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2043. if (cityTaxCurrData != null)
  2044. {
  2045. cityTaxCode = cityTaxCurrData.Name;
  2046. cityTaxName = $"({cityTaxCurrData.Remark})";
  2047. }
  2048. }
  2049. //酒店早餐
  2050. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2051. if (breakfastData != null)
  2052. {
  2053. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2054. breakfastFee = breakfastData.Price;
  2055. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2056. if (breakfastCurrData != null)
  2057. {
  2058. breakfastCode = breakfastCurrData.Name;
  2059. breakfastName = $"({breakfastCurrData.Remark})";
  2060. }
  2061. }
  2062. //房间费用
  2063. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2064. if (roomData != null)
  2065. {
  2066. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2067. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2068. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2069. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2070. roomFee = roomData.Price;
  2071. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2072. if (roomCurrData != null)
  2073. {
  2074. roomCode = roomCurrData.Name;
  2075. roomName = $"({roomCurrData.Remark})";
  2076. }
  2077. }
  2078. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2079. string hotelCostStr = "";
  2080. decimal hotelCsotTotal = 0.00M;
  2081. if (groupCost != null)
  2082. {
  2083. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2084. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2085. }
  2086. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2087. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2088. string hotelCost_day = "";
  2089. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2090. foreach (var item in hotelCostDetails1)
  2091. {
  2092. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2093. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2094. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2095. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2096. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2097. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2098. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2099. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2100. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2101. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2102. hotelCost_day += @$"<br/>";
  2103. }
  2104. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2105. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2106. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2107. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2108. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2109. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2110. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2111. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2112. $"房间说明: {hotelReservations.Remark} <br/>" +
  2113. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2114. $"{hotelBreakfastStr}" +
  2115. $"{hotelGovernmentRentStr}" +
  2116. $"{hotelCityTaxStr}";
  2117. _detail.PriceNameContent = hotelReservations.HotelName;
  2118. }
  2119. break;
  2120. case 79://车/导游地接
  2121. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2122. if (touristGuideGroundReservations != null)
  2123. {
  2124. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2125. {
  2126. _detail.BusName = touristGuideGroundReservations.BusName;
  2127. }
  2128. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2129. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2130. //if (isInt)
  2131. //{
  2132. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2133. // if (cityInfo != null)
  2134. // {
  2135. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2136. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2137. // if (carFeeItem != null)
  2138. // {
  2139. // nameContent += $@"({carFeeItem.Name})";
  2140. // }
  2141. // _detail.PriceNameContent = nameContent;
  2142. // }
  2143. //}
  2144. //else
  2145. //{
  2146. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2147. //}
  2148. var touristGuideGroundReservationsContents =
  2149. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2150. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2151. foreach (var item in touristGuideGroundReservationsContents)
  2152. {
  2153. string typeName = "Unknown";
  2154. string carCurrencyCode = "Unknown";
  2155. string carCurrencyName = "Unknown";
  2156. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2157. if (carTypeData != null) typeName = carTypeData.Name;
  2158. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2159. if (currencyData != null)
  2160. {
  2161. carCurrencyCode = currencyData.Name;
  2162. carCurrencyName = currencyData.Remark;
  2163. }
  2164. //op、成本 币种是否一致
  2165. bool IsCurrencyAgreement = false;
  2166. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2167. string opCostStr = string.Empty;
  2168. decimal opCostTypePrice = 0.00M;
  2169. #region 处理成本各项费用
  2170. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2171. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2172. if (opCost.Count > 0)
  2173. {
  2174. switch (item.SId)
  2175. {
  2176. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2177. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2178. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2179. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2180. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2181. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2182. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2183. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2184. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2185. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2186. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2187. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2188. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2189. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2190. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2191. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2192. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2193. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2194. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2195. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2196. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2197. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2198. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2199. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2200. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2201. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2202. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2203. }
  2204. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2205. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2206. }
  2207. #endregion
  2208. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2209. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2210. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2211. $"{opTypeStr} {opCostStr}<br/>" +
  2212. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2213. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2214. }
  2215. _detail.PriceMsgContent = priceMsg;
  2216. }
  2217. break;
  2218. case 80: //签证
  2219. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2220. if (visaInfo != null)
  2221. {
  2222. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2223. _detail.PriceNameContent = visaInfo.VisaDescription;
  2224. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2225. }
  2226. break;
  2227. case 81: //邀请/公务活动
  2228. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2229. if (_ioa != null)
  2230. {
  2231. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2232. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2233. sendCurrName = "Unknown", //快递费用币种 Name
  2234. sendCurrCode = "Unknown", //快递费用币种 Code
  2235. eventsCurrName = "Unknown", //公务活动费币种 Name
  2236. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2237. translateCurrName = "Unknown", //公务翻译费 Name
  2238. translateCurrCode = "Unknown"; //公务翻译费 Code
  2239. #region 处理费用币种
  2240. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2241. if (inviteCurrData != null)
  2242. {
  2243. inviteCurrName = inviteCurrData.Remark;
  2244. inviteCurrCode = inviteCurrData.Name;
  2245. }
  2246. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2247. if (sendCurrData != null)
  2248. {
  2249. sendCurrName = sendCurrData.Remark;
  2250. sendCurrCode = sendCurrData.Name;
  2251. }
  2252. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2253. if (eventsCurrData != null)
  2254. {
  2255. eventsCurrName = eventsCurrData.Remark;
  2256. eventsCurrCode = eventsCurrData.Name;
  2257. }
  2258. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2259. if (translateCurrData != null)
  2260. {
  2261. translateCurrName = translateCurrData.Remark;
  2262. translateCurrCode = translateCurrData.Name;
  2263. }
  2264. #endregion
  2265. _detail.PriceNameContent = _ioa.InviterArea;
  2266. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2267. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2268. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2269. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2270. $@"备注:" + _ioa.Remark + "<br/>";
  2271. }
  2272. break;
  2273. case 82: //团组客户保险
  2274. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2275. if (customers != null)
  2276. {
  2277. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2278. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2279. }
  2280. break;
  2281. case 85: //机票预订
  2282. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2283. if (jpRes != null)
  2284. {
  2285. string FlightsDescription = jpRes.FlightsDescription;
  2286. string PriceDescription = jpRes.PriceDescription;
  2287. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2288. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2289. }
  2290. break;
  2291. case 98://其他款项
  2292. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2293. if (gdpRes != null)
  2294. {
  2295. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2296. _detail.PriceNameContent = gdpRes.PriceName;
  2297. }
  2298. break;
  2299. case 285://收款退还
  2300. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2301. if (refundAndOtherMoney != null)
  2302. {
  2303. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2304. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2305. }
  2306. break;
  2307. case 751://酒店早餐
  2308. break;
  2309. case 1015://超支费用
  2310. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2311. if (groupExtraCost != null)
  2312. {
  2313. _detail.PriceNameContent = groupExtraCost.PriceName;
  2314. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2315. }
  2316. break;
  2317. default:
  2318. break;
  2319. }
  2320. /*
  2321. * 申请人
  2322. */
  2323. string operatorName = " - ";
  2324. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2325. if (_opUser != null)
  2326. {
  2327. operatorName = _opUser.CnName;
  2328. }
  2329. _detail.OperatorName = operatorName;
  2330. /*
  2331. * 审核人
  2332. */
  2333. string auditOperatorName = "Unknown";
  2334. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2335. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2336. else
  2337. {
  2338. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2339. if (_adUser != null)
  2340. {
  2341. auditOperatorName = _adUser.CnName;
  2342. }
  2343. }
  2344. _detail.AuditOperatorName = auditOperatorName;
  2345. /*
  2346. * 超预算比例
  2347. */
  2348. string overBudgetStr = "";
  2349. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2350. else if (entity.ExceedBudget == 0)
  2351. {
  2352. if (entity.CTable == 76 || entity.CTable == 79)
  2353. {
  2354. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2355. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2356. }
  2357. else
  2358. {
  2359. overBudgetStr = "未超预算";
  2360. }
  2361. }
  2362. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2363. _detail.OverBudget = overBudgetStr;
  2364. decimal auditFee = 0.00M; //已审核金额 人名币
  2365. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2366. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2367. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2368. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2369. {
  2370. auditedFeeOriginal = entity.PayMoney;
  2371. auditFee = CurrPayStr;
  2372. }
  2373. else if (entity.IsAuditGM == 0)
  2374. {
  2375. unAuditFeeCNY = CurrPayStr;
  2376. unAuditFeeOriginal = OriginalCurrPay;
  2377. OriginalCurrPay = 0.00M;
  2378. }
  2379. /*
  2380. * 费用总计
  2381. */
  2382. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2383. {
  2384. CurrencyId = entity.PaymentCurrency,
  2385. CurrencyName = PaymentCurrency_WaitPay,
  2386. AmountPayable = entity.PayMoney,
  2387. ThisPayment = OriginalCurrPay,
  2388. BalancePayment = BalanceStr,
  2389. AuditedFunds = auditFee,
  2390. AuditedFundsOriginal = auditedFeeOriginal,
  2391. UnAuditFundsCNY = unAuditFeeCNY,
  2392. UnAuditFundsOriginal = unAuditFeeOriginal
  2393. });
  2394. _detail.IsAuditGM = entity.IsAuditGM;
  2395. detailList.Add(_detail);
  2396. }
  2397. #endregion
  2398. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2399. /*
  2400. * 下方描述处理
  2401. */
  2402. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2403. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2404. if (ccpCurrencyPrice != null)
  2405. {
  2406. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2407. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2408. }
  2409. else
  2410. {
  2411. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2412. }
  2413. string amountPayableStr = string.Format(@"应付款总金额: ");
  2414. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2415. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2416. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2417. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2418. foreach (var item in nonDuplicat)
  2419. {
  2420. var currencyName = item.CurrencyName;
  2421. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2422. if (strs.Count > 0)
  2423. {
  2424. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2425. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2426. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2427. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2428. //单独处理此次付款金额
  2429. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2430. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2431. //单独处理已审核费用
  2432. //if (item.CurrencyId == 836) //人民币
  2433. //{
  2434. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2435. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2436. //}
  2437. //else
  2438. //{
  2439. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2440. //}
  2441. if (currencyName.Equals("CNY"))
  2442. {
  2443. //已审核费用
  2444. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2445. //未审核费用
  2446. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2447. }
  2448. else
  2449. {
  2450. //已审核费用
  2451. 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"));
  2452. //未审核费用
  2453. 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"));
  2454. }
  2455. }
  2456. }
  2457. _view.TotalStr1 = amountPayableStr[..^1];
  2458. _view.TotalStr2 = thisPaymentStr[..^1];
  2459. _view.TotalStr3 = balancePaymentStr[..^1];
  2460. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  2461. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2462. var _view1 = new
  2463. {
  2464. PageFuncAuth = pageFunAuthView,
  2465. Data = _view
  2466. };
  2467. return Ok(JsonView(_view1));
  2468. }
  2469. catch (Exception ex)
  2470. {
  2471. return Ok(JsonView(false, ex.Message));
  2472. }
  2473. }
  2474. /// <summary>
  2475. /// 费用审核
  2476. /// 修改团组费用审核状态
  2477. /// </summary>
  2478. /// <param name="_dto">参数Json字符串</param>
  2479. /// <returns></returns>
  2480. [HttpPost]
  2481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2482. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2483. {
  2484. #region 参数验证
  2485. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2486. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2487. #endregion
  2488. #region 页面操作权限验证
  2489. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2490. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2491. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2492. #endregion
  2493. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2494. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2495. DateTime dtNow = DateTime.Now;
  2496. _groupRepository.BeginTran();
  2497. int rst = 0;
  2498. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2499. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2500. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2501. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2502. List<dynamic> msgDatas = new List<dynamic>();
  2503. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2504. foreach (var item in idList)
  2505. {
  2506. int CreditId = int.Parse(item);
  2507. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2508. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2509. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2510. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2511. .Where(s => s.Id == CreditId)
  2512. .ExecuteCommandAsync();
  2513. if (result < 1)
  2514. {
  2515. rst = -1;
  2516. _groupRepository.RollbackTran();
  2517. return Ok(JsonView(false, "操作失败并回滚!"));
  2518. }
  2519. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2520. if (creditData != null)
  2521. {
  2522. #region 应用通知配置
  2523. try
  2524. {
  2525. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2526. }
  2527. catch (Exception ex)
  2528. {
  2529. }
  2530. #endregion
  2531. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2532. string groupNameStr = string.Empty;
  2533. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2534. if (groupData != null) groupNameStr = groupData.TeamName;
  2535. string creditTypeStr = string.Empty;
  2536. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2537. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2538. string creditCurrency = string.Empty;
  2539. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2540. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2541. if (creditCurrency.Equals("CNY"))
  2542. {
  2543. creditData.DayRate = 1.0000M;
  2544. }
  2545. if (creditData.PayPercentage == 0.00M)
  2546. {
  2547. creditData.PayPercentage = 100M;
  2548. }
  2549. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2550. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2551. string msgContent = "";
  2552. if (creditCurrency.Equals("CNY"))
  2553. {
  2554. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2555. }
  2556. else
  2557. {
  2558. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2559. }
  2560. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2561. }
  2562. }
  2563. if (rst == 0)
  2564. {
  2565. _groupRepository.CommitTran();
  2566. foreach (var item in msgDatas)
  2567. {
  2568. //发送消息
  2569. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2570. }
  2571. #region 应用推送
  2572. try
  2573. {
  2574. foreach (var ccpId in dic_ccp_user.Keys)
  2575. {
  2576. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2577. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2578. }
  2579. }
  2580. catch (Exception)
  2581. {
  2582. }
  2583. #endregion
  2584. return Ok(JsonView(true, "操作成功!"));
  2585. }
  2586. return Ok(JsonView(false, "操作失败!"));
  2587. }
  2588. #endregion
  2589. #region 机票费用录入
  2590. /// <summary>
  2591. /// 机票录入当前登录人可操作团组
  2592. /// </summary>
  2593. /// <param name="dto"></param>
  2594. /// <returns></returns>
  2595. [HttpPost]
  2596. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2597. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2598. {
  2599. try
  2600. {
  2601. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2602. if (groupData.Code != 0)
  2603. {
  2604. return Ok(JsonView(false, groupData.Msg));
  2605. }
  2606. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2607. }
  2608. catch (Exception ex)
  2609. {
  2610. return Ok(JsonView(false, "程序错误!"));
  2611. throw;
  2612. }
  2613. }
  2614. /// <summary>
  2615. /// 机票费用录入列表
  2616. /// </summary>
  2617. /// <param name="dto"></param>
  2618. /// <returns></returns>
  2619. [HttpPost]
  2620. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2621. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2622. {
  2623. try
  2624. {
  2625. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2626. if (groupData.Code != 0)
  2627. {
  2628. return Ok(JsonView(false, groupData.Msg));
  2629. }
  2630. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2631. }
  2632. catch (Exception ex)
  2633. {
  2634. return Ok(JsonView(false, ex.Message));
  2635. throw;
  2636. }
  2637. }
  2638. /// <summary>
  2639. /// 根据id查询费用录入信息
  2640. /// </summary>
  2641. /// <param name="dto"></param>
  2642. /// <returns></returns>
  2643. [HttpPost]
  2644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2645. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2646. {
  2647. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2648. if (groupData.Code != 0)
  2649. {
  2650. return Ok(JsonView(false, groupData.Msg));
  2651. }
  2652. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2653. }
  2654. /// <summary>
  2655. /// 机票费用录入操作(Status:1.新增,2.修改)
  2656. /// </summary>
  2657. /// <param name="dto"></param>
  2658. /// <returns></returns>
  2659. [HttpPost]
  2660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2661. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2662. {
  2663. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2664. if (groupData.Code != 0)
  2665. {
  2666. return Ok(JsonView(false, groupData.Msg));
  2667. }
  2668. #region 应用推送
  2669. try
  2670. {
  2671. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2672. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2673. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2674. //2024-10-21 新增LZ UID
  2675. var userIds = new List<int>() { 21 };
  2676. string title = $"系统通知";
  2677. string content = "";
  2678. var diId = dto.AirTicketResOpData.DiId;
  2679. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2680. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2681. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2682. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2683. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2684. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2685. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2686. }
  2687. catch (Exception ex)
  2688. {
  2689. }
  2690. #endregion
  2691. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2692. }
  2693. /// <summary>
  2694. /// 根据舱位类型查询接团客户名单信息
  2695. /// </summary>
  2696. /// <param name="dto"></param>
  2697. /// <returns></returns>
  2698. [HttpPost]
  2699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2700. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2701. {
  2702. try
  2703. {
  2704. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2705. if (crm_Groups.Count != 0)
  2706. {
  2707. List<dynamic> Customer = new List<dynamic>();
  2708. foreach (var item in crm_Groups)
  2709. {
  2710. var data = new
  2711. {
  2712. Id = item.Id,
  2713. Pinyin = item.Pinyin,
  2714. Name = item.LastName + item.FirstName
  2715. };
  2716. Customer.Add(data);
  2717. }
  2718. return Ok(JsonView(true, "查询成功!", Customer));
  2719. }
  2720. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2721. }
  2722. catch (Exception ex)
  2723. {
  2724. return Ok(JsonView(false, "程序错误!"));
  2725. throw;
  2726. }
  2727. }
  2728. /// <summary>
  2729. /// 根据团号获取客户信息
  2730. /// </summary>
  2731. /// <param name="dto"></param>
  2732. /// <returns></returns>
  2733. [HttpPost]
  2734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2735. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2736. {
  2737. var jw = JsonView(false);
  2738. if (dto.DIID < 1)
  2739. {
  2740. jw.Msg += "请输入正确的diid";
  2741. return Ok(jw);
  2742. }
  2743. var arr = getSimplClientList(dto.DIID);
  2744. jw = JsonView(true, "获取成功!", arr);
  2745. return Ok(jw);
  2746. }
  2747. private List<SimplClientInfo> getSimplClientList(int diId)
  2748. {
  2749. 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);
  2750. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2751. foreach (var item in arr)
  2752. {
  2753. EncryptionProcessor.DecryptProperties(item);
  2754. }
  2755. return arr;
  2756. }
  2757. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2758. {
  2759. string result = origin;
  2760. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2761. {
  2762. string[] temparr = origin.Split(',');
  2763. string fistrStr = temparr[0];
  2764. int count = temparr.Count();
  2765. int tempId;
  2766. bool success = int.TryParse(fistrStr, out tempId);
  2767. if (success)
  2768. {
  2769. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2770. if (tempInfo != null)
  2771. {
  2772. if (count > 1)
  2773. {
  2774. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2775. }
  2776. else
  2777. {
  2778. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2779. }
  2780. }
  2781. }
  2782. }
  2783. return result;
  2784. }
  2785. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2786. {
  2787. string result = origin;
  2788. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2789. {
  2790. string[] temparr = origin.Split(',');
  2791. result = "";
  2792. foreach (var item in temparr)
  2793. {
  2794. int tempId;
  2795. bool success = int.TryParse(item, out tempId);
  2796. if (success)
  2797. {
  2798. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2799. if (tempInfo != null)
  2800. {
  2801. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2802. }
  2803. }
  2804. }
  2805. }
  2806. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2807. return result;
  2808. }
  2809. /// <summary>
  2810. /// 机票费用录入,删除
  2811. /// </summary>
  2812. /// <param name="dto"></param>
  2813. /// <returns></returns>
  2814. [HttpPost]
  2815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2816. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2817. {
  2818. try
  2819. {
  2820. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2821. if (res)
  2822. {
  2823. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2824. {
  2825. IsDel = 1,
  2826. DeleteUserId = dto.DeleteUserId,
  2827. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2828. }).ExecuteCommandAsync();
  2829. return Ok(JsonView(true, "删除成功!"));
  2830. }
  2831. return Ok(JsonView(false, "删除失败!"));
  2832. }
  2833. catch (Exception ex)
  2834. {
  2835. return Ok(JsonView(false, "程序错误!"));
  2836. throw;
  2837. }
  2838. }
  2839. /// <summary>
  2840. /// 导出机票录入报表
  2841. /// </summary>
  2842. /// <param name="dto"></param>
  2843. /// <returns></returns>
  2844. [HttpPost]
  2845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2846. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2847. {
  2848. try
  2849. {
  2850. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2851. if (groupData.Code != 0)
  2852. {
  2853. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2854. }
  2855. else
  2856. {
  2857. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2858. if (AirTicketReservations.Count != 0)
  2859. {
  2860. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2861. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2862. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2863. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2864. WorkbookDesigner designer = new WorkbookDesigner();
  2865. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2866. decimal countCost = 0;
  2867. foreach (var item in AirTicketReservations)
  2868. {
  2869. #region 处理客人姓名
  2870. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2871. item.ClientName = clientNames;
  2872. #endregion
  2873. if (item.BankType == "其他")
  2874. {
  2875. item.BankNo = "--";
  2876. }
  2877. else
  2878. {
  2879. if (!string.IsNullOrEmpty(item.BankType))
  2880. {
  2881. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2882. }
  2883. }
  2884. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2885. item.Price = System.Decimal.Round(item.Price, 2);
  2886. countCost += Convert.ToDecimal(item.Price);
  2887. }
  2888. designer.SetDataSource("Export", AirTicketReservations);
  2889. designer.SetDataSource("ExportDiCode", diCode);
  2890. designer.SetDataSource("ExportDiName", diName);
  2891. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2892. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2893. designer.Process();
  2894. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2895. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2896. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2897. return Ok(JsonView(true, "成功", url = rst));
  2898. }
  2899. else
  2900. {
  2901. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2902. }
  2903. }
  2904. }
  2905. catch (Exception ex)
  2906. {
  2907. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2908. throw;
  2909. }
  2910. }
  2911. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2912. /// <summary>
  2913. /// 行程单导出
  2914. /// </summary>
  2915. /// <param name="dto"></param>
  2916. /// <returns></returns>
  2917. [HttpPost]
  2918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2919. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2920. {
  2921. try
  2922. {
  2923. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2924. if (groupData.Code != 0)
  2925. {
  2926. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2927. }
  2928. else
  2929. {
  2930. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2931. if (dto.Language == "CN")
  2932. {
  2933. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2934. DocumentBuilder builder = new DocumentBuilder(doc);
  2935. int tableIndex = 0;//表格索引
  2936. //得到文档中的第一个表格
  2937. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2938. foreach (var item in _AirTicketReservations)
  2939. {
  2940. #region 处理固定数据
  2941. string[] FlightsCode = item.FlightsCode.Split('/');
  2942. if (FlightsCode.Length != 0)
  2943. {
  2944. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2945. if (_AirCompany != null)
  2946. {
  2947. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2948. }
  2949. else
  2950. {
  2951. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2952. }
  2953. }
  2954. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2955. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2956. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2957. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2958. string name = "";
  2959. foreach (string clientName in nameArray)
  2960. {
  2961. if (!name.Contains(clientName))
  2962. {
  2963. name += clientName + ",";
  2964. }
  2965. }
  2966. if (!string.IsNullOrWhiteSpace(name))
  2967. {
  2968. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2969. }
  2970. else
  2971. {
  2972. table.Range.Bookmarks["ClientName"].Text = "--";
  2973. }
  2974. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2975. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2976. table.Range.Bookmarks["JointTicket"].Text = "--";
  2977. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2978. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2979. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2980. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2981. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2982. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2983. #endregion
  2984. #region 循环数据处理
  2985. List<AirInfo> airs = new List<AirInfo>();
  2986. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2987. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2988. for (int i = 0; i < FlightsCode.Length; i++)
  2989. {
  2990. AirInfo air = new AirInfo();
  2991. string[] tempstr = DayArray[i]
  2992. .Replace("\r\n", string.Empty)
  2993. .Replace("\\r\\n", string.Empty)
  2994. .TrimStart().TrimEnd()
  2995. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2996. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2997. string starCity = "";
  2998. if (star_Three != null)
  2999. {
  3000. starCity = star_Three.AirPort;
  3001. }
  3002. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3003. string EndCity = "";
  3004. if (End_Three != null)
  3005. {
  3006. EndCity = End_Three.AirPort;
  3007. }
  3008. air.Destination = starCity + "/" + EndCity;
  3009. air.Flight = FlightsCode[i];
  3010. air.SeatingClass = item.CTypeName;
  3011. string dateTime = tempstr[2];
  3012. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3013. air.FlightDate = DateTemp;
  3014. air.DepartureTime = tempstr[5];
  3015. air.LandingTime = tempstr[6];
  3016. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3017. air.TicketStatus = "--";
  3018. air.Luggage = "--";
  3019. air.DepartureTerminal = "--";
  3020. air.LandingTerminal = "--";
  3021. airs.Add(air);
  3022. }
  3023. int row = 13;
  3024. for (int i = 0; i < airs.Count; i++)
  3025. {
  3026. if (airs.Count > 2)
  3027. {
  3028. for (int j = 0; j < airs.Count - 2; j++)
  3029. {
  3030. var CopyRow = table.Rows[12].Clone(true);
  3031. table.Rows.Add(CopyRow);
  3032. }
  3033. }
  3034. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3035. int index = 0;
  3036. foreach (PropertyInfo property in properties)
  3037. {
  3038. string value = property.GetValue(airs[i]).ToString();
  3039. Cell ishcel0 = table.Rows[row].Cells[index];
  3040. Paragraph p = new Paragraph(doc);
  3041. string s = value;
  3042. p.AppendChild(new Run(doc, s));
  3043. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3044. ishcel0.AppendChild(p);
  3045. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3046. index++;
  3047. }
  3048. row++;
  3049. }
  3050. #endregion
  3051. Paragraph lastParagraph = new Paragraph(doc);
  3052. //第一个表格末尾加段落
  3053. table.ParentNode.InsertAfter(lastParagraph, table);
  3054. //复制第一个表格
  3055. Table cloneTable = (Table)table.Clone(true);
  3056. //在文档末尾段落后面加入复制的表格
  3057. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3058. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3059. {
  3060. int rownewsIndex = 13;
  3061. for (int i = 0; i < 2; i++)
  3062. {
  3063. var CopyRow = table.Rows[12].Clone(true);
  3064. table.Rows.RemoveAt(13);
  3065. table.Rows.Add(CopyRow);
  3066. rownewsIndex++;
  3067. }
  3068. }
  3069. else
  3070. {
  3071. table.Rows.RemoveAt(12);
  3072. }
  3073. cloneTable.Rows.RemoveAt(12);
  3074. }
  3075. if (_AirTicketReservations.Count != 0)
  3076. {
  3077. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3078. if (FlightsCode.Length != 0)
  3079. {
  3080. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3081. if (_AirCompany != null)
  3082. {
  3083. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3084. }
  3085. else
  3086. {
  3087. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3088. }
  3089. }
  3090. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3091. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3092. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3093. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3094. string name = "";
  3095. foreach (string clientName in nameArray)
  3096. {
  3097. if (!name.Contains(clientName))
  3098. {
  3099. name += clientName + ",";
  3100. }
  3101. }
  3102. if (!string.IsNullOrWhiteSpace(name))
  3103. {
  3104. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3105. }
  3106. else
  3107. {
  3108. table.Range.Bookmarks["ClientName"].Text = "--";
  3109. }
  3110. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3111. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3112. table.Range.Bookmarks["JointTicket"].Text = "--";
  3113. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3114. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3115. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3116. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3117. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3118. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3119. }
  3120. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3121. //保存合并后的文档
  3122. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3123. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3124. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3125. return Ok(JsonView(true, "成功!", rst));
  3126. }
  3127. else
  3128. {
  3129. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3130. DocumentBuilder builder = new DocumentBuilder(doc);
  3131. int tableIndex = 0;//表格索引
  3132. //得到文档中的第一个表格
  3133. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3134. List<string> texts = new List<string>();
  3135. foreach (var item in _AirTicketReservations)
  3136. {
  3137. string[] FlightsCode = item.FlightsCode.Split('/');
  3138. if (FlightsCode.Length != 0)
  3139. {
  3140. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3141. if (_AirCompany != null)
  3142. {
  3143. if (!transDic.ContainsKey(_AirCompany.CnName))
  3144. {
  3145. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3146. }
  3147. }
  3148. else
  3149. {
  3150. if (!transDic.ContainsKey("--"))
  3151. {
  3152. transDic.Add("--", "--");
  3153. }
  3154. }
  3155. }
  3156. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3157. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3158. string name = "";
  3159. foreach (string clientName in nameArray)
  3160. {
  3161. name += clientName + ",";
  3162. }
  3163. if (!texts.Contains(name))
  3164. {
  3165. texts.Add(name);
  3166. }
  3167. List<AirInfo> airs = new List<AirInfo>();
  3168. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3169. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3170. for (int i = 0; i < FlightsCode.Length; i++)
  3171. {
  3172. AirInfo air = new AirInfo();
  3173. string[] tempstr = DayArray[i]
  3174. .Replace("\r\n", string.Empty)
  3175. .Replace("\\r\\n", string.Empty)
  3176. .TrimStart().TrimEnd()
  3177. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3178. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3179. if (star_Three != null)
  3180. {
  3181. if (!transDic.ContainsKey(star_Three.AirPort))
  3182. {
  3183. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3184. }
  3185. }
  3186. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3187. if (End_Three != null)
  3188. {
  3189. if (!transDic.ContainsKey(End_Three.AirPort))
  3190. {
  3191. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3192. }
  3193. }
  3194. if (!texts.Contains(item.CTypeName))
  3195. {
  3196. texts.Add(item.CTypeName);
  3197. }
  3198. }
  3199. }
  3200. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  3201. if (transData.Count > 0)
  3202. {
  3203. foreach (TranslateResult item in transData)
  3204. {
  3205. if (!transDic.ContainsKey(item.Query))
  3206. {
  3207. transDic.Add(item.Query, item.Translation);
  3208. }
  3209. }
  3210. }
  3211. foreach (var item in _AirTicketReservations)
  3212. {
  3213. #region 处理固定数据
  3214. string[] FlightsCode = item.FlightsCode.Split('/');
  3215. if (FlightsCode.Length != 0)
  3216. {
  3217. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3218. if (_AirCompany != null)
  3219. {
  3220. string str = "--";
  3221. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3222. if (!string.IsNullOrEmpty(translateResult))
  3223. {
  3224. str = translateResult;
  3225. str = _airTicketResRep.Processing(str);
  3226. }
  3227. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3228. }
  3229. else
  3230. {
  3231. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3232. }
  3233. }
  3234. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3235. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3236. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3237. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3238. string names = "";
  3239. foreach (string clientName in nameArray)
  3240. {
  3241. names += clientName + ",";
  3242. }
  3243. if (!string.IsNullOrWhiteSpace(names))
  3244. {
  3245. string str = "--";
  3246. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3247. if (!string.IsNullOrEmpty(translateResult))
  3248. {
  3249. str = translateResult;
  3250. str = _airTicketResRep.Processing(str);
  3251. }
  3252. table.Range.Bookmarks["ClientName"].Text = str;
  3253. }
  3254. else
  3255. {
  3256. table.Range.Bookmarks["ClientName"].Text = "--";
  3257. }
  3258. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3259. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3260. table.Range.Bookmarks["JointTicket"].Text = "--";
  3261. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3262. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3263. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3264. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3265. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3266. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3267. #endregion
  3268. #region 循环数据处理
  3269. List<AirInfo> airs = new List<AirInfo>();
  3270. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3271. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3272. for (int i = 0; i < FlightsCode.Length; i++)
  3273. {
  3274. AirInfo air = new AirInfo();
  3275. string[] tempstr = DayArray[i]
  3276. .Replace("\r\n", string.Empty)
  3277. .Replace("\\r\\n", string.Empty)
  3278. .TrimStart().TrimEnd()
  3279. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3280. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3281. string starCity = "";
  3282. if (star_Three != null)
  3283. {
  3284. string str2 = "--";
  3285. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3286. if (!string.IsNullOrEmpty(translateResult2))
  3287. {
  3288. str2 = translateResult2;
  3289. str2 = _airTicketResRep.Processing(str2);
  3290. }
  3291. starCity = str2;
  3292. }
  3293. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3294. string EndCity = "";
  3295. if (End_Three != null)
  3296. {
  3297. string str1 = "--";
  3298. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3299. if (!string.IsNullOrEmpty(translateResult1))
  3300. {
  3301. str1 = translateResult1;
  3302. str1 = _airTicketResRep.Processing(str1);
  3303. }
  3304. EndCity = str1;
  3305. }
  3306. air.Destination = starCity + "/" + EndCity;
  3307. air.Flight = FlightsCode[i];
  3308. string str = "--";
  3309. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3310. if (!string.IsNullOrEmpty(translateResult))
  3311. {
  3312. str = translateResult;
  3313. str = _airTicketResRep.Processing(str);
  3314. }
  3315. air.SeatingClass = str;
  3316. string dateTime = tempstr[2];
  3317. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3318. air.FlightDate = DateTemp;
  3319. air.DepartureTime = tempstr[5];
  3320. air.LandingTime = tempstr[6];
  3321. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3322. air.TicketStatus = "--";
  3323. air.Luggage = "--";
  3324. air.DepartureTerminal = "--";
  3325. air.LandingTerminal = "--";
  3326. airs.Add(air);
  3327. }
  3328. int row = 13;
  3329. for (int i = 0; i < airs.Count; i++)
  3330. {
  3331. if (airs.Count > 2)
  3332. {
  3333. for (int j = 0; j < airs.Count - 2; j++)
  3334. {
  3335. var CopyRow = table.Rows[12].Clone(true);
  3336. table.Rows.Add(CopyRow);
  3337. }
  3338. }
  3339. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3340. int index = 0;
  3341. foreach (PropertyInfo property in properties)
  3342. {
  3343. string value = property.GetValue(airs[i]).ToString();
  3344. Cell ishcel0 = table.Rows[row].Cells[index];
  3345. Paragraph p = new Paragraph(doc);
  3346. string s = value;
  3347. p.AppendChild(new Run(doc, s));
  3348. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3349. ishcel0.AppendChild(p);
  3350. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3351. //ishcel0.CellFormat.VerticalAlignment=
  3352. index++;
  3353. }
  3354. row++;
  3355. }
  3356. #endregion
  3357. Paragraph lastParagraph = new Paragraph(doc);
  3358. //第一个表格末尾加段落
  3359. table.ParentNode.InsertAfter(lastParagraph, table);
  3360. //复制第一个表格
  3361. Table cloneTable = (Table)table.Clone(true);
  3362. //在文档末尾段落后面加入复制的表格
  3363. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3364. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3365. {
  3366. int rownewsIndex = 13;
  3367. for (int i = 0; i < 2; i++)
  3368. {
  3369. var CopyRow = table.Rows[12].Clone(true);
  3370. table.Rows.RemoveAt(13);
  3371. table.Rows.Add(CopyRow);
  3372. rownewsIndex++;
  3373. }
  3374. }
  3375. else
  3376. {
  3377. table.Rows.RemoveAt(12);
  3378. }
  3379. cloneTable.Rows.RemoveAt(12);
  3380. }
  3381. if (_AirTicketReservations.Count != 0)
  3382. {
  3383. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3384. if (FlightsCode.Length != 0)
  3385. {
  3386. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3387. if (_AirCompany != null)
  3388. {
  3389. string str = "--";
  3390. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3391. if (!string.IsNullOrEmpty(translateResult))
  3392. {
  3393. str = translateResult;
  3394. str = _airTicketResRep.Processing(str);
  3395. }
  3396. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3397. }
  3398. else
  3399. {
  3400. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3401. }
  3402. }
  3403. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3404. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3405. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3406. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3407. string names = "";
  3408. foreach (string clientName in nameArray)
  3409. {
  3410. names += clientName + ",";
  3411. }
  3412. if (!string.IsNullOrWhiteSpace(names))
  3413. {
  3414. string str = "--";
  3415. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3416. if (!string.IsNullOrEmpty(translateResult))
  3417. {
  3418. str = translateResult;
  3419. str = _airTicketResRep.Processing(str);
  3420. }
  3421. table.Range.Bookmarks["ClientName"].Text = str;
  3422. }
  3423. else
  3424. {
  3425. table.Range.Bookmarks["ClientName"].Text = "--";
  3426. }
  3427. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3428. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3429. table.Range.Bookmarks["JointTicket"].Text = "--";
  3430. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3431. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3432. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3433. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3434. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3435. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3436. }
  3437. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3438. //保存合并后的文档
  3439. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3440. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3441. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3442. return Ok(JsonView(true, "成功!", rst));
  3443. }
  3444. }
  3445. }
  3446. catch (Exception ex)
  3447. {
  3448. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3449. throw;
  3450. }
  3451. }
  3452. #endregion
  3453. #region 团组增减款项 --> 其他款项
  3454. /// <summary>
  3455. /// 团组增减款项下拉框绑定
  3456. /// </summary>
  3457. /// <param name="dto"></param>
  3458. /// <returns></returns>
  3459. [HttpPost]
  3460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3461. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3462. {
  3463. #region 参数验证
  3464. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3465. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3466. #endregion
  3467. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3468. }
  3469. /// <summary>
  3470. /// 根据团组Id查询团组增减款项
  3471. /// </summary>
  3472. /// <param name="dto"></param>
  3473. /// <returns></returns>
  3474. [HttpPost]
  3475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3476. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3477. {
  3478. #region 参数验证
  3479. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3480. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3481. #endregion
  3482. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3483. }
  3484. /// <summary>
  3485. /// 团组增减款项操作(Status:1.新增,2.修改)
  3486. /// </summary>
  3487. /// <param name="dto"></param>
  3488. /// <returns></returns>
  3489. [HttpPost]
  3490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3491. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3492. {
  3493. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3494. if (groupData.Code != 200)
  3495. {
  3496. return Ok(JsonView(false, groupData.Msg));
  3497. }
  3498. #region 应用推送
  3499. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3500. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3501. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3502. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  3503. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  3504. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  3505. //自动审核
  3506. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3507. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3508. //2024-10-21 新增LZ UID
  3509. var userIds = new List<int>() { 21 };
  3510. string title = $"系统通知";
  3511. string content = "";
  3512. var diId = dto.DiId;
  3513. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3514. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3515. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3516. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3517. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3518. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3519. #endregion
  3520. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3521. }
  3522. /// <summary>
  3523. /// 团组增减款项操作 删除
  3524. /// </summary>
  3525. /// <param name="dto"></param>
  3526. /// <returns></returns>
  3527. [HttpPost]
  3528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3529. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3530. {
  3531. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3532. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3533. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3534. if (res.Code == 0)
  3535. {
  3536. return Ok(JsonView(true, "删除成功!"));
  3537. }
  3538. return Ok(JsonView(false, "删除失败!"));
  3539. }
  3540. /// <summary>
  3541. /// 根据团组增减款项Id查询
  3542. /// </summary>
  3543. /// <param name="dto"></param>
  3544. /// <returns></returns>
  3545. [HttpPost]
  3546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3547. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3548. {
  3549. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3550. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3551. }
  3552. /// <summary>
  3553. /// 查询供应商名称
  3554. /// </summary>
  3555. /// <param name="dto"></param>
  3556. /// <returns></returns>
  3557. [HttpPost]
  3558. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3559. {
  3560. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3561. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3562. ?? new List<Grp_DecreasePayments>();
  3563. dbResult = dbResult.Distinct(new
  3564. ProductComparer()).ToList();
  3565. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3566. {
  3567. x.Id,
  3568. x.SupplierAddress,
  3569. x.SupplierArea,
  3570. x.SupplierContact,
  3571. x.SupplierContactNumber,
  3572. x.SupplierEmail,
  3573. x.SupplierName,
  3574. x.SupplierSocialAccount,
  3575. x.SupplierTypeId,
  3576. }).ToList());
  3577. return Ok(jw);
  3578. }
  3579. /// <summary>
  3580. /// 团组增减款项 OTA匹配
  3581. /// </summary>
  3582. /// <param name="file"></param>
  3583. /// <returns></returns>
  3584. [HttpPost]
  3585. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3586. {
  3587. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3588. string fileName = file.FileName;
  3589. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3590. {
  3591. return Ok(JsonView(false, "请上传Excel文件!"));
  3592. }
  3593. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3594. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3595. if (!Directory.Exists(path))
  3596. {
  3597. Directory.CreateDirectory(path);
  3598. }
  3599. var filePath = @$"{path}/{fileName}";
  3600. //保存文件
  3601. using (FileStream fs = System.IO.File.Create(filePath))
  3602. {
  3603. file.CopyTo(fs);
  3604. fs.Flush();
  3605. }
  3606. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3607. //读取ExcelFile
  3608. DataTable dt = ConvertExcelToDataTable(filePath);
  3609. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3610. dt.TableName = "TB";
  3611. //修改table列名
  3612. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3613. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3614. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3615. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3616. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3617. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3618. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3619. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3620. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3621. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3622. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3623. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3624. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3625. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3626. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3627. var otaOrderNos = new List<string>();
  3628. foreach (DataRow item in dt.Rows)
  3629. {
  3630. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3631. }
  3632. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3633. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3634. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3635. .Select((dp, di) => new
  3636. {
  3637. dp.PriceName,
  3638. dp.OTAOrderNo,
  3639. dp.FeeTotal,
  3640. di.TeamName,
  3641. })
  3642. .ToListAsync();
  3643. foreach (DataRow item in dt.Rows)
  3644. {
  3645. var otaOrderNo = item["OTAOrderNo"].ToString();
  3646. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3647. if (oaData == null) continue;
  3648. item["GroupName"] = oaData.TeamName;
  3649. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3650. }
  3651. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3652. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3653. List<DataTable> datas = new List<DataTable>();
  3654. datas.Add(dt);
  3655. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3656. return Ok(JsonView(true, "操作成功", new { url = url }));
  3657. }
  3658. #region
  3659. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3660. {
  3661. // 创建Workbook对象
  3662. Workbook workbook = new Workbook(excelFilePath);
  3663. // 获取第一个工作表
  3664. Worksheet worksheet = workbook.Worksheets[0];
  3665. // 将工作表转换为DataTable
  3666. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3667. return dataTable;
  3668. }
  3669. #endregion
  3670. #endregion
  3671. #region 文件上传、删除
  3672. /// <summary>
  3673. /// region 文件上传 可以带参数
  3674. /// </summary>
  3675. /// <param name="file"></param>
  3676. /// <returns></returns>
  3677. [HttpPost]
  3678. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3679. public async Task<IActionResult> UploadProject(IFormFile file)
  3680. {
  3681. //var TypeName = Request.Headers["TypeName"].ToString();
  3682. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3683. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3684. ////文件名称
  3685. //string projectFileName = file.FileName;
  3686. ////上传的文件的路径
  3687. //string filePath = $"{fileDir}/{projectFileName}";
  3688. //if (TypeName == "A")//A代表团组增减款项
  3689. //{
  3690. // filePath = fileDir + $@"\团组增减款项相关文件";
  3691. // if (!Directory.Exists(filePath))
  3692. // {
  3693. // Directory.CreateDirectory(filePath);
  3694. // }
  3695. // //上传的文件的路径
  3696. // filePath += $@"\{projectFileName}";
  3697. //}
  3698. //else if (TypeName == "B")//B代表商邀相关文件
  3699. //{
  3700. // //上传的文件的路径
  3701. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3702. // if (!Directory.Exists(filePath))
  3703. // {
  3704. // Directory.CreateDirectory(filePath);
  3705. // }
  3706. // //上传的文件的路径
  3707. // filePath = $@"\{projectFileName}";
  3708. //}
  3709. //try
  3710. //{
  3711. // using (FileStream fs = System.IO.File.Create(filePath))
  3712. // {
  3713. // file.CopyTo(fs);
  3714. // fs.Flush();
  3715. // }
  3716. //}
  3717. //catch (Exception ex)
  3718. //{
  3719. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3720. //}
  3721. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3722. try
  3723. {
  3724. var TypeName = Request.Headers["TypeName"].ToString();
  3725. if (file != null)
  3726. {
  3727. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3728. //文件名称
  3729. string projectFileName = file.FileName;
  3730. //上传的文件的路径
  3731. string filePath = $"{fileDir}/{projectFileName}";
  3732. if (TypeName == "A")//A代表团组增减款项
  3733. {
  3734. if (!Directory.Exists(fileDir))
  3735. {
  3736. Directory.CreateDirectory(fileDir);
  3737. }
  3738. //上传的文件的路径
  3739. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3740. }
  3741. else if (TypeName == "B")//B代表商邀相关文件
  3742. {
  3743. if (!Directory.Exists(fileDir))
  3744. {
  3745. Directory.CreateDirectory(fileDir);
  3746. }
  3747. //上传的文件的路径
  3748. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3749. }
  3750. using (FileStream fs = System.IO.File.Create(filePath))
  3751. {
  3752. file.CopyTo(fs);
  3753. fs.Flush();
  3754. }
  3755. return Ok(JsonView(true, "上传成功!", projectFileName));
  3756. }
  3757. else
  3758. {
  3759. return Ok(JsonView(false, "上传失败!"));
  3760. }
  3761. }
  3762. catch (Exception ex)
  3763. {
  3764. return Ok(JsonView(false, "程序错误!"));
  3765. }
  3766. }
  3767. /// <summary>
  3768. /// 删除指定文件
  3769. /// </summary>
  3770. /// <param name="dto"></param>
  3771. /// <returns></returns>
  3772. [HttpPost]
  3773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3774. public async Task<IActionResult> DelFile(DelFileDto dto)
  3775. {
  3776. try
  3777. {
  3778. var TypeName = Request.Headers["TypeName"].ToString();
  3779. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3780. string filePath = "";
  3781. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3782. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3783. int id = 0;
  3784. if (TypeName == "A")
  3785. {
  3786. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3787. // 删除该文件
  3788. System.IO.File.Delete(filePath);
  3789. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3790. .Where(a => a.Id == dto.Id)
  3791. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3792. .ExecuteCommandAsync();
  3793. }
  3794. else if (TypeName == "B")
  3795. {
  3796. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3797. // 删除该文件
  3798. System.IO.File.Delete(filePath);
  3799. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3800. if (info != null)
  3801. {
  3802. string[] files = new string[] { };
  3803. if (!string.IsNullOrEmpty(info.Attachment))
  3804. {
  3805. try
  3806. {
  3807. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3808. }
  3809. catch (Exception)
  3810. {
  3811. files = new List<string>() { info.Attachment }.ToArray();
  3812. }
  3813. }
  3814. if (files.Length > 0)
  3815. {
  3816. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3817. string filePath2 = string.Empty;
  3818. if (files1.Length > 0)
  3819. {
  3820. filePath2 = JsonConvert.SerializeObject(files1);
  3821. }
  3822. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3823. .Where(a => a.Id == dto.Id)
  3824. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3825. .ExecuteCommandAsync();
  3826. }
  3827. }
  3828. }
  3829. if (id != 0)
  3830. {
  3831. return Ok(JsonView(true, "成功!"));
  3832. }
  3833. else
  3834. {
  3835. return Ok(JsonView(false, "失败!"));
  3836. }
  3837. }
  3838. catch (Exception ex)
  3839. {
  3840. return Ok(JsonView(false, "程序错误!"));
  3841. throw;
  3842. }
  3843. }
  3844. /// <summary>
  3845. /// 文件上传多个文件 可以带参数
  3846. /// </summary>
  3847. /// <param name="files"></param>
  3848. /// <returns></returns>
  3849. [HttpPost]
  3850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3851. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3852. {
  3853. try
  3854. {
  3855. var TypeName = Request.Headers["TypeName"].ToString();
  3856. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3857. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3858. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3859. var filePahts = new List<string>();
  3860. foreach (var file in files)
  3861. {
  3862. //文件名称
  3863. string projectFileName = file.FileName;
  3864. //上传的文件的路径
  3865. string filePath = $"{fileDir}/{projectFileName}";
  3866. if (TypeName == "A")//A代表团组增减款项
  3867. {
  3868. if (!Directory.Exists(fileDir))
  3869. {
  3870. Directory.CreateDirectory(fileDir);
  3871. }
  3872. //上传的文件的路径
  3873. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3874. }
  3875. else if (TypeName == "B")//B代表商邀相关文件
  3876. {
  3877. if (!Directory.Exists(fileDir))
  3878. {
  3879. Directory.CreateDirectory(fileDir);
  3880. }
  3881. //上传的文件的路径
  3882. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3883. }
  3884. using (FileStream fs = System.IO.File.Create(filePath))
  3885. {
  3886. file.CopyTo(fs);
  3887. fs.Flush();
  3888. }
  3889. filePahts.Add(projectFileName);
  3890. }
  3891. return Ok(JsonView(true, "上传成功!", filePahts));
  3892. }
  3893. catch (Exception ex)
  3894. {
  3895. return Ok(JsonView(false, "程序错误!"));
  3896. }
  3897. }
  3898. #endregion
  3899. #region 商邀费用录入
  3900. /// <summary>
  3901. /// 根据团组Id查询商邀费用列表
  3902. /// </summary>
  3903. /// <param name="dto"></param>
  3904. /// <returns></returns>
  3905. [HttpPost]
  3906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3907. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3908. {
  3909. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3910. if (groupData.Code != 0)
  3911. {
  3912. return Ok(JsonView(false, groupData.Msg));
  3913. }
  3914. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3915. }
  3916. /// <summary>
  3917. /// 商邀费用列表
  3918. /// 下载文件
  3919. /// </summary>
  3920. /// <param name="id"></param>
  3921. /// <returns></returns>
  3922. [HttpGet("{id}")]
  3923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3924. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3925. {
  3926. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3927. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3928. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3929. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3930. var filePaths = new List<string>();
  3931. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3932. try
  3933. {
  3934. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3935. }
  3936. catch (Exception ex)
  3937. {
  3938. filePaths.Add(info.Attachment);
  3939. }
  3940. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3941. for (int i = 0; i < filePaths.Count; i++)
  3942. {
  3943. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3944. }
  3945. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3946. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3947. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3948. {
  3949. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3950. {
  3951. foreach (string filePath in filePaths)
  3952. {
  3953. if (System.IO.File.Exists(filePath))
  3954. {
  3955. // 获取文件名
  3956. string fileName = Path.GetFileName(filePath);
  3957. // 将文件添加到ZIP归档中
  3958. zipArchive.CreateEntryFromFile(filePath, fileName);
  3959. }
  3960. }
  3961. }
  3962. }
  3963. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3964. }
  3965. /// <summary>
  3966. /// 商邀费用 Info Page 基础数据源
  3967. /// </summary>
  3968. /// <returns></returns>
  3969. [HttpPost]
  3970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3971. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3972. {
  3973. try
  3974. {
  3975. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3976. if (groupData.Code != 0)
  3977. {
  3978. return Ok(JsonView(false, groupData.Msg));
  3979. }
  3980. return Ok(JsonView(true, "操作成功", groupData.Data));
  3981. }
  3982. catch (Exception ex)
  3983. {
  3984. return Ok(JsonView(false, ex.Message));
  3985. throw;
  3986. }
  3987. }
  3988. /// <summary>
  3989. /// 根据商邀费用ID查询C表和商邀费用数据
  3990. /// </summary>
  3991. /// <param name="dto"></param>
  3992. /// <returns></returns>
  3993. [HttpPost]
  3994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3995. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3996. {
  3997. try
  3998. {
  3999. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4000. if (groupData.Code != 0)
  4001. {
  4002. return Ok(JsonView(false, groupData.Msg));
  4003. }
  4004. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4005. }
  4006. catch (Exception ex)
  4007. {
  4008. return Ok(JsonView(false, ex.Message));
  4009. throw;
  4010. }
  4011. }
  4012. /// <summary>
  4013. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4014. /// </summary>
  4015. /// <param name="dto"></param>
  4016. /// <returns></returns>
  4017. [HttpPost]
  4018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4019. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4020. {
  4021. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4022. if (groupData.Code != 0)
  4023. {
  4024. return Ok(JsonView(false, groupData.Msg));
  4025. }
  4026. #region 应用推送
  4027. try
  4028. {
  4029. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4030. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4031. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4032. //2024-10-21 新增LZ UID
  4033. var userIds = new List<int>() { 21 };
  4034. string title = $"系统通知";
  4035. string content = "";
  4036. var diId = dto.DiId;
  4037. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4038. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4039. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4040. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4041. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4042. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4043. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4044. }
  4045. catch (Exception ex)
  4046. {
  4047. }
  4048. #endregion
  4049. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4050. }
  4051. /// <summary>
  4052. /// 商邀删除
  4053. /// </summary>
  4054. /// <param name="dto"></param>
  4055. /// <returns></returns>
  4056. [HttpPost]
  4057. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4058. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4059. {
  4060. try
  4061. {
  4062. _sqlSugar.BeginTran();
  4063. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4064. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4065. {
  4066. IsDel = 1,
  4067. DeleteUserId = dto.DeleteUserId,
  4068. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4069. })
  4070. .Where(it => it.Id == dto.Id)
  4071. .ExecuteCommand();
  4072. if (res1 > 0)
  4073. {
  4074. int _diId = 0;
  4075. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4076. if (_ioaInfo != null)
  4077. {
  4078. _diId = _ioaInfo.DiId;
  4079. }
  4080. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4081. .SetColumns(a => new Grp_CreditCardPayment()
  4082. {
  4083. IsDel = 1,
  4084. DeleteUserId = dto.DeleteUserId,
  4085. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4086. })
  4087. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4088. .ExecuteCommand();
  4089. if (res2 > 0)
  4090. {
  4091. _sqlSugar.CommitTran();
  4092. return Ok(JsonView(true, "删除成功!"));
  4093. }
  4094. }
  4095. _sqlSugar.RollbackTran();
  4096. return Ok(JsonView(false, "删除失败"));
  4097. }
  4098. catch (Exception ex)
  4099. {
  4100. _sqlSugar.RollbackTran();
  4101. return Ok(JsonView(false, ex.Message));
  4102. }
  4103. }
  4104. /// <summary>
  4105. /// 团组模块文件上传
  4106. /// </summary>
  4107. /// <param name="dto"></param>
  4108. /// <returns></returns>
  4109. [HttpPost]
  4110. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4111. {
  4112. var jw = JsonView(false);
  4113. long M = 1024 * 1024;
  4114. if (dto.Files == null || dto.Files.Count == 0)
  4115. {
  4116. jw.Msg = "无文件信息!";
  4117. return Ok(jw);
  4118. }
  4119. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4120. {
  4121. jw.Msg = "文件大小超过20M!";
  4122. return Ok(jw);
  4123. }
  4124. //var nameSp = dto.File.FileName.Split(".");
  4125. //if (nameSp.Length < 2)
  4126. //{
  4127. // jw.Msg = "拓展名称有误!";
  4128. // return Ok(jw);
  4129. //}
  4130. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4131. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4132. //{
  4133. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4134. // return Ok(jw);
  4135. //}
  4136. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4137. if (Ctable == null)
  4138. {
  4139. jw.Msg = "Ctable指向有误!";
  4140. return Ok(jw);
  4141. }
  4142. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4143. if (groupInfo == null)
  4144. {
  4145. jw.Msg = "团组信息不存在!";
  4146. return Ok(jw);
  4147. }
  4148. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4149. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4150. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4151. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4152. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4153. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4154. try
  4155. {
  4156. if (!Directory.Exists(fileBase))
  4157. {
  4158. Directory.CreateDirectory(fileBase);
  4159. }
  4160. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4161. foreach (var fileStream in dto.Files)
  4162. {
  4163. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4164. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4165. {
  4166. Cid = dto.Cid,
  4167. CreateTime = DateTime.Now,
  4168. CreateUserId = dto.Userid,
  4169. Ctable = dto.Ctable,
  4170. Diid = dto.Diid,
  4171. IsDel = 0,
  4172. FilePath = saveFilePath,
  4173. FileName = fileStream.FileName
  4174. };
  4175. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4176. {
  4177. fileStream.CopyTo(fs);
  4178. fs.Flush();
  4179. }
  4180. saveArr.Add(file);
  4181. }
  4182. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4183. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4184. jw = JsonView(true, "保存成功!", new
  4185. {
  4186. count = addResult,
  4187. filesName = saveArr.Select(x => x.FileName)
  4188. });
  4189. }
  4190. catch (Exception ex)
  4191. {
  4192. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4193. {
  4194. count = 0,
  4195. filesName = new string[0],
  4196. });
  4197. }
  4198. return Ok(jw);
  4199. }
  4200. /// <summary>
  4201. /// 查询各模块已保存文件
  4202. /// </summary>
  4203. /// <param name="dto"></param>
  4204. /// <returns></returns>
  4205. [HttpPost]
  4206. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4207. {
  4208. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4209. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4210. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4211. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4212. {
  4213. expression = Expressionable.Create<Grp_GroupModelFile>()
  4214. .And(x => visaIds.Contains(x.CreateUserId));
  4215. }
  4216. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4217. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4218. .Where(expression.ToExpression())
  4219. .ToList();
  4220. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4221. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4222. {
  4223. x.FileName,
  4224. x.Id,
  4225. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4226. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4227. })));
  4228. }
  4229. /// <summary>
  4230. /// 下载该团组下的所有文件
  4231. /// </summary>
  4232. /// <param name="dto"></param>
  4233. /// <returns></returns>
  4234. [HttpPost]
  4235. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4236. {
  4237. var jw = JsonView(false);
  4238. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4239. if (groupInfo == null)
  4240. {
  4241. jw.Msg = "团组信息不存在!";
  4242. return Ok(jw);
  4243. }
  4244. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4245. var isModule = Convert.ToBoolean(dto.isModule);
  4246. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4247. IOOperatorHelper io = new IOOperatorHelper();
  4248. if (isModule)
  4249. {
  4250. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4251. foreach (var moduleArr in moduleGroup)
  4252. {
  4253. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4254. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4255. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4256. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4257. foreach (var item in moduleArr)
  4258. {
  4259. if (System.IO.File.Exists(item.FilePath))
  4260. {
  4261. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4262. {
  4263. byte[] bytes = new byte[fileStream.Length];
  4264. fileStream.Read(bytes, 0, bytes.Length);
  4265. fileStream.Close();
  4266. Stream stream = new MemoryStream(bytes);
  4267. chiZips.Add(item.FileName, stream);
  4268. }
  4269. }
  4270. }
  4271. if (chiZips.Count > 0)
  4272. {
  4273. var byts = io.ConvertZipStream(chiZips);
  4274. Stream stream = new MemoryStream(byts);
  4275. Zips.Add(key.Name + "_.zip", stream);
  4276. }
  4277. }
  4278. }
  4279. else
  4280. {
  4281. foreach (var item in dbQuery)
  4282. {
  4283. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4284. {
  4285. byte[] bytes = new byte[fileStream.Length];
  4286. fileStream.Read(bytes, 0, bytes.Length);
  4287. fileStream.Close();
  4288. Stream stream = new MemoryStream(bytes);
  4289. while (Zips.Keys.Contains(item.FileName))
  4290. {
  4291. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4292. }
  4293. Zips.Add(item.FileName, stream);
  4294. }
  4295. }
  4296. }
  4297. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4298. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4299. if (Zips.Count > 0)
  4300. {
  4301. var byts = io.ConvertZipStream(Zips);
  4302. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4303. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4304. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4305. }
  4306. else
  4307. {
  4308. jw.Msg = "暂无生成文件!";
  4309. }
  4310. return Ok(jw);
  4311. }
  4312. /// <summary>
  4313. /// 下载该团组下此模块的所有文件
  4314. /// </summary>
  4315. /// <param name="dto"></param>
  4316. /// <returns></returns>
  4317. [HttpPost]
  4318. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4319. {
  4320. var jw = JsonView(false);
  4321. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4322. if (groupInfo == null)
  4323. {
  4324. jw.Msg = "团组信息不存在!";
  4325. return Ok(jw);
  4326. }
  4327. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4328. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4329. && x.IsDel == 0);
  4330. if (key == null)
  4331. {
  4332. jw.Msg = "Ctable指向错误!";
  4333. return Ok(jw);
  4334. }
  4335. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4336. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4337. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4338. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4339. IOOperatorHelper io = new IOOperatorHelper();
  4340. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4341. foreach (var item in dbQuery)
  4342. {
  4343. if (System.IO.File.Exists(item.FilePath))
  4344. {
  4345. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4346. {
  4347. byte[] bytes = new byte[fileStream.Length];
  4348. fileStream.Read(bytes, 0, bytes.Length);
  4349. fileStream.Close();
  4350. Stream stream = new MemoryStream(bytes);
  4351. while (Zips.Keys.Contains(item.FileName))
  4352. {
  4353. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4354. }
  4355. Zips.Add(item.FileName, stream);
  4356. }
  4357. }
  4358. }
  4359. if (Zips.Count > 0)
  4360. {
  4361. var byts = io.ConvertZipStream(Zips);
  4362. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4363. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4364. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4365. }
  4366. else
  4367. {
  4368. jw.Msg = "暂无生成文件!";
  4369. }
  4370. return Ok(jw);
  4371. }
  4372. /// <summary>
  4373. /// 删除该团组下的指定文件
  4374. /// </summary>
  4375. /// <param name="dto"></param>
  4376. /// <returns></returns>
  4377. [HttpPost]
  4378. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4379. {
  4380. var jw = JsonView(false);
  4381. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4382. if (sing == null)
  4383. {
  4384. jw.Msg = "暂无";
  4385. return Ok(jw);
  4386. }
  4387. if (System.IO.File.Exists(sing.FilePath))
  4388. {
  4389. try
  4390. {
  4391. System.IO.File.Delete(sing.FilePath);
  4392. }
  4393. catch (Exception ex)
  4394. {
  4395. jw.Msg = "删除失败!" + ex.Message;
  4396. return Ok(jw);
  4397. }
  4398. }
  4399. sing.IsDel = 1;
  4400. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4401. sing.DeleteUserId = dto.UserId;
  4402. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4403. jw = JsonView(true, "删除成功!");
  4404. return Ok(jw);
  4405. }
  4406. #endregion
  4407. #region 团组英文资料
  4408. /// <summary>
  4409. /// 查询团组英文所有资料
  4410. /// </summary>
  4411. /// <param name="dto"></param>
  4412. /// <returns></returns>
  4413. [HttpPost]
  4414. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4415. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4416. {
  4417. try
  4418. {
  4419. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4420. if (groupData.Code != 0)
  4421. {
  4422. return Ok(JsonView(false, groupData.Msg));
  4423. }
  4424. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4425. }
  4426. catch (Exception ex)
  4427. {
  4428. return Ok(JsonView(false, "程序错误!"));
  4429. throw;
  4430. }
  4431. }
  4432. /// <summary>
  4433. /// 团组英文资料操作(Status:1.新增,2.修改)
  4434. /// </summary>
  4435. /// <param name="dto"></param>
  4436. /// <returns></returns>
  4437. [HttpPost]
  4438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4439. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4440. {
  4441. try
  4442. {
  4443. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4444. if (groupData.Code != 0)
  4445. {
  4446. return Ok(JsonView(false, groupData.Msg));
  4447. }
  4448. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4449. }
  4450. catch (Exception ex)
  4451. {
  4452. return Ok(JsonView(false, "程序错误!"));
  4453. throw;
  4454. }
  4455. }
  4456. /// <summary>
  4457. /// 团组英文资料Id查询数据
  4458. /// </summary>
  4459. /// <param name="dto"></param>
  4460. /// <returns></returns>
  4461. [HttpPost]
  4462. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4463. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4464. {
  4465. try
  4466. {
  4467. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4468. if (_DelegationEnData != null)
  4469. {
  4470. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4471. }
  4472. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4473. }
  4474. catch (Exception ex)
  4475. {
  4476. return Ok(JsonView(false, "程序错误!"));
  4477. throw;
  4478. }
  4479. }
  4480. /// <summary>
  4481. /// 团组英文资料删除
  4482. /// </summary>
  4483. /// <param name="dto"></param>
  4484. /// <returns></returns>
  4485. [HttpPost]
  4486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4487. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4488. {
  4489. try
  4490. {
  4491. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4492. if (!res)
  4493. {
  4494. return Ok(JsonView(false, "删除失败"));
  4495. }
  4496. return Ok(JsonView(true, "删除成功!"));
  4497. }
  4498. catch (Exception ex)
  4499. {
  4500. return Ok(JsonView(false, "程序错误!"));
  4501. throw;
  4502. }
  4503. }
  4504. #endregion
  4505. #region 导出邀请函
  4506. /// <summary>
  4507. /// 导出邀请函页面初始化
  4508. /// </summary>
  4509. /// <param name="dto"></param>
  4510. /// <returns></returns>
  4511. [HttpPost]
  4512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4513. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4514. {
  4515. try
  4516. {
  4517. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4518. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4519. if (dto.DiId == 0)
  4520. {
  4521. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4522. }
  4523. else
  4524. {
  4525. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4526. }
  4527. return Ok(JsonView(true, "查询成功!", new
  4528. {
  4529. deleClient = crm_Deles,
  4530. delegations = grp_Delegations
  4531. }));
  4532. }
  4533. catch (Exception ex)
  4534. {
  4535. return Ok(JsonView(false, "程序错误!"));
  4536. throw;
  4537. }
  4538. }
  4539. /// <summary>
  4540. /// 导出邀请函
  4541. /// </summary>
  4542. /// <param name="dto"></param>
  4543. /// <returns></returns>
  4544. [HttpPost]
  4545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4546. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4547. {
  4548. #region 参数验证
  4549. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4550. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4551. #endregion
  4552. try
  4553. {
  4554. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4555. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4556. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4557. From Grp_TourClientList tcl
  4558. Left Join
  4559. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4560. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4561. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4562. From Crm_DeleClient dc
  4563. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4564. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4565. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4566. Where dc.IsDel = 0) temp
  4567. On temp.DcId =tcl.ClientId
  4568. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4569. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4570. List<string> texts = new List<string>();
  4571. if (datas.Count != 0)
  4572. {
  4573. foreach (TourClientListDetailsView item in datas)
  4574. {
  4575. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4576. {
  4577. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4578. }
  4579. else
  4580. {
  4581. string name = item.LastName + item.FirstName;
  4582. texts.Add(name);
  4583. }
  4584. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4585. {
  4586. if (!transDic.ContainsKey(item.Job))
  4587. {
  4588. texts.Add(item.Job);
  4589. }
  4590. }
  4591. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4592. {
  4593. texts.Add(item.CompanyFullName);
  4594. }
  4595. }
  4596. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4597. if (transData.Count > 0)
  4598. {
  4599. foreach (TranslateResult item in transData)
  4600. {
  4601. if (!transDic.ContainsKey(item.Query))
  4602. {
  4603. transDic.Add(item.Query, item.Translation);
  4604. }
  4605. }
  4606. }
  4607. List<GuestList> list = new List<GuestList>();
  4608. foreach (TourClientListDetailsView dele in datas)
  4609. {
  4610. GuestList guestList = new GuestList();
  4611. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4612. {
  4613. guestList.Name = dele.Pinyin;
  4614. }
  4615. else
  4616. {
  4617. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4618. guestList.Name = Name;
  4619. }
  4620. if (dele.Sex == 0)
  4621. {
  4622. guestList.Sex = "Male";
  4623. }
  4624. else if (dele.Sex == 1)
  4625. {
  4626. guestList.Sex = "Female";
  4627. }
  4628. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4629. if (!string.IsNullOrEmpty(dele.Job))
  4630. {
  4631. guestList.Job = dele.Job;
  4632. }
  4633. list.Add(guestList);
  4634. }
  4635. //载入模板
  4636. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4637. DocumentBuilder builder = new DocumentBuilder(doc);
  4638. //获取word里所有表格
  4639. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4640. //获取所填表格的序数
  4641. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4642. var rowStart = tableOne.Rows[0]; //获取第1行
  4643. //循环赋值
  4644. for (int i = 0; i < list.Count; i++)
  4645. {
  4646. builder.MoveToCell(0, i + 1, 0, 0);
  4647. builder.Write(list[i].Name.ToString());
  4648. builder.MoveToCell(0, i + 1, 1, 0);
  4649. builder.Write(list[i].Sex.ToString());
  4650. builder.MoveToCell(0, i + 1, 2, 0);
  4651. builder.Write(list[i].DOB.ToString());
  4652. builder.MoveToCell(0, i + 1, 3, 0);
  4653. builder.Write(list[i].Job.ToString());
  4654. }
  4655. //删除多余行
  4656. while (tableOne.Rows.Count > list.Count + 1)
  4657. {
  4658. tableOne.Rows.RemoveAt(list.Count + 1);
  4659. }
  4660. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4661. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4662. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4663. doc.Save(filePath);
  4664. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4665. return Ok(JsonView(true, "操作成功!", Url));
  4666. }
  4667. else
  4668. {
  4669. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4670. }
  4671. }
  4672. catch (Exception ex)
  4673. {
  4674. return Ok(JsonView(false, ex.Message));
  4675. throw;
  4676. }
  4677. }
  4678. #endregion
  4679. #region 团组经理模块 出入境费用
  4680. /// <summary>
  4681. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4682. /// </summary>
  4683. /// <returns></returns>
  4684. [HttpPost]
  4685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4686. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4687. {
  4688. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4689. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4690. //SetDataInfoView
  4691. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4692. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4693. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4694. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4695. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4696. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4697. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4698. List<CurrencyInfo> _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  4699. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4700. return Ok(JsonView(true, "查询成功!", new
  4701. {
  4702. GroupNameData = groupNameData.Data,
  4703. CurrencyData = _CurrencyData,
  4704. WordTypeData = _WordTypeData,
  4705. ExcelTypeData = _ExcelTypeData,
  4706. CurrencyInit = _currencyInfos,
  4707. ViewPermissionData = viewPermissionData
  4708. }));
  4709. }
  4710. /// <summary>
  4711. /// 团组模块 - 出入境费用
  4712. /// 实时汇率 tips
  4713. /// 签证费用 tips
  4714. /// 机票费用 tips
  4715. /// </summary>
  4716. /// <returns></returns>
  4717. [HttpPost]
  4718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4719. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4720. {
  4721. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4722. //默认币种显示
  4723. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  4724. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4725. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4726. return Ok(JsonView(true, "查询成功!", new
  4727. {
  4728. //GroupNameData = groupNameData.Data,
  4729. visaData = visaData.Data,
  4730. airData = airData.Data,
  4731. reteInfos = reteInfos
  4732. }));
  4733. }
  4734. /// <summary>
  4735. /// 团组模块 - 出入境费用 - Info
  4736. /// </summary>
  4737. /// <returns></returns>
  4738. [HttpPost]
  4739. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  4740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4741. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4742. {
  4743. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4744. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4745. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4746. }
  4747. /// <summary>
  4748. /// 团组模块 - 出入境费用 - 设置view权限
  4749. /// </summary>
  4750. /// <returns></returns>
  4751. [HttpPost]
  4752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4753. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4754. {
  4755. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4756. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4757. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4758. var permissions = new List<Grp_EnterExitCostPermission>();
  4759. foreach (var userId in dto.UserIds)
  4760. {
  4761. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  4762. }
  4763. if (permissions.Any())
  4764. {
  4765. _sqlSugar.BeginTran();
  4766. try
  4767. {
  4768. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  4769. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  4770. if (result < 1)
  4771. {
  4772. _sqlSugar.RollbackTran();
  4773. return Ok(JsonView(false));
  4774. }
  4775. }
  4776. catch (Exception ex)
  4777. {
  4778. _sqlSugar.RollbackTran();
  4779. return Ok(JsonView(false, ex.Message));
  4780. }
  4781. _sqlSugar.CommitTran();
  4782. return Ok(JsonView(true));
  4783. }
  4784. return Ok(JsonView(false));
  4785. }
  4786. /// <summary>
  4787. /// 团组模块 - 出入境费用 - Add And Update
  4788. /// </summary>
  4789. /// <returns></returns>
  4790. [HttpPost]
  4791. [ApiLog("Grp_EnterExitCost",OperationEnum.Add)]
  4792. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4793. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4794. {
  4795. try
  4796. {
  4797. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4798. if (dto.DayOtherPriceData.Any())
  4799. {
  4800. var inserList = dto.DayOtherPriceData
  4801. .Where(x => x.Id == 0)
  4802. .Select(x => new Grp_DayOtherPrice
  4803. {
  4804. Cost = x.Cost,
  4805. Id = x.Id,
  4806. CreateTime = DateTime.Now,
  4807. CreateUserId = dto.UserId,
  4808. Currency = x.Currency,
  4809. Diid = x.DiId,
  4810. Index = x.Index,
  4811. IsDel = 0,
  4812. SetDataId = x.SetDataId,
  4813. SubTotal = x.SubTotal,
  4814. Remark = x.Remark
  4815. })
  4816. .ToList();
  4817. var updateList = dto.DayOtherPriceData
  4818. .Where(x => x.Id != 0)
  4819. .Select(x => new Grp_DayOtherPrice
  4820. {
  4821. Cost = x.Cost,
  4822. Id = x.Id,
  4823. CreateTime = DateTime.Now,
  4824. CreateUserId = dto.UserId,
  4825. Currency = x.Currency,
  4826. Diid = x.DiId,
  4827. Index = x.Index,
  4828. IsDel = 0,
  4829. SetDataId = x.SetDataId,
  4830. SubTotal = x.SubTotal,
  4831. Remark = x.Remark
  4832. })
  4833. .ToList();
  4834. //添加
  4835. _sqlSugar.BeginTran();
  4836. if (inserList.Any())
  4837. {
  4838. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4839. }
  4840. if (updateList.Any())
  4841. {
  4842. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4843. }
  4844. _sqlSugar.CommitTran();
  4845. }
  4846. if (data.Code != 0)
  4847. {
  4848. return Ok(JsonView(false, data.Msg));
  4849. }
  4850. //生成默认文件pdf并且通知人员
  4851. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4852. {
  4853. DiId = dto.DiId,
  4854. ExportType = 1,
  4855. SubTypeId = 1005
  4856. }, "pdf");
  4857. //发送通知
  4858. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4859. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4860. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4861. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4862. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4863. //汇率信息记录
  4864. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4865. return Ok(JsonView(true, data.Msg, data.Data));
  4866. }
  4867. catch (Exception ex)
  4868. {
  4869. return Ok(JsonView(false, ex.Message));
  4870. }
  4871. }
  4872. /// <summary>
  4873. /// 团组模块 - 出入境费用 - Confirm 费用
  4874. /// </summary>
  4875. /// <returns></returns>
  4876. [HttpPost]
  4877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4878. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4879. {
  4880. //TODO:测试完毕需把对应的用户ID更改
  4881. //1、数据表添加字段
  4882. //2、更改字段接口()
  4883. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4884. //3、确认成功 给财务发送消息
  4885. if (_view.Code == 200)
  4886. {
  4887. if (dto.Type == 1)
  4888. {
  4889. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4890. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4891. }
  4892. }
  4893. return Ok(_view);
  4894. }
  4895. /// <summary>
  4896. /// 团组模块 - 出入境费用 - File download
  4897. /// </summary>
  4898. /// <param name="dto"></param>
  4899. /// <returns></returns>
  4900. [HttpPost]
  4901. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  4902. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4903. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4904. {
  4905. try
  4906. {
  4907. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4908. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4909. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4910. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4911. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4912. 3 团组成员名单 1 团组成员名单", ""));
  4913. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  4914. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4915. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4916. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  4917. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  4918. //数据源
  4919. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4920. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4921. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4922. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4923. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4924. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4925. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  4926. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4927. .Select((x, a, b) => new
  4928. {
  4929. x.Index,
  4930. itemName = a.Name,
  4931. CurrencyStr = b.Name,
  4932. x.Cost,
  4933. x.SubTotal,
  4934. x.Remark
  4935. })
  4936. .OrderBy((x) => x.Index)
  4937. .ToList(); //其他款项费用
  4938. var peiceItemCurrencys = new List<string>();
  4939. if (_DayAndCosts.Any())
  4940. {
  4941. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  4942. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  4943. }
  4944. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  4945. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  4946. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  4947. {
  4948. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  4949. }
  4950. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4951. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4952. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4953. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4954. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4955. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4956. .Select((tcl, dc, cc) => new ClientInfo
  4957. {
  4958. LastName = dc.LastName,
  4959. FirstName = dc.FirstName,
  4960. Sex = dc.Sex,
  4961. Birthday = dc.BirthDay,
  4962. Company = cc.CompanyFullName,
  4963. Job = dc.Job
  4964. })
  4965. .ToList();
  4966. foreach (var item in DeleClientList)
  4967. {
  4968. EncryptionProcessor.DecryptProperties(item);
  4969. }
  4970. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4971. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4972. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4973. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4974. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4975. if (dto.ExportType == 1) //明细表
  4976. {
  4977. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4978. {
  4979. //获取模板
  4980. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4981. //载入模板
  4982. Document doc = new Document(tempPath);
  4983. DocumentBuilder builder = new DocumentBuilder(doc);
  4984. //利用键值对存放数据
  4985. Dictionary<string, string> dic = new Dictionary<string, string>();
  4986. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  4987. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  4988. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  4989. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  4990. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  4991. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  4992. //境内费用(其他费用)
  4993. if (_EnterExitCosts.ChoiceOne == 1)
  4994. {
  4995. string row1_1 = "";
  4996. if (_EnterExitCosts.Visa > 0)
  4997. {
  4998. //insidePayTotal += _EnterExitCosts.Visa;
  4999. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5000. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5001. {
  5002. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5003. }
  5004. }
  5005. string row1_2 = "";
  5006. if (_EnterExitCosts.YiMiao > 0)
  5007. {
  5008. //insidePayTotal += _EnterExitCosts.YiMiao;
  5009. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5010. }
  5011. if (_EnterExitCosts.HeSuan > 0)
  5012. {
  5013. //insidePayTotal += _EnterExitCosts.HeSuan;
  5014. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5015. }
  5016. if (_EnterExitCosts.Service > 0)
  5017. {
  5018. //insidePayTotal += _EnterExitCosts.Service;
  5019. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5020. }
  5021. string row1_3 = "";
  5022. if (_EnterExitCosts.Safe > 0)
  5023. {
  5024. //insidePayTotal += _EnterExitCosts.Safe;
  5025. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5026. }
  5027. if (_EnterExitCosts.Ticket > 0)
  5028. {
  5029. //insidePayTotal += _EnterExitCosts.Ticket;
  5030. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5031. }
  5032. string row1 = "";
  5033. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5034. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5035. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5036. row1 += $"备注:{_EnterExitCosts.Remark}";
  5037. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5038. dic.Add("Row1Str", row1);
  5039. }
  5040. string airTotalStr = string.Empty,
  5041. airPriceStr = string.Empty;
  5042. //经济舱
  5043. if (_EnterExitCosts.SumJJC == 1)
  5044. {
  5045. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5046. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5047. }
  5048. //公务舱
  5049. if (_EnterExitCosts.SumGWC == 1)
  5050. {
  5051. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5052. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5053. }
  5054. //头等舱
  5055. if (_EnterExitCosts.SumTDC == 1)
  5056. {
  5057. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5058. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5059. }
  5060. //汇率描述
  5061. string rateStr = "";
  5062. if (peiceItemCurrencyInfos.Any())
  5063. {
  5064. rateStr = "\r\n汇率描述:";
  5065. foreach (var item in peiceItemCurrencyInfos)
  5066. {
  5067. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  5068. }
  5069. }
  5070. string twoItemRemark = "备注:";
  5071. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  5072. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  5073. dic.Add("AirTotalStr", airTotalStr);
  5074. dic.Add("AirPriceStr", airPriceStr);
  5075. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5076. dic.Add("TwoItemRemark", twoItemRemark);
  5077. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5078. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5079. int table1Row = 0,
  5080. table2Row = 0,
  5081. table3Row = 0,
  5082. table4Row = 0,
  5083. table5Row = 0;
  5084. //住宿费
  5085. if (_EnterExitCosts.ChoiceThree == 1)
  5086. {
  5087. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5088. table1Row = dac1.Count;
  5089. #region 填充word表格内容
  5090. for (int i = 0; i < dac1.Count; i++)
  5091. {
  5092. Grp_DayAndCost dac = dac1[i];
  5093. if (dac == null) continue;
  5094. builder.MoveToCell(0, i, 0, 0);
  5095. builder.Write("第" + dac.Days.ToString() + "晚:");
  5096. builder.MoveToCell(0, i, 1, 0);
  5097. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5098. //builder.Write(dac.Place == null ? "" : dac.Place);
  5099. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5100. builder.MoveToCell(0, i, 2, 0);
  5101. builder.Write("费用标准:");
  5102. string curr = "";
  5103. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5104. if (currData != null)
  5105. {
  5106. curr = currData.Name;
  5107. }
  5108. builder.MoveToCell(0, i, 3, 0);
  5109. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5110. builder.MoveToCell(0, i, 4, 0);
  5111. builder.Write("费用小计:");
  5112. builder.MoveToCell(0, i, 5, 0);
  5113. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5114. }
  5115. #endregion
  5116. }
  5117. else dic.Add("SubZS", "0.00");
  5118. //删除多余行
  5119. while (table1.Rows.Count > table1Row)
  5120. {
  5121. table1.Rows.RemoveAt(table1Row);
  5122. }
  5123. //伙食费
  5124. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5125. if (_EnterExitCosts.ChoiceFour == 1)
  5126. {
  5127. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5128. table2Row = dac2.Count;
  5129. #region 填充word表格内容
  5130. for (int i = 0; i < dac2.Count; i++)
  5131. {
  5132. Grp_DayAndCost dac = dac2[i];
  5133. if (dac == null) continue;
  5134. builder.MoveToCell(1, i, 0, 0);
  5135. builder.Write("第" + dac.Days.ToString() + "天:");
  5136. builder.MoveToCell(1, i, 1, 0);
  5137. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5138. builder.MoveToCell(1, i, 2, 0);
  5139. builder.Write("费用标准:");
  5140. string curr = "";
  5141. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5142. if (currData != null)
  5143. {
  5144. curr = currData.Name;
  5145. }
  5146. builder.MoveToCell(1, i, 3, 0);
  5147. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5148. builder.MoveToCell(1, i, 4, 0);
  5149. builder.Write("费用小计:");
  5150. builder.MoveToCell(1, i, 5, 0);
  5151. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5152. }
  5153. #endregion
  5154. }
  5155. else dic.Add("SubHS", "0.00");
  5156. //删除多余行
  5157. while (table2.Rows.Count > table2Row)
  5158. {
  5159. table2.Rows.RemoveAt(table2Row);
  5160. }
  5161. //公杂费
  5162. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5163. if (_EnterExitCosts.ChoiceFive == 1)
  5164. {
  5165. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5166. table3Row = dac3.Count;
  5167. #region 填充word表格内容
  5168. for (int i = 0; i < dac3.Count; i++)
  5169. {
  5170. Grp_DayAndCost dac = dac3[i];
  5171. if (dac == null) continue;
  5172. builder.MoveToCell(2, i, 0, 0);
  5173. builder.Write("第" + dac.Days.ToString() + "天:");
  5174. builder.MoveToCell(2, i, 1, 0);
  5175. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5176. builder.MoveToCell(2, i, 2, 0);
  5177. builder.Write("费用标准:");
  5178. string curr = "";
  5179. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5180. if (currData != null)
  5181. {
  5182. curr = currData.Name;
  5183. }
  5184. builder.MoveToCell(2, i, 3, 0);
  5185. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5186. builder.MoveToCell(2, i, 4, 0);
  5187. builder.Write("费用小计:");
  5188. builder.MoveToCell(2, i, 5, 0);
  5189. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5190. }
  5191. //删除多余行
  5192. while (table3.Rows.Count > table3Row)
  5193. {
  5194. table3.Rows.RemoveAt(table3Row);
  5195. }
  5196. #endregion
  5197. }
  5198. else dic.Add("SubGZF", "0.00");
  5199. //删除多余行
  5200. while (table3.Rows.Count > table3Row)
  5201. {
  5202. table3.Rows.RemoveAt(table3Row);
  5203. }
  5204. //培训费
  5205. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5206. if (_EnterExitCosts.ChoiceSix == 1)
  5207. {
  5208. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5209. dic.Add("SubPX", pxStr);
  5210. table4Row = dac4.Count;
  5211. #region 填充word表格内容
  5212. for (int i = 0; i < dac4.Count; i++)
  5213. {
  5214. Grp_DayAndCost dac = dac4[i];
  5215. if (dac == null) continue;
  5216. builder.MoveToCell(3, i, 0, 0);
  5217. builder.Write("第" + dac.Days.ToString() + "天:");
  5218. builder.MoveToCell(3, i, 1, 0);
  5219. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5220. builder.MoveToCell(3, i, 2, 0);
  5221. builder.Write("费用标准:");
  5222. string curr = "";
  5223. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5224. if (currData != null)
  5225. {
  5226. curr = currData.Name;
  5227. }
  5228. builder.MoveToCell(3, i, 3, 0);
  5229. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5230. builder.MoveToCell(3, i, 4, 0);
  5231. builder.Write("费用小计:");
  5232. builder.MoveToCell(3, i, 5, 0);
  5233. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5234. }
  5235. #endregion
  5236. }
  5237. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  5238. //删除多余行
  5239. while (table4.Rows.Count > table4Row)
  5240. {
  5241. table4.Rows.RemoveAt(table4Row);
  5242. }
  5243. //其他费用
  5244. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5245. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5246. {
  5247. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5248. dic.Add("titleQi", qtStr);
  5249. table5Row = dac5.Count;
  5250. #region 填充word表格内容
  5251. for (int i = 0; i < dac5.Count; i++)
  5252. {
  5253. var dac = dac5[i];
  5254. if (dac == null) continue;
  5255. builder.MoveToCell(4, i, 0, 0);
  5256. builder.Write("第" + dac.Index.ToString() + "项:");
  5257. builder.MoveToCell(4, i, 1, 0);
  5258. builder.Write(dac.itemName);
  5259. builder.MoveToCell(4, i, 2, 0);
  5260. builder.Write("费用标准:");
  5261. builder.MoveToCell(4, i, 3, 0);
  5262. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5263. builder.MoveToCell(4, i, 4, 0);
  5264. builder.Write("费用小计:");
  5265. builder.MoveToCell(4, i, 5, 0);
  5266. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5267. builder.MoveToCell(4, i, 6, 0);
  5268. builder.Write("备注:");
  5269. builder.MoveToCell(4, i, 7, 0);
  5270. builder.Write(dac.Remark);
  5271. }
  5272. #endregion
  5273. }
  5274. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5275. //删除多余行
  5276. while (table5.Rows.Count > table5Row)
  5277. {
  5278. table5.Rows.RemoveAt(table5Row);
  5279. }
  5280. //加上其他费用
  5281. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5282. decimal subJJC = 0.00M,
  5283. subGWC = 0.00M,
  5284. subTDC = 0.00M;
  5285. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  5286. string totalLabel = string.Format("全部费用总计:");
  5287. //经济舱
  5288. if (_EnterExitCosts.SumJJC == 1)
  5289. {
  5290. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5291. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  5292. }
  5293. //公务舱
  5294. if (_EnterExitCosts.SumGWC == 1) {
  5295. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5296. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  5297. }
  5298. //头等舱
  5299. if (_EnterExitCosts.SumTDC == 1)
  5300. {
  5301. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5302. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  5303. }
  5304. //TotalLabel
  5305. dic.Add("TotalLabel", totalLabel);
  5306. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5307. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5308. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5309. #region 填充word模板书签内容
  5310. foreach (var key in dic.Keys)
  5311. {
  5312. Bookmark bookmark = doc.Range.Bookmarks[key];
  5313. if (bookmark != null)
  5314. {
  5315. builder.MoveToBookmark(key);
  5316. builder.Write(dic[key]);
  5317. }
  5318. }
  5319. #endregion
  5320. #region 设置页眉
  5321. string userLabel = string.Empty;
  5322. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5323. if (currUserInfo != null)
  5324. {
  5325. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5326. if (userInfo != null)
  5327. {
  5328. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5329. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5330. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5331. }
  5332. }
  5333. //设置页脚
  5334. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5335. #endregion
  5336. //文件名
  5337. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5338. AsposeHelper.removewatermark_v2180();
  5339. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5340. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5341. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5342. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5343. }
  5344. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5345. {
  5346. //获取模板
  5347. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5348. //载入模板
  5349. Document doc = new Document(tempPath);
  5350. DocumentBuilder builder = new DocumentBuilder(doc);
  5351. Dictionary<string, string> dic = new Dictionary<string, string>();
  5352. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5353. {
  5354. List<string> list = new List<string>();
  5355. try
  5356. {
  5357. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5358. foreach (var item in spilitArr)
  5359. {
  5360. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5361. var depCode = spDotandEmpty[2].Substring(0, 3);
  5362. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5363. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5364. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5365. list.Add(depName);
  5366. list.Add(arrName);
  5367. }
  5368. list = list.Distinct().ToList();
  5369. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5370. }
  5371. catch (Exception)
  5372. {
  5373. dic.Add("ReturnCode", "行程录入不正确!");
  5374. }
  5375. }
  5376. else
  5377. {
  5378. dic.Add("ReturnCode", "未录入行程!");
  5379. }
  5380. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5381. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5382. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5383. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5384. {
  5385. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5386. dic.Add("Day", sp.Days.ToString());
  5387. }
  5388. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5389. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5390. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5391. //dic.Add("Names", Names);
  5392. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5393. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5394. decimal dac1totalPrice = 0.00M;
  5395. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5396. foreach (var dac in dac1)
  5397. {
  5398. if (dac.SubTotal == 0.00M)
  5399. {
  5400. continue;
  5401. }
  5402. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5403. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5404. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5405. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5406. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5407. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5408. builder.Write(currency);//币种
  5409. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5410. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5411. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5412. builder.Write("");//人数
  5413. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5414. builder.Write("");//天数
  5415. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5416. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5417. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5418. decimal rate = 0.00M;
  5419. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5420. builder.Write(rate.ToString("#0.0000"));//汇率
  5421. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5422. decimal rbmPrice = dac.SubTotal;
  5423. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5424. accommodationStartIndex++;
  5425. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5426. }
  5427. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5428. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5429. {
  5430. table1.Rows.RemoveAt(i - 1);
  5431. foodandotherStartIndex--;
  5432. }
  5433. if (dac2.Count == dac3.Count)//国家 币种 金额
  5434. {
  5435. for (int i = 0; i < dac2.Count; i++)
  5436. {
  5437. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5438. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5439. }
  5440. }
  5441. decimal dac2totalPrice = 0.00M;
  5442. foreach (var dac in dac2)
  5443. {
  5444. if (dac.SubTotal == 0)
  5445. {
  5446. continue;
  5447. }
  5448. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5449. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5450. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5451. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5452. builder.Write(currency);//币种
  5453. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5454. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5455. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5456. builder.Write("");//人数
  5457. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5458. builder.Write("");//天数
  5459. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5460. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5461. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5462. decimal rate = 0.00M;
  5463. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5464. builder.Write(rate.ToString("#0.0000"));//汇率
  5465. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5466. decimal rbmPrice = dac.SubTotal;
  5467. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5468. foodandotherStartIndex++;
  5469. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5470. }
  5471. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5472. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5473. {
  5474. table1.Rows.RemoveAt(i - 1);
  5475. }
  5476. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5477. string otherFeeStr = "";
  5478. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5479. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5480. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5481. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5482. foreach (var otherInfo in dac5)
  5483. {
  5484. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5485. }
  5486. #endregion
  5487. if (otherFeeStr.Length > 0)
  5488. {
  5489. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5490. otherFeeStr = $"({otherFeeStr})";
  5491. dic.Add("OtherFeeStr", otherFeeStr);
  5492. }
  5493. //总计
  5494. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5495. //国际旅费
  5496. string outsideAir = string.Empty;
  5497. string allPriceAir = string.Empty;
  5498. if (_EnterExitCosts.SumJJC == 1)
  5499. {
  5500. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5501. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5502. }
  5503. if (_EnterExitCosts.SumGWC == 1)
  5504. {
  5505. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5506. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5507. }
  5508. if (_EnterExitCosts.SumTDC == 1)
  5509. {
  5510. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5511. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5512. }
  5513. dic.Add("InTravelPrice", $"({outsideAir})");
  5514. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5515. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5516. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5517. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5518. foreach (var key in dic.Keys)
  5519. {
  5520. builder.MoveToBookmark(key);
  5521. builder.Write(dic[key]);
  5522. }
  5523. //模板文件名
  5524. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5525. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5526. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5527. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5528. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5529. }
  5530. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5531. {
  5532. //获取模板
  5533. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5534. //载入模板
  5535. WorkbookDesigner designer = new WorkbookDesigner();
  5536. designer.Workbook = new Workbook(tempPath);
  5537. Dictionary<string, string> dic = new Dictionary<string, string>();
  5538. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5539. {
  5540. List<string> list = new List<string>();
  5541. try
  5542. {
  5543. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5544. foreach (var item in spilitArr)
  5545. {
  5546. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5547. var depCode = spDotandEmpty[2].Substring(0, 3);
  5548. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5549. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5550. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5551. list.Add(depName);
  5552. list.Add(arrName);
  5553. }
  5554. list = list.Distinct().ToList();
  5555. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5556. }
  5557. catch (Exception)
  5558. {
  5559. dic.Add("ReturnCode", "行程录入不正确!");
  5560. }
  5561. }
  5562. else
  5563. {
  5564. dic.Add("ReturnCode", "未录入行程!");
  5565. }
  5566. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5567. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5568. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5569. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5570. {
  5571. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5572. dic.Add("Day", sp.Days.ToString());
  5573. }
  5574. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5575. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5576. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5577. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5578. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5579. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5580. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5581. designer.SetDataSource("Name", Names);
  5582. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5583. designer.SetDataSource("Day", dic["Day"] + "天");
  5584. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5585. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5586. int startIndex = 10;
  5587. const int startIndexcopy = 10;
  5588. if (dac2.Count == dac3.Count)//国家 币种 金额
  5589. {
  5590. for (int i = 0; i < dac2.Count; i++)
  5591. {
  5592. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5593. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5594. }
  5595. }
  5596. DataTable dtdac1 = new DataTable();
  5597. List<string> place = new List<string>();
  5598. dtdac1.Columns.AddRange(new DataColumn[] {
  5599. new DataColumn(){ ColumnName = "city"},
  5600. new DataColumn(){ ColumnName = "curr"},
  5601. new DataColumn(){ ColumnName = "criterion"},
  5602. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5603. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5604. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5605. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5606. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5607. });
  5608. DataTable dtdac2 = new DataTable();
  5609. dtdac2.Columns.AddRange(new DataColumn[] {
  5610. new DataColumn(){ ColumnName = "city"},
  5611. new DataColumn(){ ColumnName = "curr"},
  5612. new DataColumn(){ ColumnName = "criterion"},
  5613. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5614. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5615. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5616. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5617. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5618. });
  5619. dtdac1.TableName = "tb1";
  5620. dtdac2.TableName = "tb2";
  5621. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5622. foreach (var item in dac1)
  5623. {
  5624. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5625. if (place.Contains(item.Place))
  5626. {
  5627. continue;
  5628. }
  5629. DataRow row = dtdac1.NewRow();
  5630. row["city"] = item.Place;
  5631. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5632. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5633. row["curr"] = currency;
  5634. row["rate"] = rate.ToString("#0.0000");
  5635. row["criterion"] = item.Cost.ToString("#0.00");
  5636. row["number"] = 1;
  5637. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5638. //row["costRMB"] = rbmPrice;
  5639. dtdac1.Rows.Add(row);
  5640. place.Add(item.Place);
  5641. }
  5642. place = new List<string>();
  5643. foreach (var item in dac2)
  5644. {
  5645. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5646. if (place.Contains(item.Place))
  5647. {
  5648. continue;
  5649. }
  5650. DataRow row = dtdac2.NewRow();
  5651. row["city"] = item.Place;
  5652. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5653. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5654. row["curr"] = currency;
  5655. row["rate"] = rate.ToString("#0.0000");
  5656. row["criterion"] = item.Cost.ToString("#0.00");
  5657. row["number"] = 1;
  5658. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5659. //row["cost"] = item.SubTotal;
  5660. //row["costRMB"] = rbmPrice;
  5661. dtdac2.Rows.Add(row);
  5662. place.Add(item.Place);
  5663. //dac2totalPrice += rbmPrice;
  5664. }
  5665. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5666. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5667. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5668. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5669. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5670. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5671. string cell4Str1 = string.Empty;
  5672. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5673. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5674. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5675. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5676. string cellStr = $" 5.其他费用(";
  5677. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5678. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5679. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5680. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5681. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5682. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5683. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5684. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5685. foreach (var otherInfo in dac5)
  5686. {
  5687. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5688. }
  5689. #endregion
  5690. if (cellStr.Length > 8)
  5691. {
  5692. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5693. }
  5694. cellStr += ")";
  5695. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5696. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5697. decimal pxFee = dac4.Sum(it => it.Cost);
  5698. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5699. string celllastStr1 = "";
  5700. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5701. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5702. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5703. celllastStr1 += $",国际旅费 元";
  5704. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5705. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5706. designer.SetDataSource("cell4Str", cell4Str);
  5707. designer.SetDataSource("cellStr", cellStr);
  5708. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5709. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5710. designer.SetDataSource("celllastStr", celllastStr);
  5711. Workbook wb = designer.Workbook;
  5712. var sheet = wb.Worksheets[0];
  5713. //绑定datatable数据集
  5714. designer.SetDataSource(dtdac1);
  5715. designer.SetDataSource(dtdac2);
  5716. designer.Process();
  5717. var rowStart = dtdac1.Rows.Count;
  5718. while (rowStart > 0)
  5719. {
  5720. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5721. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5722. startIndex++;
  5723. rowStart--;
  5724. }
  5725. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5726. startIndex += 1; //总计行
  5727. rowStart = dtdac2.Rows.Count;
  5728. while (rowStart > 0)
  5729. {
  5730. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5731. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5732. startIndex++;
  5733. rowStart--;
  5734. }
  5735. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5736. wb.CalculateFormula(true);
  5737. //模板文件名
  5738. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5739. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5740. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5741. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5742. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5743. }
  5744. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5745. {
  5746. //获取模板
  5747. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5748. //载入模板
  5749. Document doc = new Document(tempPath);
  5750. DocumentBuilder builder = new DocumentBuilder(doc);
  5751. Dictionary<string, string> dic = new Dictionary<string, string>();
  5752. dic.Add("GroupName", _DelegationInfo.TeamName);
  5753. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5754. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5755. string missionLeaderJob = "";//负责人job
  5756. //int groupNumber = 0; //团人数
  5757. if (DeleClientList.Count > 0)
  5758. {
  5759. missionLeader = DeleClientList[0]?.Name ?? "";
  5760. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5761. }
  5762. dic.Add("MissionLeader", missionLeader); //团负责人
  5763. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5764. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5765. #region MyRegion
  5766. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5767. //{
  5768. // List<string> list = new List<string>();
  5769. // try
  5770. // {
  5771. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5772. // foreach (var item in spilitArr)
  5773. // {
  5774. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5775. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5776. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5777. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5778. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5779. // list.Add(depName);
  5780. // list.Add(arrName);
  5781. // }
  5782. // list = list.Distinct().ToList();
  5783. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5784. // }
  5785. // catch (Exception)
  5786. // {
  5787. // dic.Add("ReturnCode", "行程录入不正确!");
  5788. // }
  5789. //}
  5790. //else
  5791. //{
  5792. // dic.Add("ReturnCode", "未录入行程!");
  5793. //}
  5794. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5795. dic.Add("ReturnCode", string.Join("、", countrys));
  5796. #endregion
  5797. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5798. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5799. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5800. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5801. //{
  5802. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5803. // dic.Add("Day", sp.Days.ToString());
  5804. //}
  5805. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5806. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5807. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5808. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5809. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5810. //培训人员名单
  5811. int cultivateRowIndex = 7;
  5812. foreach (var item in DeleClientList)
  5813. {
  5814. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5815. builder.Write(item.Name);
  5816. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5817. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5818. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5819. string birthDay = "";
  5820. if (item.Birthday != null)
  5821. {
  5822. DateTime dt = Convert.ToDateTime(item.Birthday);
  5823. birthDay = $"{dt.Year}.{dt.Month}";
  5824. }
  5825. builder.Write(birthDay);
  5826. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5827. builder.Write(item.Company);
  5828. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5829. builder.Write(item.Job);
  5830. cultivateRowIndex++;
  5831. }
  5832. //删除多余行
  5833. //cultivateRowIndex -= 2;
  5834. int delRows = 10 + 7 - cultivateRowIndex;
  5835. if (delRows > 0)
  5836. {
  5837. for (int i = 0; i < delRows; i++)
  5838. {
  5839. table1.Rows.RemoveAt(cultivateRowIndex);
  5840. //cultivateRowIndex++;
  5841. }
  5842. }
  5843. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5844. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5845. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5846. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5847. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5848. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5849. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5850. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5851. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5852. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5853. //其他费用
  5854. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5855. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5856. //其他费用合计
  5857. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5858. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5859. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5860. //公务舱合计
  5861. //国际旅费
  5862. //string outsideJJ = "";
  5863. //string allPriceJJ = "";
  5864. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5865. {
  5866. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5867. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5868. }
  5869. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5870. {
  5871. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5872. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5873. }
  5874. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5875. {
  5876. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5877. dic.Add("AirFeeTotal", airFeeTotalStr);
  5878. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5879. dic.Add("FeeTotal", feeTotalStr);
  5880. }
  5881. foreach (var key in dic.Keys)
  5882. {
  5883. builder.MoveToBookmark(key);
  5884. builder.Write(dic[key]);
  5885. }
  5886. //模板文件名
  5887. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5888. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5889. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5890. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5891. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5892. }
  5893. }
  5894. else if (dto.ExportType == 2) //表格
  5895. {
  5896. //利用键值对存放数据
  5897. Dictionary<string, string> dic = new Dictionary<string, string>();
  5898. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5899. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5900. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5901. dic.Add("Day", sp.Days.ToString());
  5902. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5903. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5904. {
  5905. //获取模板
  5906. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5907. //载入模板
  5908. Document doc = new Document(tempPath);
  5909. DocumentBuilder builder = new DocumentBuilder(doc);
  5910. dic.Add("TeamName", _DelegationInfo.TeamName);
  5911. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5912. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5913. string missionLeaderName = "",
  5914. missionLeaderJob = "";
  5915. if (DeleClientList.Count > 0)
  5916. {
  5917. missionLeaderName = DeleClientList[0].Name;
  5918. missionLeaderJob = DeleClientList[0].Job;
  5919. }
  5920. dic.Add("MissionLeaderName", missionLeaderName);
  5921. dic.Add("MissionLeaderJob", missionLeaderJob);
  5922. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5923. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5924. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5925. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5926. int rowCount = 10;//总人数行
  5927. int startRowIndex = 7; //起始行
  5928. for (int i = 0; i < DeleClientList.Count; i++)
  5929. {
  5930. builder.MoveToCell(0, startRowIndex, 0, 0);
  5931. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5932. builder.MoveToCell(0, startRowIndex, 1, 0);
  5933. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5934. builder.Write(sex);//性别
  5935. builder.MoveToCell(0, startRowIndex, 2, 0);
  5936. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5937. builder.MoveToCell(0, startRowIndex, 3, 0);
  5938. builder.Write(DeleClientList[i].Company);//工作单位
  5939. builder.MoveToCell(0, startRowIndex, 4, 0);
  5940. builder.Write(DeleClientList[i].Job);//职务及级别
  5941. builder.MoveToCell(0, startRowIndex, 5, 0);
  5942. builder.Write("");//人员属性
  5943. builder.MoveToCell(0, startRowIndex, 6, 0);
  5944. builder.Write("");//上次出国时间
  5945. startRowIndex++;
  5946. }
  5947. int nullRow = rowCount - DeleClientList.Count;//空行
  5948. for (int i = 0; i < nullRow; i++)
  5949. {
  5950. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5951. }
  5952. foreach (var key in dic.Keys)
  5953. {
  5954. builder.MoveToBookmark(key);
  5955. builder.Write(dic[key]);
  5956. }
  5957. //模板文件名
  5958. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5959. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5960. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5961. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5962. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5963. }
  5964. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5965. {
  5966. //获取模板
  5967. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5968. //载入模板
  5969. Document doc = new Document(tempPath);
  5970. DocumentBuilder builder = new DocumentBuilder(doc);
  5971. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5972. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5973. dic.Add("Names", Names);
  5974. int accommodationRows = 12;
  5975. //int foodandotherRows = 12;
  5976. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5977. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5978. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5979. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5980. int accommodationStartIndex = 6;
  5981. decimal dac1totalPrice = 0.00M;
  5982. foreach (var dac in dac1)
  5983. {
  5984. if (dac.SubTotal == 0)
  5985. {
  5986. continue;
  5987. }
  5988. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5989. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5990. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5991. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5992. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5993. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5994. builder.Write(currency);//币种
  5995. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5996. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5997. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5998. builder.Write("");//人数
  5999. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6000. builder.Write("");//天数
  6001. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6002. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6003. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6004. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6005. builder.Write(rate.ToString("#0.0000"));//汇率
  6006. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6007. decimal rbmPrice = rate * dac.SubTotal;
  6008. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6009. accommodationStartIndex++;
  6010. dac1totalPrice += rbmPrice;
  6011. }
  6012. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6013. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6014. builder.Write("小计");
  6015. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6016. builder.Write(dac1totalPrice.ToString("#0.00"));
  6017. accommodationStartIndex++;
  6018. int nullRow = accommodationRows - dac1.Count;
  6019. //删除空行
  6020. //if (nullRow > 0)
  6021. //{
  6022. // int rowIndex = accommodationStartIndex;
  6023. // for (int i = 0; i < nullRow; i++)
  6024. // {
  6025. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6026. // row.Remove();
  6027. // rowIndex++;
  6028. // }
  6029. //}
  6030. if (dac2.Count == dac3.Count)//国家 币种 金额
  6031. {
  6032. for (int i = 0; i < dac2.Count; i++)
  6033. {
  6034. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6035. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6036. }
  6037. }
  6038. int foodandotherStartIndex = 19;//
  6039. decimal dac2totalPrice = 0.00M;
  6040. foreach (var dac in dac2)
  6041. {
  6042. if (dac.SubTotal == 0)
  6043. {
  6044. continue;
  6045. }
  6046. //foodandotherStartIndex = 12;
  6047. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6048. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6049. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6050. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6051. builder.Write(currency);//币种
  6052. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6053. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6054. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6055. builder.Write("");//人数
  6056. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6057. builder.Write("");//天数
  6058. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6059. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6060. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6061. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6062. builder.Write(rate.ToString("#0.0000"));//汇率
  6063. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6064. decimal rbmPrice = rate * dac.SubTotal;
  6065. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6066. foodandotherStartIndex++;
  6067. dac2totalPrice += rbmPrice;
  6068. }
  6069. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6070. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6071. //删除空行
  6072. //if (dac2.Count < foodandotherRows)
  6073. //{
  6074. // while (table2.Rows.Count > dac2.Count)
  6075. // {
  6076. // table2.Rows.RemoveAt(dac2.Count);
  6077. // }
  6078. //}
  6079. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6080. string otherFeeStr = "";
  6081. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6082. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6083. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6084. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6085. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6086. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6087. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6088. foreach (var otherInfo in dac5)
  6089. {
  6090. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6091. }
  6092. #endregion
  6093. if (otherFeeStr.Length > 0)
  6094. {
  6095. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6096. otherFeeStr = $"({otherFeeStr})";
  6097. dic.Add("OtherFeeStr", otherFeeStr);
  6098. }
  6099. foreach (var key in dic.Keys)
  6100. {
  6101. builder.MoveToBookmark(key);
  6102. builder.Write(dic[key]);
  6103. }
  6104. //模板文件名
  6105. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6106. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6107. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6108. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6109. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6110. }
  6111. }
  6112. else if (dto.ExportType == 3)
  6113. {
  6114. if (dto.SubTypeId == 1) //团组成员名单
  6115. {
  6116. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6117. //获取模板
  6118. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6119. //载入模板
  6120. Document doc = new Document(tempPath);
  6121. DocumentBuilder builder = new DocumentBuilder(doc);
  6122. //获取word里所有表格
  6123. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6124. //获取所填表格的序数
  6125. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6126. var rowStart = tableOne.Rows[0]; //获取第1行
  6127. //循环赋值
  6128. for (int i = 0; i < DeleClientList.Count; i++)
  6129. {
  6130. builder.MoveToCell(0, i + 1, 0, 0);
  6131. builder.Write(DeleClientList[i].Name);
  6132. builder.MoveToCell(0, i + 1, 1, 0);
  6133. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6134. builder.Write(sex);
  6135. builder.MoveToCell(0, i + 1, 2, 0);
  6136. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6137. builder.MoveToCell(0, i + 1, 3, 0);
  6138. builder.Write(DeleClientList[i].Company);
  6139. builder.MoveToCell(0, i + 1, 4, 0);
  6140. builder.Write(DeleClientList[i].Job);
  6141. }
  6142. //删除多余行
  6143. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6144. {
  6145. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6146. }
  6147. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6148. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6149. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6150. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6151. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6152. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6153. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6154. }
  6155. }
  6156. return Ok(JsonView(400, "操作失败!", ""));
  6157. }
  6158. catch (Exception ex)
  6159. {
  6160. return Ok(JsonView(400, ex.Message, ""));
  6161. }
  6162. }
  6163. /// <summary>
  6164. /// 获取三公费用标准city
  6165. /// </summary>
  6166. /// <param name="placeData"></param>
  6167. /// <param name="nationalTravelFeeId"></param>
  6168. /// <returns></returns>
  6169. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6170. {
  6171. string _city = string.Empty;
  6172. if (placeData.Count < 1) return _city;
  6173. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6174. if (data == null) return _city;
  6175. string country = data.Country;
  6176. string city = data.City;
  6177. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6178. else _city = city;
  6179. return _city;
  6180. }
  6181. /// <summary>
  6182. /// 团组模块 - 出入境费用 - 明细表导出
  6183. /// </summary>
  6184. /// <returns></returns>
  6185. [HttpPost]
  6186. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6187. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6188. {
  6189. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6190. if (data.Code != 0)
  6191. {
  6192. return Ok(JsonView(false, data.Msg));
  6193. }
  6194. return Ok(JsonView(true, data.Msg, data.Data));
  6195. }
  6196. /// <summary>
  6197. /// 团组模块 - 出入境费用 - 一键清空
  6198. /// </summary>
  6199. /// <returns></returns>
  6200. [HttpPost]
  6201. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6202. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6203. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6204. {
  6205. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6206. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6207. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6208. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6209. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6210. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6211. .SetColumns(x => new Grp_DayOtherPrice
  6212. {
  6213. IsDel = 1,
  6214. DeleteUserId = dto.UserId,
  6215. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6216. })
  6217. .ExecuteCommandAsync();
  6218. if (_view.Code == 0)
  6219. {
  6220. return Ok(JsonView(true, "操作成功"));
  6221. }
  6222. return Ok(JsonView(false, "操作失败"));
  6223. }
  6224. /// <summary>
  6225. /// 团组模块 - 出入境费用 - 子项删除
  6226. /// </summary>
  6227. /// <returns></returns>
  6228. [HttpPost]
  6229. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6231. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6232. {
  6233. try
  6234. {
  6235. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6236. if (data.Code != 0)
  6237. {
  6238. return Ok(JsonView(false, data.Msg));
  6239. }
  6240. return Ok(JsonView(true, "操作成功!", data.Data));
  6241. }
  6242. catch (Exception ex)
  6243. {
  6244. return Ok(JsonView(false, ex.Message));
  6245. }
  6246. }
  6247. /// <summary>
  6248. /// 删除三公其他费用
  6249. /// </summary>
  6250. /// <param name="dto"></param>
  6251. /// <returns></returns>
  6252. [HttpPost]
  6253. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6254. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6255. {
  6256. var jw = JsonView(false, "删除失败!");
  6257. var data = new Grp_DayOtherPrice()
  6258. {
  6259. Id = dto.Id,
  6260. IsDel = 1,
  6261. DeleteUserId = dto.DeleteUserId,
  6262. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6263. };
  6264. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6265. if (del > 0)
  6266. {
  6267. jw.Code = 200;
  6268. jw.Msg = "删除成功!";
  6269. }
  6270. return Ok(jw);
  6271. }
  6272. /// <summary>
  6273. /// 团组模块 - 出入境国家费用标准 List
  6274. /// </summary>
  6275. /// <returns></returns>
  6276. [HttpPost]
  6277. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6278. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6279. {
  6280. try
  6281. {
  6282. Stopwatch sw = new Stopwatch();
  6283. sw.Start();
  6284. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6285. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6286. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6287. Where gntf.Isdel = 0");
  6288. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6289. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6290. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6291. //foreach (var item in nationalTravel)
  6292. //{
  6293. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6294. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6295. // if (otherData != null)
  6296. // {
  6297. // cityData.Remove(otherData);
  6298. // cityData.Add(otherData);
  6299. // }
  6300. // nationalTravelFeeData1.Add(new
  6301. // {
  6302. // Country = item.Country,
  6303. // CityData = cityData
  6304. // });
  6305. //}
  6306. sw.Stop();
  6307. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6308. }
  6309. catch (Exception ex)
  6310. {
  6311. return Ok(JsonView(false, ex.Message));
  6312. throw;
  6313. }
  6314. }
  6315. /// <summary>
  6316. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6317. /// </summary>
  6318. /// <returns></returns>
  6319. [HttpPost]
  6320. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6321. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6322. {
  6323. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6324. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6325. List<string> countryData = new List<string>();
  6326. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  6327. countryData = countryData.Distinct().ToList();
  6328. List<dynamic> dataSource = new List<dynamic>();
  6329. foreach (var item in countryData)
  6330. {
  6331. var cityData1 = new List<string>();
  6332. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  6333. var countryData2 = new
  6334. {
  6335. CountryName = item,
  6336. CityData = cityData1
  6337. };
  6338. dataSource.Add(countryData2);
  6339. }
  6340. return Ok(JsonView(true, "查询成功!", dataSource));
  6341. }
  6342. /// <summary>
  6343. /// 团组模块 - 出入境国家费用标准 Page List
  6344. /// </summary>
  6345. /// <returns></returns>
  6346. [HttpPost]
  6347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6348. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6349. {
  6350. int portId = dto.PortType;
  6351. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6352. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6353. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6354. string whereSql = string.Empty;
  6355. if (!string.IsNullOrEmpty(dto.Country))
  6356. {
  6357. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6358. }
  6359. if (!string.IsNullOrEmpty(dto.City))
  6360. {
  6361. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6362. }
  6363. string pageSql = string.Format(@"Select * From (
  6364. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6365. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6366. From Grp_NationalTravelFee gntf
  6367. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6368. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6369. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6370. RefAsync<int> total = 0;
  6371. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6372. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6373. }
  6374. /// <summary>
  6375. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6376. /// </summary>
  6377. /// <returns></returns>
  6378. [HttpPost]
  6379. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6380. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6381. {
  6382. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6383. int portId = dto.PortType;
  6384. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6385. string whereSql = string.Empty;
  6386. if (!string.IsNullOrEmpty(dto.Country))
  6387. {
  6388. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6389. }
  6390. if (!string.IsNullOrEmpty(dto.City))
  6391. {
  6392. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6393. }
  6394. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6395. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6396. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6397. From Grp_NationalTravelFee gntf
  6398. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6399. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6400. Where gntf.Isdel = 0 {0} ", whereSql);
  6401. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6402. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6403. }
  6404. /// <summary>
  6405. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6406. /// </summary>
  6407. /// <returns></returns>
  6408. [HttpPost]
  6409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6410. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6411. {
  6412. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6413. if (data.Code != 0)
  6414. {
  6415. return Ok(JsonView(false, data.Msg));
  6416. }
  6417. return Ok(JsonView(true, "操作成功!", data.Data));
  6418. }
  6419. /// <summary>
  6420. /// 团组模块 - 出入境国家费用标准 - Del
  6421. /// </summary>
  6422. /// <returns></returns>
  6423. [HttpPost]
  6424. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6425. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6426. {
  6427. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6428. {
  6429. Id = dto.Id,
  6430. DeleteUserId = dto.DeleteUserId,
  6431. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6432. IsDel = 1
  6433. };
  6434. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6435. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6436. .WhereColumns(it => new { it.Id })
  6437. .ExecuteCommandAsync();
  6438. if (delStatus <= 0)
  6439. {
  6440. return Ok(JsonView(false, "删除失败!"));
  6441. }
  6442. return Ok(JsonView(true, "操作成功!"));
  6443. }
  6444. /// <summary>
  6445. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6446. /// 注:Get 请求Headers 加 Token
  6447. /// </summary>
  6448. /// <param name="groupId"></param>
  6449. /// <returns></returns>
  6450. [HttpGet("{groupId}")]
  6451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6452. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6453. {
  6454. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6455. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6456. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6457. data.ForEach(x =>
  6458. {
  6459. x.CreateUserId = _currUserInfo.UserId;
  6460. });
  6461. if (data.Any())
  6462. {
  6463. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6464. if (add > 0)
  6465. {
  6466. return Ok(JsonView(true, "操作成功!"));
  6467. }
  6468. }
  6469. return Ok(JsonView(false, "未操作!"));
  6470. }
  6471. #endregion
  6472. #region 团组经理模块 出入境费用-草稿
  6473. /// <summary>
  6474. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6475. /// </summary>
  6476. /// <returns></returns>
  6477. [HttpPost]
  6478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6479. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6480. {
  6481. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6482. .Where(x => x.IsDel == 0)
  6483. .OrderByDescending(x => x.CreateTime)
  6484. .Select(x => new { x.Id, x.DraftName })
  6485. .ToListAsync();
  6486. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6487. //SetDataInfoView
  6488. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6489. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6490. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6491. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6492. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6493. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6494. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6495. //默认币种显示
  6496. List<CurrencyInfo> _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6497. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6498. return Ok(JsonView(true, "查询成功!", new
  6499. {
  6500. DraftNameDatas = draftNameDatas,
  6501. CurrencyData = _CurrencyData,
  6502. WordTypeData = _WordTypeData,
  6503. ExcelTypeData = _ExcelTypeData,
  6504. CurrencyInit = _currencyInfos,
  6505. ViewPermissionData = viewPermissionData
  6506. }));
  6507. }
  6508. /// <summary>
  6509. /// 团组模块 - 出入境费用-草稿
  6510. /// 实时汇率 tips
  6511. /// 签证费用 tips
  6512. /// 机票费用 tips
  6513. /// </summary>
  6514. /// <returns></returns>
  6515. [HttpPost]
  6516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6517. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6518. {
  6519. //var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6520. //默认币种显示
  6521. var _currencyInfos = _currencyInit;
  6522. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  6523. List<dynamic> reteInfos = new List<dynamic>();
  6524. if (_currencyRate.Count > 0)
  6525. {
  6526. foreach (var item in _currencyInfos)
  6527. {
  6528. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6529. if (rateInfo != null)
  6530. {
  6531. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6532. decimal rate1 = item.Rate;
  6533. rate1 *= 1.03M;
  6534. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6535. reteInfos.Add(new
  6536. {
  6537. currCode = item.CurrencyCode,
  6538. currName = item.CurrencyName,
  6539. rate = rate2,
  6540. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6541. });
  6542. }
  6543. }
  6544. }
  6545. //var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  6546. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6547. return Ok(JsonView(true, "查询成功!", new
  6548. {
  6549. //GroupNameData = groupNameData.Data,
  6550. //visaData = visaData.Data,
  6551. //airData = airData.Data,
  6552. reteInfos = reteInfos
  6553. }));
  6554. }
  6555. /// <summary>
  6556. /// 团组模块 - 出入境费用-草稿 - Info
  6557. /// </summary>
  6558. /// <returns></returns>
  6559. [HttpPost]
  6560. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  6561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6562. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6563. {
  6564. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6565. }
  6566. /// <summary>
  6567. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6568. /// </summary>
  6569. /// <returns></returns>
  6570. [HttpPost]
  6571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6572. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6573. {
  6574. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6575. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6576. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6577. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6578. foreach (var userId in dto.UserIds)
  6579. {
  6580. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6581. }
  6582. if (permissions.Any())
  6583. {
  6584. _sqlSugar.BeginTran();
  6585. try
  6586. {
  6587. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6588. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6589. if (result < 1)
  6590. {
  6591. _sqlSugar.RollbackTran();
  6592. return Ok(JsonView(false));
  6593. }
  6594. }
  6595. catch (Exception ex)
  6596. {
  6597. _sqlSugar.RollbackTran();
  6598. return Ok(JsonView(false, ex.Message));
  6599. }
  6600. _sqlSugar.CommitTran();
  6601. return Ok(JsonView(true));
  6602. }
  6603. return Ok(JsonView(false));
  6604. }
  6605. /// <summary>
  6606. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6607. /// </summary>
  6608. /// <returns></returns>
  6609. [HttpPost]
  6610. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  6611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6612. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6613. {
  6614. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6615. if (data.Code != 0)
  6616. {
  6617. return Ok(JsonView(false, data.Msg));
  6618. }
  6619. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6620. //汇率信息记录
  6621. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6622. return Ok(JsonView(true, data.Msg, data.Data));
  6623. }
  6624. /// <summary>
  6625. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6626. /// </summary>
  6627. /// <param name="dto"></param>
  6628. /// <returns></returns>
  6629. [HttpPost]
  6630. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  6631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6632. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6633. {
  6634. try
  6635. {
  6636. var id = dto.Id;
  6637. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6638. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6639. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6640. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6641. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6642. 3 团组成员名单 1 团组成员名单", ""));
  6643. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6644. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6645. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6646. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6647. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6648. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6649. //数据源
  6650. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6651. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6652. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6653. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6654. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6655. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6656. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6657. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6658. .Select((x, a, b) => new
  6659. {
  6660. x.Index,
  6661. itemName = a.Name,
  6662. CurrencyStr = b.Name,
  6663. x.Cost,
  6664. x.SubTotal,
  6665. x.Remark
  6666. })
  6667. .OrderBy((x) => x.Index)
  6668. .ToList(); //其他款项费用
  6669. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6670. var peiceItemCurrencys = new List<string>();
  6671. if (_DayAndCosts.Any())
  6672. {
  6673. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6674. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6675. }
  6676. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6677. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6678. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6679. {
  6680. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6681. }
  6682. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6683. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6684. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6685. if (dto.ExportType == 1) //明细表
  6686. {
  6687. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6688. {
  6689. //获取模板
  6690. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6691. //载入模板
  6692. Document doc = new Document(tempPath);
  6693. DocumentBuilder builder = new DocumentBuilder(doc);
  6694. //利用键值对存放数据
  6695. Dictionary<string, string> dic = new Dictionary<string, string>();
  6696. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6697. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6698. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6699. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6700. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6701. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6702. //境内费用(其他费用)
  6703. if (_EnterExitCosts.ChoiceOne == 1)
  6704. {
  6705. string row1_1 = "";
  6706. if (_EnterExitCosts.Visa > 0)
  6707. {
  6708. //insidePayTotal += _EnterExitCosts.Visa;
  6709. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6710. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6711. {
  6712. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6713. }
  6714. }
  6715. string row1_2 = "";
  6716. if (_EnterExitCosts.YiMiao > 0)
  6717. {
  6718. //insidePayTotal += _EnterExitCosts.YiMiao;
  6719. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6720. }
  6721. if (_EnterExitCosts.HeSuan > 0)
  6722. {
  6723. //insidePayTotal += _EnterExitCosts.HeSuan;
  6724. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6725. }
  6726. if (_EnterExitCosts.Service > 0)
  6727. {
  6728. //insidePayTotal += _EnterExitCosts.Service;
  6729. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6730. }
  6731. string row1_3 = "";
  6732. if (_EnterExitCosts.Safe > 0)
  6733. {
  6734. //insidePayTotal += _EnterExitCosts.Safe;
  6735. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6736. }
  6737. if (_EnterExitCosts.Ticket > 0)
  6738. {
  6739. //insidePayTotal += _EnterExitCosts.Ticket;
  6740. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6741. }
  6742. string row1 = "";
  6743. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6744. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6745. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6746. row1 += $"备注:{_EnterExitCosts.Remark}";
  6747. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6748. dic.Add("Row1Str", row1);
  6749. }
  6750. string airTotalStr = string.Empty,
  6751. airPriceStr = string.Empty;
  6752. //经济舱
  6753. if (_EnterExitCosts.SumJJC == 1)
  6754. {
  6755. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6756. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6757. }
  6758. //公务舱
  6759. if (_EnterExitCosts.SumGWC == 1)
  6760. {
  6761. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6762. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6763. }
  6764. //头等舱
  6765. if (_EnterExitCosts.SumTDC == 1)
  6766. {
  6767. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6768. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6769. }
  6770. //汇率描述
  6771. string rateStr = "";
  6772. if (peiceItemCurrencyInfos.Any())
  6773. {
  6774. rateStr = "\r\n汇率描述:";
  6775. foreach (var item in peiceItemCurrencyInfos)
  6776. {
  6777. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6778. }
  6779. }
  6780. string twoItemRemark = "备注:";
  6781. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6782. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6783. dic.Add("AirTotalStr", airTotalStr);
  6784. dic.Add("AirPriceStr", airPriceStr);
  6785. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6786. dic.Add("TwoItemRemark", twoItemRemark);
  6787. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6788. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6789. int table1Row = 0,
  6790. table2Row = 0,
  6791. table3Row = 0,
  6792. table4Row = 0,
  6793. table5Row = 0;
  6794. //住宿费
  6795. if (_EnterExitCosts.ChoiceThree == 1)
  6796. {
  6797. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6798. table1Row = dac1.Count;
  6799. #region 填充word表格内容
  6800. for (int i = 0; i < dac1.Count; i++)
  6801. {
  6802. var dac = dac1[i];
  6803. if (dac == null) continue;
  6804. builder.MoveToCell(0, i, 0, 0);
  6805. builder.Write("第" + dac.Days.ToString() + "晚:");
  6806. builder.MoveToCell(0, i, 1, 0);
  6807. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6808. //builder.Write(dac.Place == null ? "" : dac.Place);
  6809. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6810. builder.MoveToCell(0, i, 2, 0);
  6811. builder.Write("费用标准:");
  6812. string curr = "";
  6813. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6814. if (currData != null)
  6815. {
  6816. curr = currData.Name;
  6817. }
  6818. builder.MoveToCell(0, i, 3, 0);
  6819. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6820. builder.MoveToCell(0, i, 4, 0);
  6821. builder.Write("费用小计:");
  6822. builder.MoveToCell(0, i, 5, 0);
  6823. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6824. }
  6825. #endregion
  6826. }
  6827. else dic.Add("SubZS", "0.00");
  6828. //删除多余行
  6829. while (table1.Rows.Count > table1Row)
  6830. {
  6831. table1.Rows.RemoveAt(table1Row);
  6832. }
  6833. //伙食费
  6834. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6835. if (_EnterExitCosts.ChoiceFour == 1)
  6836. {
  6837. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6838. table2Row = dac2.Count;
  6839. #region 填充word表格内容
  6840. for (int i = 0; i < dac2.Count; i++)
  6841. {
  6842. var dac = dac2[i];
  6843. if (dac == null) continue;
  6844. builder.MoveToCell(1, i, 0, 0);
  6845. builder.Write("第" + dac.Days.ToString() + "天:");
  6846. builder.MoveToCell(1, i, 1, 0);
  6847. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6848. builder.MoveToCell(1, i, 2, 0);
  6849. builder.Write("费用标准:");
  6850. string curr = "";
  6851. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6852. if (currData != null)
  6853. {
  6854. curr = currData.Name;
  6855. }
  6856. builder.MoveToCell(1, i, 3, 0);
  6857. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6858. builder.MoveToCell(1, i, 4, 0);
  6859. builder.Write("费用小计:");
  6860. builder.MoveToCell(1, i, 5, 0);
  6861. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6862. }
  6863. #endregion
  6864. }
  6865. else dic.Add("SubHS", "0.00");
  6866. //删除多余行
  6867. while (table2.Rows.Count > table2Row)
  6868. {
  6869. table2.Rows.RemoveAt(table2Row);
  6870. }
  6871. //公杂费
  6872. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6873. if (_EnterExitCosts.ChoiceFive == 1)
  6874. {
  6875. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6876. table3Row = dac3.Count;
  6877. #region 填充word表格内容
  6878. for (int i = 0; i < dac3.Count; i++)
  6879. {
  6880. var dac = dac3[i];
  6881. if (dac == null) continue;
  6882. builder.MoveToCell(2, i, 0, 0);
  6883. builder.Write("第" + dac.Days.ToString() + "天:");
  6884. builder.MoveToCell(2, i, 1, 0);
  6885. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6886. builder.MoveToCell(2, i, 2, 0);
  6887. builder.Write("费用标准:");
  6888. string curr = "";
  6889. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6890. if (currData != null)
  6891. {
  6892. curr = currData.Name;
  6893. }
  6894. builder.MoveToCell(2, i, 3, 0);
  6895. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6896. builder.MoveToCell(2, i, 4, 0);
  6897. builder.Write("费用小计:");
  6898. builder.MoveToCell(2, i, 5, 0);
  6899. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6900. }
  6901. //删除多余行
  6902. while (table3.Rows.Count > table3Row)
  6903. {
  6904. table3.Rows.RemoveAt(table3Row);
  6905. }
  6906. #endregion
  6907. }
  6908. else dic.Add("SubGZF", "0.00");
  6909. //删除多余行
  6910. while (table3.Rows.Count > table3Row)
  6911. {
  6912. table3.Rows.RemoveAt(table3Row);
  6913. }
  6914. //培训费
  6915. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6916. if (_EnterExitCosts.ChoiceSix == 1)
  6917. {
  6918. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6919. dic.Add("SubPX", pxStr);
  6920. table4Row = dac4.Count;
  6921. #region 填充word表格内容
  6922. for (int i = 0; i < dac4.Count; i++)
  6923. {
  6924. var dac = dac4[i];
  6925. if (dac == null) continue;
  6926. builder.MoveToCell(3, i, 0, 0);
  6927. builder.Write("第" + dac.Days.ToString() + "天:");
  6928. builder.MoveToCell(3, i, 1, 0);
  6929. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6930. builder.MoveToCell(3, i, 2, 0);
  6931. builder.Write("费用标准:");
  6932. string curr = "";
  6933. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6934. if (currData != null)
  6935. {
  6936. curr = currData.Name;
  6937. }
  6938. builder.MoveToCell(3, i, 3, 0);
  6939. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6940. builder.MoveToCell(3, i, 4, 0);
  6941. builder.Write("费用小计:");
  6942. builder.MoveToCell(3, i, 5, 0);
  6943. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6944. }
  6945. #endregion
  6946. }
  6947. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  6948. //删除多余行
  6949. while (table4.Rows.Count > table4Row)
  6950. {
  6951. table4.Rows.RemoveAt(table4Row);
  6952. }
  6953. //其他费用
  6954. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6955. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6956. {
  6957. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6958. dic.Add("titleQi", qtStr);
  6959. table5Row = dac5.Count;
  6960. #region 填充word表格内容
  6961. for (int i = 0; i < dac5.Count; i++)
  6962. {
  6963. var dac = dac5[i];
  6964. if (dac == null) continue;
  6965. builder.MoveToCell(4, i, 0, 0);
  6966. builder.Write("第" + dac.Index.ToString() + "项:");
  6967. builder.MoveToCell(4, i, 1, 0);
  6968. builder.Write(dac.itemName);
  6969. builder.MoveToCell(4, i, 2, 0);
  6970. builder.Write("费用标准:");
  6971. builder.MoveToCell(4, i, 3, 0);
  6972. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6973. builder.MoveToCell(4, i, 4, 0);
  6974. builder.Write("费用小计:");
  6975. builder.MoveToCell(4, i, 5, 0);
  6976. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6977. builder.MoveToCell(4, i, 6, 0);
  6978. builder.Write("备注:");
  6979. builder.MoveToCell(4, i, 7, 0);
  6980. builder.Write(dac.Remark);
  6981. }
  6982. #endregion
  6983. }
  6984. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6985. //删除多余行
  6986. while (table5.Rows.Count > table5Row)
  6987. {
  6988. table5.Rows.RemoveAt(table5Row);
  6989. }
  6990. //加上其他费用
  6991. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6992. decimal subJJC = 0.00M,
  6993. subGWC = 0.00M,
  6994. subTDC = 0.00M;
  6995. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6996. string totalLabel = string.Format("全部费用总计:");
  6997. //经济舱
  6998. if (_EnterExitCosts.SumJJC == 1)
  6999. {
  7000. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7001. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  7002. }
  7003. //公务舱
  7004. if (_EnterExitCosts.SumGWC == 1)
  7005. {
  7006. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7007. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  7008. }
  7009. //头等舱
  7010. if (_EnterExitCosts.SumTDC == 1)
  7011. {
  7012. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7013. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  7014. }
  7015. //TotalLabel
  7016. dic.Add("TotalLabel", totalLabel);
  7017. #region 填充word模板书签内容
  7018. foreach (var key in dic.Keys)
  7019. {
  7020. Bookmark bookmark = doc.Range.Bookmarks[key];
  7021. if (bookmark != null)
  7022. {
  7023. builder.MoveToBookmark(key);
  7024. builder.Write(dic[key]);
  7025. }
  7026. }
  7027. #endregion
  7028. //文件名
  7029. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7030. strFileName = CommonFun.ValidFileName(strFileName);
  7031. AsposeHelper.removewatermark_v2180();
  7032. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7033. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7034. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7035. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7036. }
  7037. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7038. {
  7039. //获取模板
  7040. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7041. //载入模板
  7042. Document doc = new Document(tempPath);
  7043. DocumentBuilder builder = new DocumentBuilder(doc);
  7044. Dictionary<string, string> dic = new Dictionary<string, string>();
  7045. string returnCodeLabel = string.Empty;
  7046. if (nationalTravelFeeData.Any())
  7047. {
  7048. List<string> list = new List<string>();
  7049. foreach (var item in nationalTravelFeeData)
  7050. {
  7051. list.Add($"{item.Country}({item.City})");
  7052. }
  7053. list = list.Distinct().ToList();
  7054. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7055. }
  7056. var countryLabel = string.Empty;
  7057. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7058. if (countryData.Any())
  7059. {
  7060. countryLabel = string.Join("、", countryData);
  7061. }
  7062. dic.Add("ReturnCodeAir", returnCodeLabel);
  7063. dic.Add("VisitStartDate", "-");
  7064. dic.Add("VisitEndDate", "-");
  7065. dic.Add("Day", "-");
  7066. dic.Add("VisitCountry", countryLabel);
  7067. dic.Add("ClientUnit", "-");
  7068. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7069. //dic.Add("Names", Names);
  7070. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7071. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7072. decimal dac1totalPrice = 0.00M;
  7073. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7074. foreach (var dac in dac1)
  7075. {
  7076. if (dac.SubTotal == 0.00M)
  7077. {
  7078. continue;
  7079. }
  7080. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7081. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7082. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7083. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7084. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7085. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7086. builder.Write(currency);//币种
  7087. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7088. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7089. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7090. builder.Write("");//人数
  7091. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7092. builder.Write("");//天数
  7093. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7094. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7095. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7096. decimal rate = 0.00M;
  7097. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7098. builder.Write(rate.ToString("#0.0000"));//汇率
  7099. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7100. decimal rbmPrice = dac.SubTotal;
  7101. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7102. accommodationStartIndex++;
  7103. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7104. }
  7105. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7106. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7107. {
  7108. table1.Rows.RemoveAt(i - 1);
  7109. foodandotherStartIndex--;
  7110. }
  7111. if (dac2.Count == dac3.Count)//国家 币种 金额
  7112. {
  7113. for (int i = 0; i < dac2.Count; i++)
  7114. {
  7115. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7116. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7117. }
  7118. }
  7119. decimal dac2totalPrice = 0.00M;
  7120. foreach (var dac in dac2)
  7121. {
  7122. if (dac.SubTotal == 0)
  7123. {
  7124. continue;
  7125. }
  7126. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7127. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7128. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7129. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7130. builder.Write(currency);//币种
  7131. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7132. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7133. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7134. builder.Write("");//人数
  7135. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7136. builder.Write("");//天数
  7137. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7138. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7139. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7140. decimal rate = 0.00M;
  7141. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7142. builder.Write(rate.ToString("#0.0000"));//汇率
  7143. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7144. decimal rbmPrice = dac.SubTotal;
  7145. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7146. foodandotherStartIndex++;
  7147. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7148. }
  7149. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7150. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7151. {
  7152. table1.Rows.RemoveAt(i - 1);
  7153. }
  7154. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7155. string otherFeeStr = "";
  7156. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7157. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7158. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7159. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7160. foreach (var otherInfo in dac5)
  7161. {
  7162. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7163. }
  7164. #endregion
  7165. if (otherFeeStr.Length > 0)
  7166. {
  7167. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7168. otherFeeStr = $"({otherFeeStr})";
  7169. dic.Add("OtherFeeStr", otherFeeStr);
  7170. }
  7171. //总计
  7172. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7173. //国际旅费
  7174. string outsideAir = string.Empty;
  7175. string allPriceAir = string.Empty;
  7176. if (_EnterExitCosts.SumJJC == 1)
  7177. {
  7178. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7179. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7180. }
  7181. if (_EnterExitCosts.SumGWC == 1)
  7182. {
  7183. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7184. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7185. }
  7186. if (_EnterExitCosts.SumTDC == 1)
  7187. {
  7188. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7189. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7190. }
  7191. dic.Add("InTravelPrice", $"({outsideAir})");
  7192. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7193. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7194. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7195. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7196. foreach (var key in dic.Keys)
  7197. {
  7198. builder.MoveToBookmark(key);
  7199. builder.Write(dic[key]);
  7200. }
  7201. //模板文件名
  7202. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7203. strFileName = CommonFun.ValidFileName(strFileName);
  7204. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7205. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7206. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7207. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7208. }
  7209. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7210. {
  7211. //获取模板
  7212. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7213. //载入模板
  7214. WorkbookDesigner designer = new WorkbookDesigner();
  7215. designer.Workbook = new Workbook(tempPath);
  7216. Dictionary<string, string> dic = new Dictionary<string, string>();
  7217. string returnCodeLabel = string.Empty;
  7218. if (nationalTravelFeeData.Any())
  7219. {
  7220. List<string> list = new List<string>();
  7221. foreach (var item in nationalTravelFeeData)
  7222. {
  7223. list.Add($"{item.Country}({item.City})");
  7224. }
  7225. list = list.Distinct().ToList();
  7226. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7227. }
  7228. var countryLabel = string.Empty;
  7229. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7230. if (countryData.Any())
  7231. {
  7232. countryLabel = string.Join("、", countryData);
  7233. }
  7234. dic.Add("ReturnCodeAir", returnCodeLabel);
  7235. dic.Add("VisitStartDate", "-");
  7236. dic.Add("VisitEndDate", "-");
  7237. dic.Add("Day", "0");
  7238. dic.Add("VisitCountry", countryLabel);
  7239. dic.Add("ClientUnit", "-");
  7240. designer.SetDataSource("ClientUnit", "-");
  7241. designer.SetDataSource("VisitCountry", countryLabel);
  7242. designer.SetDataSource("Group", "-");
  7243. designer.SetDataSource("ClientUnitTitle", "-");
  7244. designer.SetDataSource("Name", "-");
  7245. designer.SetDataSource("VisitStartDate", "-");
  7246. designer.SetDataSource("Day", "0");
  7247. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7248. designer.SetDataSource("ReturnCodeAir", "-");
  7249. int startIndex = 10;
  7250. const int startIndexcopy = 10;
  7251. if (dac2.Count == dac3.Count)//国家 币种 金额
  7252. {
  7253. for (int i = 0; i < dac2.Count; i++)
  7254. {
  7255. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7256. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7257. }
  7258. }
  7259. DataTable dtdac1 = new DataTable();
  7260. List<string> place = new List<string>();
  7261. dtdac1.Columns.AddRange(new DataColumn[] {
  7262. new DataColumn(){ ColumnName = "city"},
  7263. new DataColumn(){ ColumnName = "curr"},
  7264. new DataColumn(){ ColumnName = "criterion"},
  7265. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7266. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7267. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7268. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7269. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7270. });
  7271. DataTable dtdac2 = new DataTable();
  7272. dtdac2.Columns.AddRange(new DataColumn[] {
  7273. new DataColumn(){ ColumnName = "city"},
  7274. new DataColumn(){ ColumnName = "curr"},
  7275. new DataColumn(){ ColumnName = "criterion"},
  7276. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7277. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7278. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7279. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7280. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7281. });
  7282. dtdac1.TableName = "tb1";
  7283. dtdac2.TableName = "tb2";
  7284. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7285. foreach (var item in dac1)
  7286. {
  7287. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7288. if (place.Contains(item.Place))
  7289. {
  7290. continue;
  7291. }
  7292. DataRow row = dtdac1.NewRow();
  7293. row["city"] = item.Place;
  7294. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7295. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7296. row["curr"] = currency;
  7297. row["rate"] = rate.ToString("#0.0000");
  7298. row["criterion"] = item.Cost.ToString("#0.00");
  7299. row["number"] = 1;
  7300. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7301. //row["costRMB"] = rbmPrice;
  7302. dtdac1.Rows.Add(row);
  7303. place.Add(item.Place);
  7304. }
  7305. place = new List<string>();
  7306. foreach (var item in dac2)
  7307. {
  7308. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7309. if (place.Contains(item.Place))
  7310. {
  7311. continue;
  7312. }
  7313. DataRow row = dtdac2.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"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7322. //row["cost"] = item.SubTotal;
  7323. //row["costRMB"] = rbmPrice;
  7324. dtdac2.Rows.Add(row);
  7325. place.Add(item.Place);
  7326. //dac2totalPrice += rbmPrice;
  7327. }
  7328. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7329. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7330. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7331. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7332. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7333. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7334. string cell4Str1 = string.Empty;
  7335. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7336. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7337. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7338. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7339. string cellStr = $" 5.其他费用(";
  7340. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7341. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7342. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7343. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7344. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7345. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7346. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7347. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7348. foreach (var otherInfo in dac5)
  7349. {
  7350. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7351. }
  7352. #endregion
  7353. if (cellStr.Length > 8)
  7354. {
  7355. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7356. }
  7357. cellStr += ")";
  7358. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7359. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7360. decimal pxFee = dac4.Sum(it => it.Cost);
  7361. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7362. string celllastStr1 = "";
  7363. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7364. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7365. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7366. celllastStr1 += $",国际旅费 元";
  7367. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7368. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7369. designer.SetDataSource("cell4Str", cell4Str);
  7370. designer.SetDataSource("cellStr", cellStr);
  7371. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7372. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7373. designer.SetDataSource("celllastStr", celllastStr);
  7374. Workbook wb = designer.Workbook;
  7375. var sheet = wb.Worksheets[0];
  7376. //绑定datatable数据集
  7377. designer.SetDataSource(dtdac1);
  7378. designer.SetDataSource(dtdac2);
  7379. designer.Process();
  7380. var rowStart = dtdac1.Rows.Count;
  7381. while (rowStart > 0)
  7382. {
  7383. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7384. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7385. startIndex++;
  7386. rowStart--;
  7387. }
  7388. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7389. startIndex += 1; //总计行
  7390. rowStart = dtdac2.Rows.Count;
  7391. while (rowStart > 0)
  7392. {
  7393. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7394. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7395. startIndex++;
  7396. rowStart--;
  7397. }
  7398. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7399. wb.CalculateFormula(true);
  7400. //模板文件名
  7401. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7402. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7403. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7404. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7405. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7406. }
  7407. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7408. {
  7409. //获取模板
  7410. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7411. //载入模板
  7412. Document doc = new Document(tempPath);
  7413. DocumentBuilder builder = new DocumentBuilder(doc);
  7414. Dictionary<string, string> dic = new Dictionary<string, string>();
  7415. dic.Add("GroupName", "-");
  7416. dic.Add("ClientUnit", "-");
  7417. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7418. //string missionLeaderJob = "";//负责人job
  7419. //int groupNumber = 0; //团人数
  7420. dic.Add("MissionLeader", "-"); //团负责人
  7421. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7422. dic.Add("GroupNumber", "0"); //团人数
  7423. dic.Add("Day", "0");
  7424. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7425. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7426. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7427. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7428. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7429. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7430. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7431. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7432. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7433. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7434. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7435. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7436. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7437. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7438. //其他费用
  7439. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7440. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7441. //其他费用合计
  7442. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7443. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7444. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7445. //公务舱合计
  7446. //国际旅费
  7447. //string outsideJJ = "";
  7448. //string allPriceJJ = "";
  7449. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7450. {
  7451. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7452. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7453. }
  7454. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7455. {
  7456. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7457. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7458. }
  7459. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7460. {
  7461. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7462. dic.Add("AirFeeTotal", airFeeTotalStr);
  7463. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7464. dic.Add("FeeTotal", feeTotalStr);
  7465. }
  7466. foreach (var key in dic.Keys)
  7467. {
  7468. builder.MoveToBookmark(key);
  7469. builder.Write(dic[key]);
  7470. }
  7471. //模板文件名
  7472. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7473. strFileName = CommonFun.ValidFileName(strFileName);
  7474. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7475. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7476. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7477. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7478. }
  7479. }
  7480. else if (dto.ExportType == 2) //表格
  7481. {
  7482. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7483. }
  7484. else if (dto.ExportType == 3)
  7485. {
  7486. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7487. }
  7488. return Ok(JsonView(400, "只可导出明细表!", ""));
  7489. }
  7490. catch (Exception ex)
  7491. {
  7492. return Ok(JsonView(400, ex.Message, ""));
  7493. }
  7494. }
  7495. /// <summary>
  7496. /// 获取三公费用标准city
  7497. /// </summary>
  7498. /// <param name="placeData"></param>
  7499. /// <param name="nationalTravelFeeId"></param>
  7500. /// <returns></returns>
  7501. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7502. {
  7503. string _city = string.Empty;
  7504. if (!placeData.Any()) return _city;
  7505. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7506. if (data == null) return _city;
  7507. string country = data.Country;
  7508. string city = data.City;
  7509. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7510. else _city = city;
  7511. return _city;
  7512. }
  7513. /// <summary>
  7514. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7515. /// </summary>
  7516. /// <returns></returns>
  7517. [HttpPost]
  7518. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7519. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7520. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7521. {
  7522. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7523. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7524. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7525. if (_view.Code == 0)
  7526. {
  7527. return Ok(JsonView(true, "操作成功"));
  7528. }
  7529. return Ok(JsonView(false, "操作失败"));
  7530. }
  7531. /// <summary>
  7532. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7533. /// </summary>
  7534. /// <returns></returns>
  7535. [HttpPost]
  7536. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7537. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7538. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7539. {
  7540. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7541. if (data.Code != 0)
  7542. {
  7543. return Ok(JsonView(false, data.Msg));
  7544. }
  7545. return Ok(JsonView(true, "操作成功!", data.Data));
  7546. }
  7547. /// <summary>
  7548. /// 三公其他费用草稿 删除
  7549. /// </summary>
  7550. /// <param name="dto"></param>
  7551. /// <returns></returns>
  7552. [HttpPost]
  7553. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7554. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7555. {
  7556. var jw = JsonView(false, "删除失败!");
  7557. var data = new Grp_DayOtherPriceDraft()
  7558. {
  7559. Id = dto.Id,
  7560. IsDel = 1,
  7561. DeleteUserId = dto.DeleteUserId,
  7562. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7563. };
  7564. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7565. if (del > 0)
  7566. {
  7567. jw.Code = 200;
  7568. jw.Msg = "删除成功!";
  7569. }
  7570. return Ok(jw);
  7571. }
  7572. /// <summary>
  7573. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7574. /// </summary>
  7575. /// <returns></returns>
  7576. [HttpPost]
  7577. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7578. {
  7579. var jw = JsonView(false);
  7580. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7581. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  7582. jw.Code = StatusCodes.Status200OK;
  7583. jw.Msg = "操作成功!";
  7584. jw.Data = new { groupNameDatas = groupNameDatas.Data, draftNames = draftDatas };
  7585. return Ok(jw);
  7586. }
  7587. /// <summary>
  7588. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7589. /// </summary>
  7590. /// <param name="dto"></param>
  7591. /// <returns></returns>
  7592. [HttpPost]
  7593. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7594. {
  7595. int userId = dto.UserId,
  7596. portId = dto.PortType,
  7597. groupId = dto.GroupId,
  7598. draftId = dto.DraftId;
  7599. _portTypeData.Add(1);
  7600. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7601. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7602. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7603. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7604. _sqlSugar.BeginTran();
  7605. try
  7606. {
  7607. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7608. if (draftDatas == null)
  7609. {
  7610. _sqlSugar.RollbackTran();
  7611. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7612. }
  7613. //验证可覆盖已有数据 两边创建人需为同一人;
  7614. int draftCreateUserId = draftDatas.CreateUserId,
  7615. formalCreateUserId = 0;
  7616. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7617. if (formalData != null)
  7618. {
  7619. formalCreateUserId = formalData.CreateUserId;
  7620. if (draftCreateUserId != formalCreateUserId)
  7621. {
  7622. _sqlSugar.RollbackTran();
  7623. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7624. }
  7625. }
  7626. //默认添加查看、编辑权限(创建人、自己)
  7627. await _enterExitCostRep.InitPerm(dto.GroupId,dto.UserId);
  7628. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7629. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7630. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7631. newExterData.DiId = groupId;
  7632. newExterData.CreateUserId = userId;
  7633. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7634. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7635. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7636. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7637. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7638. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7639. //数据如果存在执行删除
  7640. if (enterExitCostInfo != null)
  7641. {
  7642. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7643. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7644. .Where(x => x.Id == enterExitCostInfo.Id)
  7645. .ExecuteCommand();
  7646. _sqlSugar.Updateable<Grp_DayAndCost>()
  7647. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7648. .Where(x => x.DiId == groupId)
  7649. .ExecuteCommand();
  7650. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7651. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7652. .Where(x => x.Diid == groupId)
  7653. .ExecuteCommand();
  7654. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7655. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7656. .Where(x => x.GroupId == groupId)
  7657. .ExecuteCommand();
  7658. }
  7659. //执行insert
  7660. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7661. if (insertId < 1)
  7662. {
  7663. _sqlSugar.RollbackTran();
  7664. return Ok(JsonView(false, "草稿数据导入失败!"));
  7665. }
  7666. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7667. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7668. #region 默认添加权限
  7669. #endregion
  7670. _sqlSugar.CommitTran();
  7671. //执行操作之后
  7672. //生成默认文件pdf并且通知人员
  7673. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7674. {
  7675. DiId = groupId,
  7676. ExportType = 1,
  7677. SubTypeId = 1005
  7678. }, "pdf");
  7679. //发送通知
  7680. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7681. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7682. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7683. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7684. //汇率信息记录
  7685. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7686. return Ok(JsonView(true));
  7687. }
  7688. catch (Exception ex)
  7689. {
  7690. _sqlSugar.RollbackTran();
  7691. return Ok(JsonView(false, ex.Message));
  7692. }
  7693. }
  7694. #endregion
  7695. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7696. /// <summary>
  7697. /// 获取币种基础数据(含逻辑处理)
  7698. /// </summary>
  7699. /// <returns></returns>
  7700. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7701. {
  7702. return await GeneralMethod.EnterExitCostInitRate();
  7703. }
  7704. /// <summary>
  7705. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7706. /// </summary>
  7707. /// <returns></returns>
  7708. [HttpPost]
  7709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7710. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7711. {
  7712. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7713. //SetDataInfoView
  7714. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7715. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7716. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7717. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7718. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7719. //默认币种显示
  7720. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7721. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7722. return Ok(JsonView(true, "查询成功!", new
  7723. {
  7724. WordTypeData = _WordTypeData,
  7725. ExcelTypeData = _ExcelTypeData,
  7726. CurrencyInit = _currencyInfos,
  7727. viewPermissionData = viewPermissionData
  7728. }));
  7729. }
  7730. /// <summary>
  7731. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7732. /// </summary>
  7733. /// <returns></returns>
  7734. [HttpPost]
  7735. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7736. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7737. {
  7738. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7739. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7740. RefAsync<int> total = 0;
  7741. int diId = 0;
  7742. var status = int.TryParse(dto.GroupName, out diId);
  7743. string sql = string.Format(@"SELECT
  7744. Id,
  7745. TeamName GroupName,
  7746. CASE WHEN EXISTS (
  7747. SELECT
  7748. 1
  7749. FROM
  7750. Grp_EnterExitCost
  7751. WHERE
  7752. IsDel = 0
  7753. AND DiId = di.Id
  7754. ) THEN 1 ELSE 0 END AS [IsNull],
  7755. CASE WHEN EXISTS(
  7756. SELECT
  7757. TOP 1 *
  7758. FROM
  7759. Grp_EnterExitCost
  7760. WHERE
  7761. IsDel = 0
  7762. AND DiId = di.Id
  7763. AND CreateUserId = {0}
  7764. ORDER BY
  7765. CreateTime DESC
  7766. ) THEN 1 ELSE 0 END AS [IsEdit],
  7767. CASE WHEN EXISTS(
  7768. SELECT
  7769. TOP 1 *
  7770. FROM
  7771. Grp_EnterExitCost
  7772. WHERE
  7773. IsDel = 0
  7774. AND DiId = di.Id
  7775. AND CreateUserId = {0}
  7776. ORDER BY
  7777. CreateTime DESC
  7778. ) THEN 1 WHEN EXISTS(
  7779. SELECT
  7780. TOP 1 *
  7781. FROM
  7782. Grp_EnterExitCostPermission
  7783. WHERE
  7784. IsDel = 0
  7785. AND GroupId = di.Id
  7786. AND Permission = 1
  7787. AND UserId = {0}
  7788. ORDER BY
  7789. CreateTime DESC
  7790. ) THEN 1 ELSE 0 END AS [IsView]
  7791. FROM
  7792. Grp_DelegationInfo di
  7793. WHERE
  7794. di.Isdel = 0 ", dto.CurrUserId);
  7795. var data = await _sqlSugar.SqlQueryable<EnterExitCostMobileGroupView>(sql)
  7796. .Where(x => !string.IsNullOrEmpty(x.GroupName))
  7797. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7798. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.GroupName.Contains(dto.GroupName))
  7799. .OrderByDescending(x => x.Id)
  7800. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7801. return Ok(JsonView(true, "查询成功!", data, total));
  7802. }
  7803. /// <summary>
  7804. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7805. /// </summary>
  7806. /// <returns></returns>
  7807. [HttpPost]
  7808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7809. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7810. {
  7811. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7812. RefAsync<int> total = 0;
  7813. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7814. .Where(x => x.IsDel == 0 && x.STid == 66)
  7815. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7816. .Select(x => new
  7817. {
  7818. id = x.Id,
  7819. name = x.Name,
  7820. remark = x.Remark,
  7821. })
  7822. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7823. return Ok(JsonView(true, "查询成功!", data, total));
  7824. }
  7825. /// <summary>
  7826. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7827. /// </summary>
  7828. /// <returns></returns>
  7829. [HttpPost]
  7830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7831. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7832. {
  7833. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7834. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7835. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7836. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7837. var groupOtherRateData = groupRateData.TeamRates;
  7838. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7839. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  7840. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  7841. groupOtherRateData = groupOtherRateData
  7842. .Select(x => new TeamRateDescAddCurrencyIdView
  7843. {
  7844. CurrencyId = x.CurrencyId,
  7845. CurrencyName = x.CurrencyName,
  7846. CurrencyCode = x.CurrencyCode,
  7847. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  7848. }).ToList();
  7849. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  7850. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  7851. }
  7852. /// <summary>
  7853. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  7854. /// </summary>
  7855. /// <returns></returns>
  7856. [HttpPost]
  7857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7858. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  7859. {
  7860. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7861. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7862. var tipsData = new List<int>() { 1, 2, 3 };
  7863. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  7864. if (dto.TipsType == 1)
  7865. {
  7866. //默认币种显示
  7867. var _currencyInfos = _currencyInit;
  7868. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  7869. List<dynamic> reteInfos = new List<dynamic>();
  7870. if (_currencyRate.Count > 0)
  7871. {
  7872. foreach (var item in _currencyInfos)
  7873. {
  7874. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7875. if (rateInfo != null)
  7876. {
  7877. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  7878. decimal rate1 = item.Rate;
  7879. rate1 *= 1.03M;
  7880. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7881. reteInfos.Add(new
  7882. {
  7883. currCode = item.CurrencyCode,
  7884. currName = item.CurrencyName,
  7885. rate = rate2,
  7886. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  7887. });
  7888. }
  7889. }
  7890. }
  7891. return Ok(JsonView(true, "查询成功!", reteInfos));
  7892. }
  7893. else if (dto.TipsType == 2)
  7894. {
  7895. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  7896. return Ok(JsonView(true, "查询成功!", visaData.Data));
  7897. }
  7898. else if (dto.TipsType == 3)
  7899. {
  7900. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  7901. return Ok(JsonView(true, "查询成功!", airData.Data));
  7902. }
  7903. return Ok(JsonView(false));
  7904. }
  7905. /// <summary>
  7906. /// 团组模块 - 出入境国家费用标准-移动端 List
  7907. /// </summary>
  7908. /// <returns></returns>
  7909. [HttpPost]
  7910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7911. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  7912. {
  7913. Stopwatch sw = new Stopwatch();
  7914. sw.Start();
  7915. RefAsync<int> total = 0;
  7916. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7917. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  7918. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  7919. .Where((ntf, sd, u) => ntf.IsDel == 0)
  7920. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  7921. .Select((ntf, sd, u) => new
  7922. {
  7923. Id = ntf.Id,
  7924. Area = $"{ntf.Country}-{ntf.City}",
  7925. Currency = ntf.Currency,
  7926. CurrencyCode = sd.Name,
  7927. CurrencyName = sd.Remark,
  7928. RoomCost = ntf.RoomCost,
  7929. FoodCost = ntf.FoodCost,
  7930. PublicCost = ntf.PublicCost,
  7931. LastUpdateUserId = ntf.LastUpdateUserId,
  7932. LastUpdateUserName = u.CnName,
  7933. LastUpdateTime = ntf.LastUpdateTime,
  7934. })
  7935. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7936. sw.Stop();
  7937. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  7938. }
  7939. /// <summary>
  7940. /// 团组模块 - 出入境费用-移动端 - Info
  7941. /// </summary>
  7942. /// <returns></returns>
  7943. [HttpPost]
  7944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7945. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  7946. {
  7947. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7948. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7949. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  7950. return Ok(data);
  7951. }
  7952. /// <summary>
  7953. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  7954. /// </summary>
  7955. /// <returns></returns>
  7956. [HttpPost]
  7957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7958. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  7959. {
  7960. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7961. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7962. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7963. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7964. var mobileInfo = new EnterExitCostMobileParentInfoView();
  7965. mobileInfo.DiId = dto.DiId;
  7966. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  7967. if (eecInfo == null) return Ok(mobileInfo);
  7968. //验证查看权限
  7969. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  7970. //if (!isView) return Ok(JsonView(false, msg));
  7971. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  7972. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  7973. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  7974. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  7975. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  7976. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  7977. {
  7978. SubId = dac.Id,
  7979. DiId = dac.DiId,
  7980. Type = dac.Type,
  7981. Days = dac.Days,
  7982. NationalTravelFeeId = dac.NationalTravelFeeId,
  7983. Arae = $"{ntf.Country}-{ntf.City}",
  7984. Cost = dac.Cost,
  7985. Currency = dac.Currency,
  7986. CurrencyName = sd.Name,
  7987. SubTotal = dac.SubTotal,
  7988. })
  7989. .ToList();
  7990. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  7991. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  7992. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  7993. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  7994. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  7995. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  7996. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  7997. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  7998. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  7999. //其他款项
  8000. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8001. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8002. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8003. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8004. .OrderBy((dop, sd1, sd2) => dop.Index)
  8005. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8006. {
  8007. SubId = dop.Id,
  8008. DiId = dop.Diid,
  8009. Index = dop.Index,
  8010. SetDataId = dop.SetDataId,
  8011. SetDataName = sd1.Name,
  8012. Cost = dop.Cost,
  8013. Currency = dop.Currency,
  8014. CurrencyName = sd2.Remark,
  8015. SubTotal = dop.SubTotal,
  8016. Remark = dop.Remark,
  8017. })
  8018. .ToArray();
  8019. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8020. return Ok(mobileInfo);
  8021. }
  8022. /// <summary>
  8023. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8024. /// </summary>
  8025. /// <returns></returns>
  8026. [HttpPost]
  8027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8028. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8029. {
  8030. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8031. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8032. //验证查看权限
  8033. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8034. if (!isView) return Ok(JsonView(false, msg));
  8035. var userIds = Array.Empty<int>();
  8036. userIds = await _sqlSugar
  8037. .Queryable<Grp_EnterExitCostPermission>()
  8038. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8039. .Select(x => x.UserId)
  8040. .ToArrayAsync();
  8041. return Ok(userIds);
  8042. }
  8043. /// <summary>
  8044. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8045. /// </summary>
  8046. /// <returns></returns>
  8047. [HttpPost]
  8048. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8049. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8050. {
  8051. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8052. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8053. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8054. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8055. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8056. //验证查看权限
  8057. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8058. //if (!isView) return Ok(JsonView(false, msg));
  8059. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8060. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8061. var subType = dto.SubType;
  8062. if (subType == 1) //1:境内费用
  8063. {
  8064. var oneData = new ChoiceOneMobileSubInfoView()
  8065. {
  8066. Id = eecInfo.Id,
  8067. ChoiceOne = eecInfo.ChoiceOne,
  8068. ChoiceOneTotalCost = eecInfo.InsidePay,
  8069. Visa = eecInfo.Visa,
  8070. VisaRemark = eecInfo.VisaRemark,
  8071. YiMiao = eecInfo.YiMiao,
  8072. HeSuan = eecInfo.HeSuan,
  8073. Service = eecInfo.Service,
  8074. Ticket = eecInfo.Ticket,
  8075. Safe = eecInfo.Safe,
  8076. FirstItemRemark = eecInfo.FirstItemRemark
  8077. };
  8078. return Ok(JsonView(oneData));
  8079. }
  8080. else if (subType == 2) //2:国际旅费
  8081. {
  8082. var twoData = new ChoiceTwoMobileSubInfoView()
  8083. {
  8084. Id = eecInfo.Id,
  8085. ChoiceTwoJJ = eecInfo.SumJJC,
  8086. OutsideJJPay = eecInfo.OutsideJJPay,
  8087. ChoiceTwoGW = eecInfo.SumGWC,
  8088. OutsideGWPay = eecInfo.OutsideGWPay,
  8089. ChoiceTwoTD = eecInfo.SumTDC,
  8090. OutsideTDPay = eecInfo.OutsideTDPay,
  8091. AirJJ = eecInfo.AirJJ,
  8092. AirGW = eecInfo.AirGW,
  8093. AirTD = eecInfo.AirTD,
  8094. CityTranffic = eecInfo.CityTranffic,
  8095. TwoItemRemark = eecInfo.TwoItemRemark
  8096. };
  8097. return Ok(JsonView(twoData));
  8098. }
  8099. else if (subType == 3) //3:住宿费
  8100. {
  8101. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8102. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8103. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8104. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8105. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8106. {
  8107. SubId = dac.Id,
  8108. DiId = dac.DiId,
  8109. Type = dac.Type,
  8110. Days = dac.Days,
  8111. NationalTravelFeeId = dac.NationalTravelFeeId,
  8112. Arae = $"{ntf.Country}-{ntf.City}",
  8113. Cost = dac.Cost,
  8114. Currency = dac.Currency,
  8115. CurrencyName = sd.Name,
  8116. SubTotal = dac.SubTotal,
  8117. })
  8118. .ToArray();
  8119. var data = new ChoiceMobileSubInfo3To6View()
  8120. {
  8121. ParentId = eecInfo.Id,
  8122. Choice = eecInfo.ChoiceThree,
  8123. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8124. Details = dayAndCostDatas
  8125. };
  8126. return Ok(JsonView(data));
  8127. }
  8128. else if (subType == 4) //4:伙食费
  8129. {
  8130. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8131. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8132. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8133. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8134. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8135. {
  8136. SubId = dac.Id,
  8137. DiId = dac.DiId,
  8138. Type = dac.Type,
  8139. Days = dac.Days,
  8140. NationalTravelFeeId = dac.NationalTravelFeeId,
  8141. Arae = $"{ntf.Country}-{ntf.City}",
  8142. Cost = dac.Cost,
  8143. Currency = dac.Currency,
  8144. CurrencyName = sd.Name,
  8145. SubTotal = dac.SubTotal,
  8146. })
  8147. .ToArray();
  8148. var data = new ChoiceMobileSubInfo3To6View()
  8149. {
  8150. ParentId = eecInfo.Id,
  8151. Choice = eecInfo.ChoiceFour,
  8152. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8153. Details = dayAndCostDatas
  8154. };
  8155. return Ok(JsonView(data));
  8156. }
  8157. else if (subType == 5) //5:公杂费
  8158. {
  8159. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8160. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8161. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8162. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8163. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8164. {
  8165. SubId = dac.Id,
  8166. DiId = dac.DiId,
  8167. Type = dac.Type,
  8168. Days = dac.Days,
  8169. NationalTravelFeeId = dac.NationalTravelFeeId,
  8170. Arae = $"{ntf.Country}-{ntf.City}",
  8171. Cost = dac.Cost,
  8172. Currency = dac.Currency,
  8173. CurrencyName = sd.Name,
  8174. SubTotal = dac.SubTotal,
  8175. })
  8176. .ToArray();
  8177. var data = new ChoiceMobileSubInfo3To6View()
  8178. {
  8179. ParentId = eecInfo.Id,
  8180. Choice = eecInfo.ChoiceFive,
  8181. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8182. Details = dayAndCostDatas
  8183. };
  8184. return Ok(JsonView(data));
  8185. }
  8186. else if (subType == 6) //6:培训费
  8187. {
  8188. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8189. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8190. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8191. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8192. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8193. {
  8194. SubId = dac.Id,
  8195. DiId = dac.DiId,
  8196. Type = dac.Type,
  8197. Days = dac.Days,
  8198. NationalTravelFeeId = dac.NationalTravelFeeId,
  8199. Arae = $"{ntf.Country}-{ntf.City}",
  8200. Cost = dac.Cost,
  8201. Currency = dac.Currency,
  8202. CurrencyName = sd.Name,
  8203. SubTotal = dac.SubTotal,
  8204. })
  8205. .ToArray();
  8206. var data = new ChoiceMobileSubInfo3To6View()
  8207. {
  8208. ParentId = eecInfo.Id,
  8209. Choice = eecInfo.ChoiceSix,
  8210. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8211. Details = dayAndCostDatas
  8212. };
  8213. return Ok(JsonView(data));
  8214. }
  8215. else if (subType == 7) //7:其他
  8216. {
  8217. //其他款项
  8218. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8219. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8220. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8221. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8222. .OrderBy((dop, sd1, sd2) => dop.Index)
  8223. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8224. {
  8225. SubId = dop.Id,
  8226. DiId = dop.Diid,
  8227. Index = dop.Index,
  8228. SetDataId = dop.SetDataId,
  8229. SetDataName = sd1.Name,
  8230. Cost = dop.Cost,
  8231. Currency = dop.Currency,
  8232. CurrencyName = sd2.Name,
  8233. SubTotal = dop.SubTotal,
  8234. Remark = dop.Remark,
  8235. })
  8236. .ToArray();
  8237. var data = new ChoiceSevenMobileSubInfoView()
  8238. {
  8239. ParentId = eecInfo.Id,
  8240. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8241. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8242. Details = otherData
  8243. };
  8244. return Ok(JsonView(data));
  8245. }
  8246. return Ok(JsonView(false));
  8247. }
  8248. #region op
  8249. /// <summary>
  8250. /// 移动端更新费用消息通知
  8251. /// </summary>
  8252. /// <param name="diid"></param>
  8253. /// <param name="id"></param>
  8254. /// <param name="currUserId"></param>
  8255. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  8256. {
  8257. try
  8258. {
  8259. ////生成默认文件pdf并且通知人员
  8260. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8261. //{
  8262. // DiId = diid,
  8263. // ExportType = 1,
  8264. // SubTypeId = 1005
  8265. //}, "pdf");
  8266. ////发送通知
  8267. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8268. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8269. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8270. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8271. ////汇率信息记录
  8272. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8273. }
  8274. catch (Exception ex)
  8275. {
  8276. //记录日志
  8277. throw;
  8278. }
  8279. }
  8280. /// <summary>
  8281. /// 验证出入境费用数据是否存在
  8282. /// 不存在添加
  8283. /// </summary>
  8284. /// <param name="diId"></param>
  8285. /// <param name="currUserId"></param>
  8286. /// <returns></returns>
  8287. /// <exception cref="CustomException"></exception>
  8288. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  8289. {
  8290. var parentId = 0;
  8291. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8292. if (info != null)
  8293. {
  8294. parentId = info.Id;
  8295. }
  8296. else
  8297. {
  8298. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8299. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8300. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8301. parentId = addId;
  8302. }
  8303. return parentId;
  8304. }
  8305. /// <summary>
  8306. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8307. /// </summary>
  8308. /// <returns></returns>
  8309. [HttpPost]
  8310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8311. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8312. {
  8313. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8314. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8315. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8316. //验证编辑权限
  8317. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8318. //if (!isEdit) return Ok(JsonView(false, msg));
  8319. var permissions = new List<Grp_EnterExitCostPermission>();
  8320. foreach (var userId in dto.UserIds)
  8321. {
  8322. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8323. }
  8324. if (permissions.Any())
  8325. {
  8326. _sqlSugar.BeginTran();
  8327. try
  8328. {
  8329. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8330. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8331. if (result < 1)
  8332. {
  8333. _sqlSugar.RollbackTran();
  8334. return Ok(JsonView(false));
  8335. }
  8336. }
  8337. catch (Exception ex)
  8338. {
  8339. _sqlSugar.RollbackTran();
  8340. return Ok(JsonView(false, ex.Message));
  8341. }
  8342. _sqlSugar.CommitTran();
  8343. return Ok(JsonView(true));
  8344. }
  8345. return Ok(JsonView(false));
  8346. }
  8347. /// <summary>
  8348. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8349. /// </summary>
  8350. /// <returns></returns>
  8351. [HttpPost]
  8352. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8353. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8354. {
  8355. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8356. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8357. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8358. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8359. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8360. int id = dto.Id;
  8361. if (id <= 0) //add
  8362. {
  8363. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8364. if (add < 1) return Ok(JsonView(false));
  8365. id = add;
  8366. }
  8367. else //update
  8368. {
  8369. ////验证编辑权限
  8370. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8371. //if (!isEdit) return Ok(JsonView(false, msg));
  8372. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8373. if (upd < 1) return Ok(JsonView(false));
  8374. }
  8375. #region 汇率变更时更改币种相关费用
  8376. var opDayCosts = new List<Grp_DayAndCost>();
  8377. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8378. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8379. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8380. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  8381. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8382. .Select((dac, sd) => new
  8383. {
  8384. dac.Id,
  8385. dac.DiId,
  8386. CurrencyCode = sd.Name,
  8387. dac.Cost
  8388. })
  8389. .ToList();
  8390. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8391. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8392. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8393. .Select((dop, sd) => new
  8394. {
  8395. dop.Id,
  8396. dop.Diid,
  8397. CurrencyCode = sd.Name,
  8398. dop.Cost
  8399. })
  8400. .ToList();
  8401. if (dayCosts.Count > 0)
  8402. {
  8403. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8404. foreach (var dc in new_dayCosts)
  8405. {
  8406. var thisCurrency = dc.Key.ToUpper();
  8407. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8408. if (thisRate == 0.00M) continue;
  8409. foreach (var dcSub in dc)
  8410. {
  8411. opDayCosts.Add(new Grp_DayAndCost()
  8412. {
  8413. Id = dcSub.Id,
  8414. DiId = dcSub.DiId,
  8415. Cost = dcSub.Cost,
  8416. SubTotal = dcSub.Cost * thisRate,
  8417. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8418. });
  8419. }
  8420. }
  8421. if (opDayCosts.Count > 0)
  8422. {
  8423. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8424. }
  8425. }
  8426. if (dayOtherCosts.Count > 0)
  8427. {
  8428. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8429. foreach (var dc in new_dayOtherCosts)
  8430. {
  8431. var thisCurrency = dc.Key.ToUpper();
  8432. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8433. if (thisRate == 0.00M) continue;
  8434. foreach (var dcSub in dc)
  8435. {
  8436. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8437. {
  8438. Id = dcSub.Id,
  8439. Diid = dcSub.Diid,
  8440. Cost = dcSub.Cost,
  8441. SubTotal = dcSub.Cost * thisRate,
  8442. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8443. });
  8444. }
  8445. }
  8446. if (opDayOtherCosts.Count > 0)
  8447. {
  8448. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8449. }
  8450. }
  8451. #endregion
  8452. //消息通知
  8453. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8454. //汇率信息记录
  8455. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8456. return Ok(JsonView(new { parentId = id }));
  8457. }
  8458. /// <summary>
  8459. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8460. /// </summary>
  8461. /// <returns></returns>
  8462. [HttpPost]
  8463. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8464. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8465. {
  8466. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8467. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8468. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8469. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8470. int id = dto.Id;
  8471. if (id <= 0) //add
  8472. {
  8473. checkboxInfo.CreateUserId = dto.CurrUserId;
  8474. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8475. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8476. if (add < 1) return Ok(JsonView(false));
  8477. }
  8478. else //update
  8479. {
  8480. ////验证编辑权限
  8481. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8482. //if (!isEdit) return Ok(JsonView(false, msg));
  8483. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8484. .UpdateColumns(x => new
  8485. {
  8486. x.ChoiceOne,
  8487. x.ChoiceTwo,
  8488. x.SumJJC,
  8489. x.SumGWC,
  8490. x.SumTDC,
  8491. x.ChoiceThree,
  8492. x.ChoiceFour,
  8493. x.ChoiceFive,
  8494. x.ChoiceSix,
  8495. x.OtherExpenses_Checked
  8496. })
  8497. .Where(x => x.Id == id)
  8498. .ExecuteCommandAsync();
  8499. if (upd < 1) return Ok(JsonView(false));
  8500. }
  8501. return Ok(JsonView(new { parentId = id }));
  8502. }
  8503. /// <summary>
  8504. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8505. /// </summary>
  8506. /// <returns></returns>
  8507. [HttpPost]
  8508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8509. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8510. {
  8511. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  8512. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8513. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8514. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8515. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8516. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8517. var checkboxInfo = new Grp_EnterExitCost()
  8518. {
  8519. Id = id,
  8520. DiId = diId,
  8521. CreateUserId = currUserId
  8522. };
  8523. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8524. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8525. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8526. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8527. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8528. if (id <= 0) //add
  8529. {
  8530. checkboxInfo.CreateUserId = dto.CurrUserId;
  8531. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8532. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8533. if (add < 1) return Ok(JsonView(false));
  8534. }
  8535. else //update
  8536. {
  8537. ////验证编辑权限
  8538. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8539. //if (!isEdit) return Ok(JsonView(false, msg));
  8540. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8541. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8542. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8543. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8544. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8545. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8546. .Where(x => x.Id == id)
  8547. .ExecuteCommandAsync();
  8548. if (upd < 1) return Ok(JsonView(false));
  8549. }
  8550. return Ok(JsonView(new { parentId = id }));
  8551. }
  8552. /// <summary>
  8553. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8554. /// </summary>
  8555. /// <returns></returns>
  8556. [HttpPost]
  8557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8558. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8559. {
  8560. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8561. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8562. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8563. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8564. info.FirstItemRemark = dto.FirstItemRemark;
  8565. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8566. int id = dto.Id;
  8567. if (id <= 0) //add
  8568. {
  8569. info.CreateUserId = dto.CurrUserId;
  8570. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8571. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8572. if (add < 1) return Ok(JsonView(false));
  8573. id = add;
  8574. }
  8575. else //update
  8576. {
  8577. ////验证编辑权限
  8578. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8579. //if (!isEdit) return Ok(JsonView(false, msg));
  8580. var upd = await _sqlSugar.Updateable(info)
  8581. .UpdateColumns(x => new
  8582. {
  8583. x.ChoiceOne,
  8584. x.InsidePay,
  8585. x.VisaRemark,
  8586. x.Visa,
  8587. x.Service,
  8588. x.Safe,
  8589. x.Ticket,
  8590. x.HeSuan,
  8591. x.YiMiao,
  8592. x.FirstItemRemark
  8593. })
  8594. .Where(x => x.Id == id)
  8595. .ExecuteCommandAsync();
  8596. if (upd < 1) return Ok(JsonView(false));
  8597. }
  8598. //消息通知
  8599. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8600. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8601. }
  8602. /// <summary>
  8603. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8604. /// </summary>
  8605. /// <returns></returns>
  8606. [HttpPost]
  8607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8608. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8609. {
  8610. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8611. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8612. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8613. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8614. info.OutsideJJPay = dto.OutsideJJPay;
  8615. info.OutsideGWPay = dto.OutsideGWPay;
  8616. info.OutsideTDPay = dto.OutsideTDPay;
  8617. info.AirJJ = dto.AirJJ;
  8618. info.AirGW = dto.AirGW;
  8619. info.AirTD = dto.AirTD;
  8620. info.CityTranffic = dto.CityTranffic;
  8621. info.TwoItemRemark = dto.TwoItemRemark;
  8622. info.SumJJC = dto.ChoiceTwoJJ;
  8623. info.SumGWC = dto.ChoiceTwoGW;
  8624. info.SumTDC = dto.ChoiceTwoTD;
  8625. int id = dto.Id;
  8626. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8627. if (id <= 0) //add
  8628. {
  8629. info.CreateUserId = dto.CurrUserId;
  8630. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8631. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8632. if (addId <= 0) return Ok(JsonView(false));
  8633. id = addId;
  8634. }
  8635. else //update
  8636. {
  8637. ////验证编辑权限
  8638. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8639. //if (!isEdit) return Ok(JsonView(false, msg));
  8640. var upd = await _sqlSugar.Updateable(info)
  8641. .UpdateColumns(x => new
  8642. {
  8643. x.SumJJC,
  8644. x.OutsideJJPay,
  8645. x.SumGWC,
  8646. x.OutsideGWPay,
  8647. x.SumTDC,
  8648. x.OutsideTDPay,
  8649. x.AirJJ,
  8650. x.AirGW,
  8651. x.AirTD,
  8652. x.CityTranffic,
  8653. x.TwoItemRemark
  8654. })
  8655. .Where(x => x.Id == id)
  8656. .ExecuteCommandAsync();
  8657. if (upd < 1) return Ok(JsonView(false));
  8658. }
  8659. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8660. gwcItemTotal = info.AirGW + info.CityTranffic;
  8661. tdcItemTotal = info.AirTD + info.CityTranffic;
  8662. //消息通知
  8663. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8664. return Ok(JsonView(new
  8665. {
  8666. parentId = id,
  8667. choiceTwoJJ = dto.ChoiceTwoJJ,
  8668. jjcItemTotal = jjcItemTotal,
  8669. choiceTwoGW = dto.ChoiceTwoGW,
  8670. gwcItemTotal = gwcItemTotal,
  8671. choiceTwoTD = dto.ChoiceTwoTD,
  8672. tdcItemTotal = tdcItemTotal
  8673. }));
  8674. }
  8675. /// <summary>
  8676. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8677. /// </summary>
  8678. /// <returns></returns>
  8679. [HttpPost]
  8680. [ApiExplorerSettings(IgnoreApi = true)]
  8681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8682. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8683. {
  8684. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8685. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8686. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8687. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8688. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8689. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8690. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8691. var infos = infos1.Select(x => new Grp_DayAndCost
  8692. {
  8693. Id = x.Id,
  8694. DiId = dto.DiId,
  8695. Type = dto.FeeType,
  8696. Days = x.Days,
  8697. NationalTravelFeeId = x.NationalTravelFeeId,
  8698. Cost = x.Cost,
  8699. Currency = x.Currency,
  8700. SubTotal = x.SubTotal,
  8701. CreateUserId = dto.CurrUserId
  8702. })
  8703. .ToList();
  8704. var adds = infos.Where(x => x.Id <= 0).ToList();
  8705. var upds = infos.Where(x => x.Id > 0).ToList();
  8706. if (adds.Count > 0)
  8707. {
  8708. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8709. if (add < 1) return Ok(JsonView(false));
  8710. }
  8711. if (upds.Count > 0)
  8712. {
  8713. var upd = await _sqlSugar.Updateable(adds)
  8714. .UpdateColumns(x => new
  8715. {
  8716. x.Days,
  8717. x.NationalTravelFeeId,
  8718. x.Cost,
  8719. x.Currency,
  8720. x.SubTotal
  8721. })
  8722. .WhereColumns(x => new { x.Id })
  8723. .ExecuteCommandAsync();
  8724. if (upd < 1) return Ok(JsonView(false));
  8725. }
  8726. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8727. //消息通知
  8728. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8729. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8730. return Ok(JsonView(new { itemTotal = itemTotal }));
  8731. }
  8732. /// <summary>
  8733. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8734. /// </summary>
  8735. /// <returns></returns>
  8736. [HttpPost]
  8737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8738. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8739. {
  8740. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8741. int subId = dto.SubId, feeType = dto.FeeType;
  8742. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8743. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8744. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8745. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8746. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8747. subInfo.Id = subId;
  8748. subInfo.DiId = dto.DiId;
  8749. if (feeType == 3) subInfo.Type = 1;
  8750. else if (feeType == 4) subInfo.Type = 2;
  8751. else if (feeType == 5) subInfo.Type = 3;
  8752. else if (feeType == 6) subInfo.Type = 4;
  8753. subInfo.CreateUserId = dto.CurrUserId;
  8754. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8755. if (parentId < 1) return Ok(JsonView(false));
  8756. //子表op
  8757. if (subId < 1)
  8758. {
  8759. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8760. if (subAdd < 1) return Ok(JsonView(false));
  8761. }
  8762. else
  8763. {
  8764. ////验证编辑权限
  8765. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8766. //if (!isEdit) return Ok(JsonView(false, msg));
  8767. var subUpd = await _sqlSugar.Updateable(subInfo)
  8768. .UpdateColumns(x => new
  8769. {
  8770. x.Days,
  8771. x.NationalTravelFeeId,
  8772. x.Cost,
  8773. x.Currency,
  8774. x.SubTotal
  8775. })
  8776. .WhereColumns(x => new { x.Id })
  8777. .ExecuteCommandAsync();
  8778. if (subUpd < 1) return Ok(JsonView(false));
  8779. }
  8780. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8781. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8782. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8783. }
  8784. /// <summary>
  8785. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8786. /// </summary>
  8787. /// <returns></returns>
  8788. [HttpPost]
  8789. [ApiExplorerSettings(IgnoreApi = true)]
  8790. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8791. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8792. {
  8793. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8794. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8795. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8796. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8797. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8798. {
  8799. Id = x.Id,
  8800. Diid = dto.DiId,
  8801. SetDataId = x.SetDataId,
  8802. Index = x.Index,
  8803. Cost = x.Cost,
  8804. Currency = x.Currency,
  8805. SubTotal = x.SubTotal,
  8806. CreateUserId = dto.CurrUserId,
  8807. Remark = x.Remark
  8808. }).ToList();
  8809. var adds = infos.Where(x => x.Id <= 0).ToList();
  8810. var upds = infos.Where(x => x.Id > 0).ToList();
  8811. if (adds.Count > 0)
  8812. {
  8813. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8814. if (add < 1) return Ok(JsonView(false));
  8815. }
  8816. if (upds.Count > 0)
  8817. {
  8818. var upd = await _sqlSugar.Updateable(adds)
  8819. .UpdateColumns(x => new
  8820. {
  8821. x.Index,
  8822. x.SetDataId,
  8823. x.Cost,
  8824. x.Currency,
  8825. x.SubTotal,
  8826. x.Remark
  8827. })
  8828. .WhereColumns(x => new { x.Id })
  8829. .ExecuteCommandAsync();
  8830. if (upd < 1) return Ok(JsonView(false));
  8831. }
  8832. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8833. //消息通知
  8834. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8835. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8836. return Ok(JsonView(new { itemTotal = itemTotal }));
  8837. }
  8838. /// <summary>
  8839. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8840. /// </summary>
  8841. /// <returns></returns>
  8842. [HttpPost]
  8843. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8844. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8845. {
  8846. int subId = dto.SubId;
  8847. int diId = dto.Diid;
  8848. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8849. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8850. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8851. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8852. subInfo.Id = subId;
  8853. subInfo.Diid = dto.Diid;
  8854. subInfo.CreateUserId = dto.CurrUserId;
  8855. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8856. if (parentId < 1) return Ok(JsonView(false));
  8857. #region 子表op
  8858. if (subId < 1)//add
  8859. {
  8860. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8861. if (subAdd < 1) return Ok(JsonView(false));
  8862. }
  8863. else //upd
  8864. {
  8865. ////验证编辑权限
  8866. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  8867. //if (!isEdit) return Ok(JsonView(false, msg));
  8868. var subUpd = await _sqlSugar.Updateable(subInfo)
  8869. .UpdateColumns(x => new
  8870. {
  8871. x.Index,
  8872. x.SetDataId,
  8873. x.Cost,
  8874. x.Currency,
  8875. x.SubTotal,
  8876. x.Remark
  8877. })
  8878. .WhereColumns(x => new { x.Id })
  8879. .ExecuteCommandAsync();
  8880. if (subUpd < 1) return Ok(JsonView(false));
  8881. }
  8882. #endregion
  8883. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  8884. //消息通知
  8885. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  8886. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8887. }
  8888. /// <summary>
  8889. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  8890. /// </summary>
  8891. /// <returns></returns>
  8892. [HttpPost]
  8893. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8894. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  8895. {
  8896. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8897. if (data.Code != 0)
  8898. {
  8899. return Ok(JsonView(false, data.Msg));
  8900. }
  8901. return Ok(JsonView(true, "操作成功!", data.Data));
  8902. }
  8903. /// <summary>
  8904. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  8905. /// </summary>
  8906. /// <param name="dto"></param>
  8907. /// <returns></returns>
  8908. [HttpPost]
  8909. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  8910. {
  8911. var data = new Grp_DayOtherPrice()
  8912. {
  8913. Id = dto.Id,
  8914. IsDel = 1,
  8915. DeleteUserId = dto.DeleteUserId,
  8916. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8917. };
  8918. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8919. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  8920. return Ok(JsonView(false, "删除失败!"));
  8921. }
  8922. #endregion
  8923. #endregion
  8924. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  8925. /// <summary>
  8926. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  8927. /// </summary>
  8928. /// <returns></returns>
  8929. [HttpPost]
  8930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8931. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  8932. {
  8933. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8934. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8935. RefAsync<int> total = 0;
  8936. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8937. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  8938. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  8939. .Select(x => new
  8940. {
  8941. Id = x.Id,
  8942. DraftName = x.DraftName,
  8943. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  8944. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  8945. .Any()
  8946. })
  8947. .OrderByDescending(x => x.Id)
  8948. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8949. return Ok(JsonView(true, "查询成功!", data, total));
  8950. }
  8951. /// <summary>
  8952. /// 出入境费用-草稿 移动端
  8953. /// 获取币种基础数据(含逻辑处理)
  8954. /// </summary>
  8955. /// <returns></returns>
  8956. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  8957. {
  8958. return await GeneralMethod.EnterExitCostInitRate();
  8959. }
  8960. /// <summary>
  8961. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  8962. /// </summary>
  8963. /// <returns></returns>
  8964. [HttpPost]
  8965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8966. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(PortDtoBase dto)
  8967. {
  8968. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8969. //SetDataInfoView
  8970. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  8971. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  8972. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  8973. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  8974. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  8975. //默认币种显示
  8976. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  8977. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  8978. return Ok(JsonView(true, "查询成功!", new
  8979. {
  8980. WordTypeData = _WordTypeData,
  8981. ExcelTypeData = _ExcelTypeData,
  8982. CurrencyInit = _currencyInfos,
  8983. viewPermissionData = viewPermissionData
  8984. }));
  8985. }
  8986. /// <summary>
  8987. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  8988. /// </summary>
  8989. /// <returns></returns>
  8990. [HttpPost]
  8991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8992. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  8993. {
  8994. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8995. RefAsync<int> total = 0;
  8996. int diId = 0;
  8997. var status = int.TryParse(dto.GroupName, out diId);
  8998. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  8999. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9000. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9001. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9002. .Select(x => new
  9003. {
  9004. Id = x.Id,
  9005. GroupName = x.TeamName
  9006. })
  9007. .OrderByDescending(x => x.Id)
  9008. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9009. return Ok(JsonView(true, "查询成功!", data, total));
  9010. }
  9011. /// <summary>
  9012. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9013. /// </summary>
  9014. /// <returns></returns>
  9015. [HttpPost]
  9016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9017. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9018. {
  9019. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9020. RefAsync<int> total = 0;
  9021. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9022. .Where(x => x.IsDel == 0 && x.STid == 66)
  9023. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9024. .Select(x => new
  9025. {
  9026. id = x.Id,
  9027. name = x.Name,
  9028. remark = x.Remark,
  9029. })
  9030. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9031. return Ok(JsonView(true, "查询成功!", data, total));
  9032. }
  9033. /// <summary>
  9034. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9035. /// </summary>
  9036. /// <returns></returns>
  9037. [HttpPost]
  9038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9039. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9040. {
  9041. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9042. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9043. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, 2274, 98);
  9044. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9045. var groupOtherRateData = groupRateData.TeamRates;
  9046. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9047. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9048. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9049. groupOtherRateData = groupOtherRateData
  9050. .Select(x => new TeamRateDescAddCurrencyIdView
  9051. {
  9052. CurrencyId = x.CurrencyId,
  9053. CurrencyName = x.CurrencyName,
  9054. CurrencyCode = x.CurrencyCode,
  9055. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9056. }).ToList();
  9057. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9058. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9059. }
  9060. /// <summary>
  9061. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9062. /// </summary>
  9063. /// <returns></returns>
  9064. [HttpPost]
  9065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9066. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9067. {
  9068. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9069. var tipsData = new List<int>() { 1, 2, 3 };
  9070. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9071. if (dto.TipsType == 1)
  9072. {
  9073. //默认币种显示
  9074. var _currencyInfos = _currencyInit;
  9075. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  9076. List<dynamic> reteInfos = new List<dynamic>();
  9077. if (_currencyRate.Count > 0)
  9078. {
  9079. foreach (var item in _currencyInfos)
  9080. {
  9081. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  9082. if (rateInfo != null)
  9083. {
  9084. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  9085. decimal rate1 = item.Rate;
  9086. rate1 *= 1.03M;
  9087. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  9088. reteInfos.Add(new
  9089. {
  9090. currCode = item.CurrencyCode,
  9091. currName = item.CurrencyName,
  9092. rate = rate2,
  9093. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  9094. });
  9095. }
  9096. }
  9097. }
  9098. return Ok(JsonView(true, "查询成功!", reteInfos));
  9099. }
  9100. else if (dto.TipsType == 2)
  9101. {
  9102. }
  9103. else if (dto.TipsType == 3)
  9104. {
  9105. }
  9106. return Ok(JsonView(false));
  9107. }
  9108. /// <summary>
  9109. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9110. /// </summary>
  9111. /// <returns></returns>
  9112. [HttpPost]
  9113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9114. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9115. {
  9116. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9117. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9118. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9119. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9120. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9121. if (eecInfo == null) return Ok(mobileInfo);
  9122. //验证查看权限
  9123. (bool isView, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId);
  9124. if (!isView) return Ok(JsonView(false, msg));
  9125. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9126. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9127. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9128. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9129. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9130. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9131. {
  9132. ParentId = dac.ParentId,
  9133. SubId = dac.Id,
  9134. Type = dac.Type,
  9135. Days = dac.Days,
  9136. NationalTravelFeeId = dac.NationalTravelFeeId,
  9137. Arae = $"{ntf.Country}-{ntf.City}",
  9138. Cost = dac.Cost,
  9139. Currency = dac.Currency,
  9140. CurrencyName = sd.Name,
  9141. SubTotal = dac.SubTotal,
  9142. })
  9143. .ToList();
  9144. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9145. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9146. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9147. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9148. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9149. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9150. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9151. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9152. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9153. //其他款项
  9154. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9155. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9156. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9157. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9158. .OrderBy((dop, sd1, sd2) => dop.Index)
  9159. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9160. {
  9161. ParentId = dop.ParentId,
  9162. SubId = dop.Id,
  9163. Index = dop.Index,
  9164. SetDataId = dop.SetDataId,
  9165. SetDataName = sd1.Name,
  9166. Cost = dop.Cost,
  9167. Currency = dop.Currency,
  9168. CurrencyName = sd2.Remark,
  9169. SubTotal = dop.SubTotal,
  9170. Remark = dop.Remark,
  9171. })
  9172. .ToArray();
  9173. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9174. return Ok(mobileInfo);
  9175. }
  9176. /// <summary>
  9177. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9178. /// </summary>
  9179. /// <returns></returns>
  9180. [HttpPost]
  9181. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9182. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9183. {
  9184. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9185. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9186. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9187. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9188. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9189. //验证查看权限
  9190. (bool isView, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId);
  9191. if (!isView) return Ok(JsonView(false, msg));
  9192. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9193. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9194. var subType = dto.SubType;
  9195. if (subType == 1) //1:境内费用
  9196. {
  9197. var oneData = new ChoiceOneMobileSubInfoView()
  9198. {
  9199. Id = eecInfo.Id,
  9200. ChoiceOne = eecInfo.ChoiceOne,
  9201. ChoiceOneTotalCost = eecInfo.InsidePay,
  9202. Visa = eecInfo.Visa,
  9203. VisaRemark = eecInfo.VisaRemark,
  9204. YiMiao = eecInfo.YiMiao,
  9205. HeSuan = eecInfo.HeSuan,
  9206. Service = eecInfo.Service,
  9207. Ticket = eecInfo.Ticket,
  9208. Safe = eecInfo.Safe,
  9209. FirstItemRemark = eecInfo.FirstItemRemark
  9210. };
  9211. return Ok(JsonView(oneData));
  9212. }
  9213. else if (subType == 2) //2:国际旅费
  9214. {
  9215. var twoData = new ChoiceTwoMobileSubInfoView()
  9216. {
  9217. Id = eecInfo.Id,
  9218. ChoiceTwoJJ = eecInfo.SumJJC,
  9219. OutsideJJPay = eecInfo.OutsideJJPay,
  9220. ChoiceTwoGW = eecInfo.SumGWC,
  9221. OutsideGWPay = eecInfo.OutsideGWPay,
  9222. ChoiceTwoTD = eecInfo.SumTDC,
  9223. OutsideTDPay = eecInfo.OutsideTDPay,
  9224. AirJJ = eecInfo.AirJJ,
  9225. AirGW = eecInfo.AirGW,
  9226. AirTD = eecInfo.AirTD,
  9227. CityTranffic = eecInfo.CityTranffic,
  9228. TwoItemRemark = eecInfo.TwoItemRemark
  9229. };
  9230. return Ok(JsonView(twoData));
  9231. }
  9232. else if (subType == 3) //3:住宿费
  9233. {
  9234. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9235. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9236. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9237. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9238. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9239. {
  9240. ParentId = dac.ParentId,
  9241. SubId = dac.Id,
  9242. Type = dac.Type,
  9243. Days = dac.Days,
  9244. NationalTravelFeeId = dac.NationalTravelFeeId,
  9245. Arae = $"{ntf.Country}-{ntf.City}",
  9246. Cost = dac.Cost,
  9247. Currency = dac.Currency,
  9248. CurrencyName = sd.Name,
  9249. SubTotal = dac.SubTotal,
  9250. })
  9251. .ToArray();
  9252. var data = new ChoiceDraftMobileSubInfo3To6View()
  9253. {
  9254. ParentId = eecInfo.Id,
  9255. Choice = eecInfo.ChoiceThree,
  9256. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9257. Details = dayAndCostDatas
  9258. };
  9259. return Ok(JsonView(data));
  9260. }
  9261. else if (subType == 4) //4:伙食费
  9262. {
  9263. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9264. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9265. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9266. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9267. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9268. {
  9269. ParentId = dac.ParentId,
  9270. SubId = dac.Id,
  9271. Type = dac.Type,
  9272. Days = dac.Days,
  9273. NationalTravelFeeId = dac.NationalTravelFeeId,
  9274. Arae = $"{ntf.Country}-{ntf.City}",
  9275. Cost = dac.Cost,
  9276. Currency = dac.Currency,
  9277. CurrencyName = sd.Name,
  9278. SubTotal = dac.SubTotal,
  9279. })
  9280. .ToArray();
  9281. var data = new ChoiceDraftMobileSubInfo3To6View()
  9282. {
  9283. ParentId = eecInfo.Id,
  9284. Choice = eecInfo.ChoiceFour,
  9285. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9286. Details = dayAndCostDatas
  9287. };
  9288. return Ok(JsonView(data));
  9289. }
  9290. else if (subType == 5) //5:公杂费
  9291. {
  9292. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9293. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9294. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9295. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9296. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9297. {
  9298. ParentId = dac.ParentId,
  9299. SubId = dac.Id,
  9300. Type = dac.Type,
  9301. Days = dac.Days,
  9302. NationalTravelFeeId = dac.NationalTravelFeeId,
  9303. Arae = $"{ntf.Country}-{ntf.City}",
  9304. Cost = dac.Cost,
  9305. Currency = dac.Currency,
  9306. CurrencyName = sd.Name,
  9307. SubTotal = dac.SubTotal,
  9308. })
  9309. .ToArray();
  9310. var data = new ChoiceDraftMobileSubInfo3To6View()
  9311. {
  9312. ParentId = eecInfo.Id,
  9313. Choice = eecInfo.ChoiceFive,
  9314. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9315. Details = dayAndCostDatas
  9316. };
  9317. return Ok(JsonView(data));
  9318. }
  9319. else if (subType == 6) //6:培训费
  9320. {
  9321. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9322. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9323. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9324. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9325. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9326. {
  9327. ParentId = dac.ParentId,
  9328. SubId = dac.Id,
  9329. Type = dac.Type,
  9330. Days = dac.Days,
  9331. NationalTravelFeeId = dac.NationalTravelFeeId,
  9332. Arae = $"{ntf.Country}-{ntf.City}",
  9333. Cost = dac.Cost,
  9334. Currency = dac.Currency,
  9335. CurrencyName = sd.Name,
  9336. SubTotal = dac.SubTotal,
  9337. })
  9338. .ToArray();
  9339. var data = new ChoiceDraftMobileSubInfo3To6View()
  9340. {
  9341. ParentId = eecInfo.Id,
  9342. Choice = eecInfo.ChoiceSix,
  9343. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9344. Details = dayAndCostDatas
  9345. };
  9346. return Ok(JsonView(data));
  9347. }
  9348. else if (subType == 7) //7:其他
  9349. {
  9350. //其他款项
  9351. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9352. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9353. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9354. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9355. .OrderBy((dop, sd1, sd2) => dop.Index)
  9356. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9357. {
  9358. ParentId = dop.ParentId,
  9359. SubId = dop.Id,
  9360. Index = dop.Index,
  9361. SetDataId = dop.SetDataId,
  9362. SetDataName = sd1.Name,
  9363. Cost = dop.Cost,
  9364. Currency = dop.Currency,
  9365. CurrencyName = sd2.Name,
  9366. SubTotal = dop.SubTotal,
  9367. Remark = dop.Remark,
  9368. })
  9369. .ToArray();
  9370. var data = new ChoiceSevenDraftMobileSubInfoView()
  9371. {
  9372. ParentId = eecInfo.Id,
  9373. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9374. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9375. Details = otherData
  9376. };
  9377. return Ok(JsonView(data));
  9378. }
  9379. return Ok(JsonView(false));
  9380. }
  9381. #region op
  9382. /// <summary>
  9383. /// 移动端更新费用消息通知
  9384. /// </summary>
  9385. /// <param name="draftId"></param>
  9386. /// <param name="id"></param>
  9387. /// <param name="currUserId"></param>
  9388. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9389. {
  9390. try
  9391. {
  9392. ////生成默认文件pdf并且通知人员
  9393. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9394. //{
  9395. // DiId = draftId,
  9396. // ExportType = 1,
  9397. // SubTypeId = 1005
  9398. //}, "pdf");
  9399. ////发送通知
  9400. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9401. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9402. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9403. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9404. ////汇率信息记录
  9405. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9406. }
  9407. catch (Exception ex)
  9408. {
  9409. //记录日志
  9410. throw;
  9411. }
  9412. }
  9413. /// <summary>
  9414. /// 验证出入境费用数据是否存在
  9415. /// 不存在添加
  9416. /// </summary>
  9417. /// <param name="draftId"></param>
  9418. /// <param name="currUserId"></param>
  9419. /// <returns></returns>
  9420. /// <exception cref="CustomException"></exception>
  9421. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9422. {
  9423. var parentId = 0;
  9424. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9425. if (info != null) parentId = info.Id;
  9426. else
  9427. {
  9428. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9429. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9430. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9431. parentId = addId;
  9432. }
  9433. return parentId;
  9434. }
  9435. /// <summary>
  9436. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9437. /// </summary>
  9438. /// <returns></returns>
  9439. [HttpPost]
  9440. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9441. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9442. {
  9443. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9444. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9445. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9446. //验证编辑权限
  9447. (bool isEdit, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId, 2);
  9448. if (!isEdit) return Ok(JsonView(false, msg));
  9449. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  9450. foreach (var userId in dto.UserIds)
  9451. {
  9452. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9453. }
  9454. if (permissions.Any())
  9455. {
  9456. _sqlSugar.BeginTran();
  9457. try
  9458. {
  9459. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9460. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9461. if (result < 1)
  9462. {
  9463. _sqlSugar.RollbackTran();
  9464. return Ok(JsonView(false));
  9465. }
  9466. }
  9467. catch (Exception ex)
  9468. {
  9469. _sqlSugar.RollbackTran();
  9470. return Ok(JsonView(false, ex.Message));
  9471. }
  9472. _sqlSugar.CommitTran();
  9473. return Ok(JsonView(true));
  9474. }
  9475. return Ok(JsonView(false));
  9476. }
  9477. /// <summary>
  9478. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9479. /// </summary>
  9480. /// <returns></returns>
  9481. [HttpPost]
  9482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9483. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9484. {
  9485. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9486. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9487. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9488. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9489. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9490. int id = dto.DraftId;
  9491. if (id <= 0) //add
  9492. {
  9493. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9494. if (add < 1) return Ok(JsonView(false));
  9495. id = add;
  9496. }
  9497. else //update
  9498. {
  9499. //验证编辑权限
  9500. (bool isEdit, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId, 2);
  9501. if (!isEdit) return Ok(JsonView(false, msg));
  9502. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9503. if (upd < 1) return Ok(JsonView(false));
  9504. }
  9505. #region 汇率变更时更改币种相关费用
  9506. var opDayCosts = new List<Grp_DayAndCostDraft>();
  9507. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  9508. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9509. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9510. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9511. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9512. .Select((dac, sd) => new
  9513. {
  9514. dac.Id,
  9515. dac.ParentId,
  9516. CurrencyCode = sd.Name,
  9517. dac.Cost
  9518. })
  9519. .ToList();
  9520. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9521. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9522. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9523. .Select((dop, sd) => new
  9524. {
  9525. dop.Id,
  9526. dop.ParentId,
  9527. CurrencyCode = sd.Name,
  9528. dop.Cost
  9529. })
  9530. .ToList();
  9531. if (dayCosts.Count > 0)
  9532. {
  9533. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9534. foreach (var dc in new_dayCosts)
  9535. {
  9536. var thisCurrency = dc.Key.ToUpper();
  9537. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9538. if (thisRate == 0.00M) continue;
  9539. foreach (var dcSub in dc)
  9540. {
  9541. opDayCosts.Add(new Grp_DayAndCostDraft()
  9542. {
  9543. Id = dcSub.Id,
  9544. ParentId = dcSub.ParentId,
  9545. Cost = dcSub.Cost,
  9546. SubTotal = dcSub.Cost * thisRate,
  9547. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  9548. });
  9549. }
  9550. }
  9551. if (opDayCosts.Count > 0)
  9552. {
  9553. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9554. }
  9555. }
  9556. if (dayOtherCosts.Count > 0)
  9557. {
  9558. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9559. foreach (var dc in new_dayOtherCosts)
  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. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  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 (opDayOtherCosts.Count > 0)
  9577. {
  9578. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9579. }
  9580. }
  9581. #endregion
  9582. ////消息通知
  9583. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9584. ////汇率信息记录
  9585. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9586. return Ok(JsonView(new { parentId = id }));
  9587. }
  9588. /// <summary>
  9589. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  9590. /// </summary>
  9591. /// <returns></returns>
  9592. [HttpPost]
  9593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9594. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  9595. {
  9596. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9597. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9598. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9599. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9600. int id = dto.DraftId;
  9601. if (id <= 0) //add
  9602. {
  9603. checkboxInfo.CreateUserId = dto.CurrUserId;
  9604. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  9605. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9606. if (add < 1) return Ok(JsonView(false));
  9607. }
  9608. else //update
  9609. {
  9610. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9611. .UpdateColumns(x => new
  9612. {
  9613. x.ChoiceOne,
  9614. x.ChoiceTwo,
  9615. x.SumJJC,
  9616. x.SumGWC,
  9617. x.SumTDC,
  9618. x.ChoiceThree,
  9619. x.ChoiceFour,
  9620. x.ChoiceFive,
  9621. x.ChoiceSix,
  9622. x.OtherExpenses_Checked
  9623. })
  9624. .Where(x => x.Id == id)
  9625. .ExecuteCommandAsync();
  9626. if (upd < 1) return Ok(JsonView(false));
  9627. }
  9628. return Ok(JsonView(new { parentId = id }));
  9629. }
  9630. /// <summary>
  9631. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框更改
  9632. /// </summary>
  9633. /// <returns></returns>
  9634. [HttpPost]
  9635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9636. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  9637. {
  9638. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  9639. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9640. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9641. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9642. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9643. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9644. var checkboxInfo = new Grp_EnterExitCostDraft()
  9645. {
  9646. Id = draftId,
  9647. CreateUserId = currUserId
  9648. };
  9649. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9650. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9651. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9652. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9653. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9654. if (draftId <= 0) //add
  9655. {
  9656. checkboxInfo.CreateUserId = dto.CurrUserId;
  9657. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9658. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9659. if (add < 1) return Ok(JsonView(false));
  9660. }
  9661. else //update
  9662. {
  9663. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  9664. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9665. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9666. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9667. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9668. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9669. .Where(x => x.Id == draftId)
  9670. .ExecuteCommandAsync();
  9671. if (upd < 1) return Ok(JsonView(false));
  9672. }
  9673. return Ok(JsonView(new { parentId = draftId }));
  9674. }
  9675. /// <summary>
  9676. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  9677. /// </summary>
  9678. /// <returns></returns>
  9679. [HttpPost]
  9680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9681. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  9682. {
  9683. int id = dto.DraftId, currUserId = dto.CurrUserId;
  9684. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9685. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9686. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9687. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9688. info.FirstItemRemark = dto.FirstItemRemark;
  9689. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9690. if (id <= 0) //add
  9691. {
  9692. info.CreateUserId = dto.CurrUserId;
  9693. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9694. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9695. if (add < 1) return Ok(JsonView(false));
  9696. id = add;
  9697. }
  9698. else //update
  9699. {
  9700. var upd = await _sqlSugar.Updateable(info)
  9701. .UpdateColumns(x => new
  9702. {
  9703. x.ChoiceOne,
  9704. x.InsidePay,
  9705. x.VisaRemark,
  9706. x.Visa,
  9707. x.Service,
  9708. x.Safe,
  9709. x.Ticket,
  9710. x.HeSuan,
  9711. x.YiMiao,
  9712. x.FirstItemRemark
  9713. })
  9714. .Where(x => x.Id == id)
  9715. .ExecuteCommandAsync();
  9716. if (upd < 1) return Ok(JsonView(false));
  9717. }
  9718. ////消息通知
  9719. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9720. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9721. }
  9722. /// <summary>
  9723. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  9724. /// </summary>
  9725. /// <returns></returns>
  9726. [HttpPost]
  9727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9728. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  9729. {
  9730. int id = dto.DraftId;
  9731. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9732. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9733. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9734. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9735. info.OutsideJJPay = dto.OutsideJJPay;
  9736. info.OutsideGWPay = dto.OutsideGWPay;
  9737. info.OutsideTDPay = dto.OutsideTDPay;
  9738. info.AirJJ = dto.AirJJ;
  9739. info.AirGW = dto.AirGW;
  9740. info.AirTD = dto.AirTD;
  9741. info.CityTranffic = dto.CityTranffic;
  9742. info.TwoItemRemark = dto.TwoItemRemark;
  9743. info.SumJJC = dto.ChoiceTwoJJ;
  9744. info.SumGWC = dto.ChoiceTwoGW;
  9745. info.SumTDC = dto.ChoiceTwoTD;
  9746. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9747. if (id <= 0) //add
  9748. {
  9749. info.CreateUserId = dto.CurrUserId;
  9750. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9751. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9752. if (addId <= 0) return Ok(JsonView(false));
  9753. id = addId;
  9754. }
  9755. else //update
  9756. {
  9757. var upd = await _sqlSugar.Updateable(info)
  9758. .UpdateColumns(x => new
  9759. {
  9760. x.SumJJC,
  9761. x.OutsideJJPay,
  9762. x.SumGWC,
  9763. x.OutsideGWPay,
  9764. x.SumTDC,
  9765. x.OutsideTDPay,
  9766. x.AirJJ,
  9767. x.AirGW,
  9768. x.AirTD,
  9769. x.CityTranffic,
  9770. x.TwoItemRemark
  9771. })
  9772. .Where(x => x.Id == id)
  9773. .ExecuteCommandAsync();
  9774. if (upd < 1) return Ok(JsonView(false));
  9775. }
  9776. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9777. gwcItemTotal = info.AirGW + info.CityTranffic;
  9778. tdcItemTotal = info.AirTD + info.CityTranffic;
  9779. ////消息通知
  9780. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9781. return Ok(JsonView(new
  9782. {
  9783. parentId = id,
  9784. choiceTwoJJ = dto.ChoiceTwoJJ,
  9785. jjcItemTotal = jjcItemTotal,
  9786. choiceTwoGW = dto.ChoiceTwoGW,
  9787. gwcItemTotal = gwcItemTotal,
  9788. choiceTwoTD = dto.ChoiceTwoTD,
  9789. tdcItemTotal = tdcItemTotal
  9790. }));
  9791. }
  9792. /// <summary>
  9793. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9794. /// </summary>
  9795. /// <returns></returns>
  9796. [HttpPost]
  9797. [ApiExplorerSettings(IgnoreApi = true)]
  9798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9799. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  9800. {
  9801. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9802. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9803. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9804. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9805. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9806. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9807. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  9808. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  9809. {
  9810. Id = x.Id,
  9811. ParentId = dto.DraftId,
  9812. Type = dto.FeeType,
  9813. Days = x.Days,
  9814. NationalTravelFeeId = x.NationalTravelFeeId,
  9815. Cost = x.Cost,
  9816. Currency = x.Currency,
  9817. SubTotal = x.SubTotal,
  9818. CreateUserId = dto.CurrUserId
  9819. })
  9820. .ToList();
  9821. var adds = infos.Where(x => x.Id <= 0).ToList();
  9822. var upds = infos.Where(x => x.Id > 0).ToList();
  9823. if (adds.Count > 0)
  9824. {
  9825. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9826. if (add < 1) return Ok(JsonView(false));
  9827. }
  9828. if (upds.Count > 0)
  9829. {
  9830. var upd = await _sqlSugar.Updateable(adds)
  9831. .UpdateColumns(x => new
  9832. {
  9833. x.Days,
  9834. x.NationalTravelFeeId,
  9835. x.Cost,
  9836. x.Currency,
  9837. x.SubTotal
  9838. })
  9839. .WhereColumns(x => new { x.Id })
  9840. .ExecuteCommandAsync();
  9841. if (upd < 1) return Ok(JsonView(false));
  9842. }
  9843. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9844. ////消息通知
  9845. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  9846. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9847. return Ok(JsonView(new { itemTotal = itemTotal }));
  9848. }
  9849. /// <summary>
  9850. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9851. /// </summary>
  9852. /// <returns></returns>
  9853. [HttpPost]
  9854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9855. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  9856. {
  9857. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9858. int subId = dto.SubId, feeType = dto.FeeType;
  9859. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9860. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9861. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9862. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9863. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  9864. subInfo.Id = subId;
  9865. subInfo.ParentId = dto.DraftId;
  9866. if (feeType == 3) subInfo.Type = 1;
  9867. else if (feeType == 4) subInfo.Type = 2;
  9868. else if (feeType == 5) subInfo.Type = 3;
  9869. else if (feeType == 6) subInfo.Type = 4;
  9870. subInfo.CreateUserId = dto.CurrUserId;
  9871. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  9872. if (parentId < 1) return Ok(JsonView(false));
  9873. //子表op
  9874. if (subId < 1)
  9875. {
  9876. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9877. if (subAdd < 1) return Ok(JsonView(false));
  9878. }
  9879. else
  9880. {
  9881. var subUpd = await _sqlSugar.Updateable(subInfo)
  9882. .UpdateColumns(x => new
  9883. {
  9884. x.Days,
  9885. x.NationalTravelFeeId,
  9886. x.Cost,
  9887. x.Currency,
  9888. x.SubTotal
  9889. })
  9890. .WhereColumns(x => new { x.Id })
  9891. .ExecuteCommandAsync();
  9892. if (subUpd < 1) return Ok(JsonView(false));
  9893. }
  9894. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  9895. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9896. }
  9897. /// <summary>
  9898. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  9899. /// </summary>
  9900. /// <returns></returns>
  9901. [HttpPost]
  9902. [ApiExplorerSettings(IgnoreApi = true)]
  9903. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9904. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  9905. {
  9906. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9907. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9908. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9909. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  9910. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  9911. {
  9912. Id = x.Id,
  9913. ParentId = dto.DraftId,
  9914. SetDataId = x.SetDataId,
  9915. Index = x.Index,
  9916. Cost = x.Cost,
  9917. Currency = x.Currency,
  9918. SubTotal = x.SubTotal,
  9919. CreateUserId = dto.CurrUserId,
  9920. Remark = x.Remark
  9921. }).ToList();
  9922. var adds = infos.Where(x => x.Id <= 0).ToList();
  9923. var upds = infos.Where(x => x.Id > 0).ToList();
  9924. if (adds.Count > 0)
  9925. {
  9926. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9927. if (add < 1) return Ok(JsonView(false));
  9928. }
  9929. if (upds.Count > 0)
  9930. {
  9931. var upd = await _sqlSugar.Updateable(adds)
  9932. .UpdateColumns(x => new
  9933. {
  9934. x.Index,
  9935. x.SetDataId,
  9936. x.Cost,
  9937. x.Currency,
  9938. x.SubTotal,
  9939. x.Remark
  9940. })
  9941. .WhereColumns(x => new { x.Id })
  9942. .ExecuteCommandAsync();
  9943. if (upd < 1) return Ok(JsonView(false));
  9944. }
  9945. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  9946. //消息通知
  9947. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  9948. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9949. return Ok(JsonView(new { itemTotal = itemTotal }));
  9950. }
  9951. /// <summary>
  9952. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  9953. /// </summary>
  9954. /// <returns></returns>
  9955. [HttpPost]
  9956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9957. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  9958. {
  9959. int subId = dto.SubId, id = dto.DarftId;
  9960. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9961. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  9962. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9963. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  9964. subInfo.Id = subId;
  9965. subInfo.ParentId = dto.DarftId;
  9966. subInfo.CreateUserId = dto.CurrUserId;
  9967. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  9968. if (parentId < 1) return Ok(JsonView(false));
  9969. #region 子表op
  9970. if (subId < 1)//add
  9971. {
  9972. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9973. if (subAdd < 1) return Ok(JsonView(false));
  9974. }
  9975. else //upd
  9976. {
  9977. var subUpd = await _sqlSugar.Updateable(subInfo)
  9978. .UpdateColumns(x => new
  9979. {
  9980. x.Index,
  9981. x.SetDataId,
  9982. x.Cost,
  9983. x.Currency,
  9984. x.SubTotal,
  9985. x.Remark
  9986. })
  9987. .WhereColumns(x => new { x.Id })
  9988. .ExecuteCommandAsync();
  9989. if (subUpd < 1) return Ok(JsonView(false));
  9990. }
  9991. #endregion
  9992. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  9993. ////消息通知
  9994. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  9995. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9996. }
  9997. /// <summary>
  9998. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  9999. /// </summary>
  10000. /// <returns></returns>
  10001. [HttpPost]
  10002. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10003. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10004. {
  10005. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10006. if (data.Code != 0)
  10007. {
  10008. return Ok(JsonView(false, data.Msg));
  10009. }
  10010. return Ok(JsonView(true, "操作成功!", data.Data));
  10011. }
  10012. /// <summary>
  10013. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10014. /// </summary>
  10015. /// <param name="dto"></param>
  10016. /// <returns></returns>
  10017. [HttpPost]
  10018. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10019. {
  10020. var data = new Grp_DayOtherPriceDraft()
  10021. {
  10022. Id = dto.Id,
  10023. IsDel = 1,
  10024. DeleteUserId = dto.DeleteUserId,
  10025. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10026. };
  10027. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10028. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10029. return Ok(JsonView(false, "删除失败!"));
  10030. }
  10031. #endregion
  10032. #endregion
  10033. #region 团组经理模块 出入境费用报价表
  10034. /// <summary>
  10035. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  10036. /// </summary>
  10037. /// <returns></returns>
  10038. [HttpPost]
  10039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10040. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  10041. {
  10042. //默认币种显示
  10043. var currencyInfos = new List<CurrencyInfo>()
  10044. {
  10045. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  10046. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  10047. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  10048. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  10049. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  10050. };
  10051. var liveRateInfos = new List<LiveRateInfo>();
  10052. var currencyRate = await _juHeApi.PostItemRateAsync(currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  10053. if (currencyRate.Any())
  10054. {
  10055. foreach (var item in currencyInfos)
  10056. {
  10057. var rateInfo = currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  10058. if (rateInfo != null)
  10059. {
  10060. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  10061. if (rateInfo.Name.Equals("日元")) rate1 *= 1.3700M;
  10062. else rate1 *= 1.035M;
  10063. liveRateInfos.Add(new LiveRateInfo() {
  10064. CurrencyCode = item.CurrencyCode,
  10065. CurrencyName = item.CurrencyName,
  10066. Rate = rate1.TruncDecimals(4),
  10067. LastUpdTime = $"{rateInfo.Date} {rateInfo.Time}",
  10068. });
  10069. }
  10070. }
  10071. }
  10072. return Ok(JsonView(true, "查询成功!", new
  10073. {
  10074. InitRates = await GeneralMethod.EnterExitCostInitRate(),
  10075. LiveRates = await GeneralMethod.EnterExitCostLiveRate()
  10076. }));
  10077. }
  10078. /// <summary>
  10079. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  10080. /// </summary>
  10081. /// <returns></returns>
  10082. [HttpPost]
  10083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10084. public async Task<IActionResult> EnterExitCostQuoteNameListDto(EnterExitCostQuoteNameListDto dto)
  10085. {
  10086. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  10087. }
  10088. /// <summary>
  10089. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  10090. /// </summary>
  10091. /// <returns></returns>
  10092. [HttpPost]
  10093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10094. public async Task<IActionResult> EnterExitCostGroupNameListDto(EnterExitCostQuoteGroupNameListDto dto)
  10095. {
  10096. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  10097. }
  10098. #endregion
  10099. #region 签证费用录入
  10100. /// <summary>
  10101. /// 根据diid查询签证费用列表
  10102. /// </summary>
  10103. /// <param name="dto"></param>
  10104. /// <returns></returns>
  10105. [HttpPost]
  10106. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10107. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  10108. {
  10109. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  10110. if (groupData.Code != 0)
  10111. {
  10112. return Ok(JsonView(false, groupData.Msg));
  10113. }
  10114. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10115. }
  10116. /// <summary>
  10117. /// 根据签证费用Id查询单条数据及c表数据
  10118. /// </summary>
  10119. /// <param name="dto"></param>
  10120. /// <returns></returns>
  10121. [HttpPost]
  10122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10123. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  10124. {
  10125. Result groupData = await _visaPriceRep.PostVisaById(dto);
  10126. if (groupData.Code != 0)
  10127. {
  10128. return Ok(JsonView(false, groupData.Msg));
  10129. }
  10130. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10131. }
  10132. /// <summary>
  10133. /// 签证费用删除
  10134. /// </summary>
  10135. /// <param name="dto"></param>
  10136. /// <returns></returns>
  10137. [HttpPost]
  10138. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10139. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  10140. {
  10141. _sqlSugar.BeginTran();
  10142. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  10143. if (!res)
  10144. {
  10145. _sqlSugar.RollbackTran();
  10146. return Ok(JsonView(false, "删除失败"));
  10147. }
  10148. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  10149. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  10150. .SetColumns(a => new Grp_CreditCardPayment()
  10151. {
  10152. IsDel = 1,
  10153. DeleteUserId = dto.DeleteUserId,
  10154. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10155. })
  10156. .ExecuteCommand();
  10157. if (resSub < 1)
  10158. {
  10159. _sqlSugar.RollbackTran();
  10160. return Ok(JsonView(false, "删除失败"));
  10161. }
  10162. _sqlSugar.CommitTran();
  10163. return Ok(JsonView(true, "删除成功!"));
  10164. }
  10165. /// <summary>
  10166. /// 签证费用录入下拉框初始化
  10167. /// </summary>
  10168. /// <returns></returns>
  10169. [HttpPost]
  10170. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10171. public async Task<IActionResult> VisaPriceAddSelect()
  10172. {
  10173. //支付方式
  10174. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  10175. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  10176. //币种
  10177. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  10178. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  10179. //乘客类型
  10180. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  10181. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  10182. //卡类型
  10183. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  10184. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  10185. //代办费类型
  10186. var agencyFeeTypeData = new List<dynamic>() {
  10187. new { id = 0 , Text = "未选择" },
  10188. new { id = 1 , Text = "小公务" },
  10189. new { id = 2 , Text = "大公务" },
  10190. };
  10191. //签证费用标准国家Data
  10192. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  10193. var data = new
  10194. {
  10195. Payment = _Payment,
  10196. CurrencyList = _CurrencyList,
  10197. PassengerType = _PassengerType,
  10198. BankCard = _BankCard,
  10199. AgencyFeeType = agencyFeeTypeData,
  10200. CountryFeeData = visaCountryFeeData
  10201. };
  10202. return Ok(JsonView(true, "查询成功!", data));
  10203. }
  10204. /// <summary>
  10205. /// 签证费用录入操作(Status:1.新增,2.修改)
  10206. /// </summary>
  10207. /// <param name="dto"></param>
  10208. /// <returns></returns>
  10209. [HttpPost]
  10210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10211. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  10212. {
  10213. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  10214. if (groupData.Code != 0)
  10215. {
  10216. return Ok(JsonView(false, groupData.Msg));
  10217. }
  10218. #region 应用推送
  10219. try
  10220. {
  10221. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10222. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10223. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10224. //2024-10-21 新增LZ UID
  10225. var userIds = new List<int>() { 21 };
  10226. string title = $"系统通知";
  10227. string content = "";
  10228. var diId = dto.DiId;
  10229. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10230. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10231. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10232. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10233. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10234. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10235. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10236. }
  10237. catch (Exception ex)
  10238. {
  10239. }
  10240. #endregion
  10241. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10242. }
  10243. #endregion
  10244. #region 签证提成录入
  10245. /// <summary>
  10246. /// 签证提成录入
  10247. /// 基础数据
  10248. /// </summary>
  10249. /// <returns></returns>
  10250. [HttpGet]
  10251. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10252. public async Task<IActionResult> VisaCommissionInit()
  10253. {
  10254. return Ok(await _visaCommissionRep.Init());
  10255. }
  10256. /// <summary>
  10257. /// 签证提成录入
  10258. /// Item
  10259. /// </summary>
  10260. /// <param name="_dto"></param>
  10261. /// <returns></returns>
  10262. [HttpPost]
  10263. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10264. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  10265. {
  10266. var validator = new VisaCommissionItemDtoValidator();
  10267. var validatorRes = await validator.ValidateAsync(_dto);
  10268. if (!validatorRes.IsValid)
  10269. {
  10270. StringBuilder sb = new StringBuilder();
  10271. foreach (var item in validatorRes.Errors)
  10272. {
  10273. sb.AppendLine(item.ErrorMessage);
  10274. }
  10275. return Ok(JsonView(false, sb.ToString()));
  10276. }
  10277. return Ok(await _visaCommissionRep.Item(_dto));
  10278. }
  10279. /// <summary>
  10280. /// 签证提成录入
  10281. /// Save
  10282. /// </summary>
  10283. /// <param name="_dto"></param>
  10284. /// <returns></returns>
  10285. [HttpPost]
  10286. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10287. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  10288. {
  10289. //参数验证
  10290. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  10291. foreach (var item in _dto.Items)
  10292. {
  10293. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  10294. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  10295. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  10296. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  10297. }
  10298. return Ok(await _visaCommissionRep.Save(_dto));
  10299. }
  10300. /// <summary>
  10301. /// 签证提成录入
  10302. /// Create
  10303. /// </summary>
  10304. /// <param name="_dto"></param>
  10305. /// <returns></returns>
  10306. [HttpPost]
  10307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10308. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  10309. {
  10310. var validator = new VisaCommissionCreateDtoValidator();
  10311. var validatorRes = await validator.ValidateAsync(_dto);
  10312. if (!validatorRes.IsValid)
  10313. {
  10314. StringBuilder sb = new StringBuilder();
  10315. foreach (var item in validatorRes.Errors)
  10316. {
  10317. sb.AppendLine(item.ErrorMessage);
  10318. }
  10319. return Ok(JsonView(false, sb.ToString()));
  10320. }
  10321. return Ok(await _visaCommissionRep.Create(_dto));
  10322. }
  10323. /// <summary>
  10324. /// 签证提成录入
  10325. /// Put(编辑)
  10326. /// </summary>
  10327. /// <param name="id"></param>
  10328. /// <param name="_dto"></param>
  10329. /// <returns></returns>
  10330. [HttpPut]
  10331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10332. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  10333. {
  10334. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10335. var validator = new VisaCommissionCreateDtoValidator();
  10336. var validatorRes = await validator.ValidateAsync(_dto);
  10337. if (!validatorRes.IsValid)
  10338. {
  10339. StringBuilder sb = new StringBuilder();
  10340. foreach (var item in validatorRes.Errors)
  10341. {
  10342. sb.AppendLine(item.ErrorMessage);
  10343. }
  10344. return Ok(JsonView(false, sb.ToString()));
  10345. }
  10346. return Ok(await _visaCommissionRep.Edit(id, _dto));
  10347. }
  10348. /// <summary>
  10349. /// 签证提成录入
  10350. /// Del
  10351. /// </summary>
  10352. /// <param name="id"></param>
  10353. /// <param name="currUserId"></param>
  10354. /// <returns></returns>
  10355. [HttpPost]
  10356. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10357. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  10358. {
  10359. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10360. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  10361. return Ok(await _visaCommissionRep.Del(id, currUserId));
  10362. }
  10363. #endregion
  10364. #region op费用录入
  10365. /// <summary>
  10366. /// 根据diid查询op费用列表
  10367. /// </summary>
  10368. /// <param name="dto"></param>
  10369. /// <returns></returns>
  10370. [HttpPost]
  10371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10372. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  10373. {
  10374. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  10375. if (groupData.Code != 0)
  10376. {
  10377. return Ok(JsonView(false, groupData.Msg));
  10378. }
  10379. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10380. }
  10381. /// <summary>
  10382. /// 根据op费用Id查询单条数据及c表数据
  10383. /// </summary>
  10384. /// <param name="dto"></param>
  10385. /// <returns></returns>
  10386. [HttpPost]
  10387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10388. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  10389. {
  10390. try
  10391. {
  10392. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  10393. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  10394. var data = new
  10395. {
  10396. CarTouristGuideGround = _groupData,
  10397. CreditCardPayment = _creditCardPayment
  10398. };
  10399. return Ok(JsonView(true, "查询成功!", data));
  10400. }
  10401. catch (Exception ex)
  10402. {
  10403. return Ok(JsonView(false, "程序错误!"));
  10404. }
  10405. }
  10406. /// <summary>
  10407. /// op费用删除
  10408. /// </summary>
  10409. /// <param name="dto"></param>
  10410. /// <returns></returns>
  10411. [HttpPost]
  10412. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10413. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  10414. {
  10415. try
  10416. {
  10417. _sqlSugar.BeginTran();
  10418. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  10419. if (!res)
  10420. {
  10421. return Ok(JsonView(false, "删除失败"));
  10422. }
  10423. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  10424. {
  10425. IsDel = 1,
  10426. DeleteUserId = dto.DeleteUserId,
  10427. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10428. }).ExecuteCommandAsync();
  10429. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  10430. {
  10431. IsDel = 1,
  10432. DeleteUserId = dto.DeleteUserId,
  10433. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10434. }).ExecuteCommandAsync();
  10435. #region 删除超支相关数据
  10436. //删除导入的超支数据
  10437. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  10438. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  10439. {
  10440. IsDel = 1,
  10441. DeleteUserId = dto.DeleteUserId,
  10442. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10443. }).ExecuteCommand();
  10444. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  10445. {
  10446. IsDel = 1,
  10447. DeleteUserId = dto.DeleteUserId,
  10448. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10449. }).ExecuteCommand();
  10450. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  10451. {
  10452. IsDel = 1,
  10453. DeleteUserId = dto.DeleteUserId,
  10454. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10455. }).ExecuteCommand();
  10456. #endregion
  10457. _sqlSugar.CommitTran();
  10458. return Ok(JsonView(true, "删除成功!"));
  10459. }
  10460. catch (Exception ex)
  10461. {
  10462. _sqlSugar.RollbackTran();
  10463. return Ok(JsonView(false, "程序错误!" + ex.Message));
  10464. }
  10465. }
  10466. /// <summary>
  10467. /// op费用录入操作(Status:1.新增,2.修改)
  10468. /// </summary>
  10469. /// <param name="dto"></param>
  10470. /// <returns></returns>
  10471. [HttpPost]
  10472. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10473. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  10474. {
  10475. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  10476. if (groupData.Code != 0)
  10477. {
  10478. return Ok(JsonView(false, groupData.Msg));
  10479. }
  10480. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10481. }
  10482. /// <summary>
  10483. /// 填写费用详细页面初始化绑定
  10484. /// </summary>
  10485. /// <param name="dto"></param>
  10486. /// <returns></returns>
  10487. [HttpPost]
  10488. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10489. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  10490. {
  10491. try
  10492. {
  10493. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  10494. if (groupData.Code != 0)
  10495. {
  10496. return Ok(JsonView(false, groupData.Msg));
  10497. }
  10498. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10499. }
  10500. catch (Exception ex)
  10501. {
  10502. return Ok(JsonView(false, ex.Message));
  10503. }
  10504. }
  10505. /// <summary>
  10506. /// 根据op费用Id查询详细数据
  10507. /// </summary>
  10508. /// <param name="dto"></param>
  10509. /// <returns></returns>
  10510. [HttpPost]
  10511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10512. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  10513. {
  10514. try
  10515. {
  10516. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  10517. if (groupData.Code != 0)
  10518. {
  10519. return Ok(JsonView(false, groupData.Msg));
  10520. }
  10521. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10522. }
  10523. catch (Exception ex)
  10524. {
  10525. return Ok(JsonView(false, ex.Message));
  10526. }
  10527. }
  10528. /// <summary>
  10529. /// OP费用录入填写详情
  10530. /// </summary>
  10531. /// <param name="dto"></param>
  10532. /// <returns></returns>
  10533. [HttpPost]
  10534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10535. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  10536. {
  10537. try
  10538. {
  10539. #region 参数校验
  10540. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  10541. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  10542. if (di == null) return Ok(JsonView(false, "团组错误!"));
  10543. #endregion
  10544. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  10545. if (groupData.Code != 0)
  10546. {
  10547. return Ok(JsonView(false, groupData.Msg));
  10548. }
  10549. //自动审核
  10550. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  10551. #region 应用推送
  10552. try
  10553. {
  10554. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10555. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10556. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10557. //2024-10-21 新增LZ UID
  10558. var userIds = new List<int>() { 21 };
  10559. string title = $"系统通知";
  10560. var diId = dto.DiId;
  10561. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10562. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10563. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  10564. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10565. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10566. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10567. }
  10568. catch (Exception ex)
  10569. {
  10570. }
  10571. #endregion
  10572. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10573. }
  10574. catch (Exception ex)
  10575. {
  10576. return Ok(JsonView(false, ex.Message));
  10577. }
  10578. }
  10579. /// <summary>
  10580. /// 获取三公详细所有城市
  10581. /// </summary>
  10582. /// <returns></returns>
  10583. [HttpGet]
  10584. public IActionResult OpCarCityResult()
  10585. {
  10586. var jw = JsonView(false);
  10587. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  10588. {
  10589. x.Id,
  10590. x.Country,
  10591. x.City,
  10592. }).ToList();
  10593. if (data.Count > 0)
  10594. {
  10595. jw = JsonView(true, "获取成功!", data);
  10596. }
  10597. else
  10598. {
  10599. jw.Msg = "城市数据为空!";
  10600. jw.Data = new string[0];
  10601. }
  10602. return Ok(jw);
  10603. }
  10604. /// <summary>
  10605. /// 导出地接费用明细
  10606. /// </summary>
  10607. /// <param name="dto"></param>
  10608. /// <returns></returns>
  10609. [HttpPost]
  10610. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  10611. {
  10612. var jw = JsonView(false);
  10613. if (dto.Diid < 1)
  10614. {
  10615. jw.Msg = "请输入正确的diid!";
  10616. return Ok(jw);
  10617. }
  10618. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  10619. if (group == null)
  10620. {
  10621. jw.Msg = "未找到团组信息!";
  10622. return Ok(jw);
  10623. }
  10624. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  10625. if (localGuideArr.Count == 0)
  10626. {
  10627. jw.Msg = "该团组暂无地接信息!";
  10628. return Ok(jw);
  10629. }
  10630. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  10631. var overspendSoure = new Dictionary<int, int>
  10632. {
  10633. { 91, 982 }, //车
  10634. { 92 , 1059} ,//导游
  10635. { 994 , 1073}, //翻译
  10636. { 988 , 1074 }, //早餐
  10637. { 93 , 1075 }, //午餐
  10638. { 989 , 1076 }, //晚餐
  10639. };
  10640. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  10641. foreach (var groupArr in localGroup)
  10642. {
  10643. var keyValue = groupArr.Key;
  10644. if (int.TryParse(keyValue, out int cityid))
  10645. {
  10646. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  10647. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  10648. }
  10649. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  10650. foreach (var item in groupArr)
  10651. {
  10652. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  10653. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  10654. new Grp_CarTouristGuideGroundReservationsContentExtend
  10655. {
  10656. Count = a.Count,
  10657. CreateTime = a.CreateTime,
  10658. CreateUserId = a.CreateUserId,
  10659. CTGGRId = a.CTGGRId,
  10660. Currency = a.Currency,
  10661. DatePrice = a.DatePrice,
  10662. DeleteTime = a.DeleteTime,
  10663. DeleteUserId = a.DeleteUserId,
  10664. DiId = a.DiId,
  10665. Id = a.Id,
  10666. IsDel = a.IsDel,
  10667. Price = a.Price,
  10668. PriceContent = a.PriceContent,
  10669. Remark = a.Remark,
  10670. SId = a.SId,
  10671. SidName = b.Name,
  10672. Units = a.Units,
  10673. }
  10674. ).ToList();
  10675. if (content.Count > 0)
  10676. {
  10677. contentArr.Add(content);
  10678. }
  10679. }
  10680. //open excel
  10681. //set excel
  10682. //save excel
  10683. try
  10684. {
  10685. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  10686. IWorkbook workbook;
  10687. if (Path.GetExtension(filePath).ToLower() == ".xls")
  10688. {
  10689. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10690. }
  10691. else
  10692. {
  10693. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10694. }
  10695. ISheet sheet = workbook.GetSheetAt(0);
  10696. var rowStartIndex = 2;
  10697. var clounmCount = 10;
  10698. var initStyleRow = sheet.GetRow(2);
  10699. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  10700. //var overspendArrDetail =
  10701. var existsId = new List<CarCompare>();
  10702. var lastElem = arr.Last();
  10703. var thisSid = -1;
  10704. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  10705. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  10706. {
  10707. Name = "未知币种!",
  10708. Remark = "未知币种!",
  10709. };
  10710. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  10711. Action cloneRowFn = () =>
  10712. {
  10713. rowStartIndex++;
  10714. var cloneRow = sheet.CreateRow(rowStartIndex);
  10715. // 复制样式
  10716. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  10717. {
  10718. ICell sourceCell = initStyleRow.GetCell(i);
  10719. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  10720. // 确保单元格存在样式
  10721. if (sourceCell.CellStyle != null)
  10722. {
  10723. targetCell.CellStyle = sourceCell.CellStyle;
  10724. }
  10725. }
  10726. };
  10727. var mergeRow = () =>
  10728. {
  10729. for (int i = 2; i < sheet.LastRowNum; i++)
  10730. {
  10731. var row = sheet.GetRow(i);
  10732. var cellFirst = row.GetCell(0);
  10733. var thisIndex = i + 1;
  10734. while (thisIndex < sheet.LastRowNum)
  10735. {
  10736. var nextRow = sheet.GetRow(thisIndex);
  10737. var nextCellFirst = nextRow.GetCell(0);
  10738. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  10739. {
  10740. thisIndex++;
  10741. }
  10742. else
  10743. {
  10744. break;
  10745. }
  10746. }
  10747. thisIndex--;
  10748. if (thisIndex != i)
  10749. {
  10750. //合并row
  10751. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10752. i, // 起始行索引(0-based)
  10753. thisIndex, // 结束行索引(0-based)
  10754. 0, // 起始列索引(0-based)
  10755. 0 // 结束列索引(0-based)
  10756. );
  10757. sheet.AddMergedRegion(cellRangeAddress);
  10758. i = thisIndex;
  10759. }
  10760. }
  10761. };
  10762. var chaoshiNumber = 0;
  10763. var totalNumber = 0.00M;
  10764. string lastStr = "";
  10765. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  10766. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  10767. {
  10768. b.IsAuditGM,
  10769. x.Id,
  10770. x.Area,
  10771. b.PayPercentage,
  10772. b.PayMoney,
  10773. }).ToList();
  10774. string yesPayment = "", noPayment = "";
  10775. foreach (var item in queryCarArrByCityAndDiid)
  10776. {
  10777. if (item.IsAuditGM == 1)
  10778. {
  10779. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10780. }
  10781. else
  10782. {
  10783. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10784. }
  10785. }
  10786. lastStr = yesPayment + noPayment;
  10787. foreach (var item in arr)
  10788. {
  10789. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  10790. {
  10791. if (thisSid != item.SId)
  10792. {
  10793. if (thisSid == -1)
  10794. {
  10795. thisSid = item.SId;
  10796. }
  10797. else
  10798. {
  10799. //合并小计行
  10800. //创建合并区域的实例
  10801. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10802. rowStartIndex, // 起始行索引(0-based)
  10803. rowStartIndex, // 结束行索引(0-based)
  10804. 0, // 起始列索引(0-based)
  10805. 3 // 结束列索引(0-based)
  10806. );
  10807. sheet.AddMergedRegion(cellRangeAddress);
  10808. var CellStyle = workbook.CreateCellStyle();
  10809. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10810. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10811. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10812. for (int i = 0; i <= clounmCount; i++)
  10813. {
  10814. if (i > 6)
  10815. {
  10816. var CellStyle1 = workbook.CreateCellStyle();
  10817. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10818. IFont Font = workbook.CreateFont(); // 创建字体
  10819. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  10820. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10821. CellStyle1.SetFont(Font);
  10822. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  10823. }
  10824. else
  10825. {
  10826. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  10827. }
  10828. }
  10829. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  10830. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  10831. //超时合计
  10832. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  10833. //超时数
  10834. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  10835. //超时合计费用
  10836. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  10837. thisSid = item.SId;
  10838. cloneRowFn();
  10839. chaoshiNumber = 0;
  10840. totalNumber = 0;
  10841. }
  10842. }
  10843. IRow row = sheet.GetRow(rowStartIndex);
  10844. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10845. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  10846. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  10847. if (isOpenOverspendSoure)
  10848. {
  10849. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10850. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  10851. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  10852. }
  10853. for (int i = 0; i <= clounmCount; i++)
  10854. {
  10855. var cell = row.GetCell(i);
  10856. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  10857. if (cell == null)
  10858. {
  10859. cell = row.CreateCell(i);
  10860. }
  10861. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  10862. fontRed.CloneStyleFrom(cell.CellStyle);
  10863. IFont Font = workbook.CreateFont(); // 创建字体
  10864. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  10865. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10866. fontRed.SetFont(Font);
  10867. byte[] rgb = new byte[3] { 255, 242, 204 };
  10868. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  10869. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  10870. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  10871. if (workbook is XSSFWorkbook)
  10872. {
  10873. BackgroundColor255_242_204.FillForegroundColor = 0;
  10874. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  10875. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  10876. }
  10877. else
  10878. {
  10879. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  10880. }
  10881. if (i == 1 || i > 6)
  10882. {
  10883. if (i > 6)
  10884. {
  10885. fontRed.FillForegroundColor = 0;
  10886. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  10887. fontRed.FillPattern = FillPattern.SolidForeground;
  10888. }
  10889. cell.CellStyle = fontRed;
  10890. }
  10891. if (i > 2 && i < 7)
  10892. {
  10893. cell.CellStyle = BackgroundColor255_242_204;
  10894. }
  10895. cell.SetCellValue(setCellValue); //写入单元格
  10896. }
  10897. if (overspendSoure.ContainsKey(thisSid))
  10898. {
  10899. var overspendId = overspendSoure[thisSid];
  10900. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10901. }
  10902. cloneRowFn();
  10903. existsId.Add(new CarCompare
  10904. {
  10905. DataPrice = item.DatePrice.ObjToDate(),
  10906. Sid = item.SId
  10907. });
  10908. }
  10909. if (item.Equals(lastElem))
  10910. {
  10911. //合并小计行
  10912. //创建合并区域的实例
  10913. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10914. rowStartIndex, // 起始行索引(0-based)
  10915. rowStartIndex, // 结束行索引(0-based)
  10916. 0, // 起始列索引(0-based)
  10917. 3 // 结束列索引(0-based)
  10918. );
  10919. sheet.AddMergedRegion(cellRangeAddress);
  10920. var CellStyle = workbook.CreateCellStyle();
  10921. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10922. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10923. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10924. for (int i = 0; i <= clounmCount; i++)
  10925. {
  10926. if (i > 6)
  10927. {
  10928. var CellStyle1 = workbook.CreateCellStyle();
  10929. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10930. IFont Font = workbook.CreateFont(); // 创建字体
  10931. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  10932. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10933. CellStyle1.SetFont(Font);
  10934. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  10935. }
  10936. else
  10937. {
  10938. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  10939. }
  10940. }
  10941. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  10942. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  10943. //超时合计
  10944. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  10945. //超时数
  10946. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  10947. //超时合计费用
  10948. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  10949. cloneRowFn();
  10950. // 创建合并区域的实例
  10951. cellRangeAddress = new CellRangeAddress(
  10952. rowStartIndex, // 起始行索引(0-based)
  10953. rowStartIndex, // 结束行索引(0-based)
  10954. 0, // 起始列索引(0-based)
  10955. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  10956. );
  10957. // 添加合并区域
  10958. sheet.AddMergedRegion(cellRangeAddress);
  10959. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  10960. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  10961. }
  10962. }
  10963. mergeRow();
  10964. // 保存修改后的Excel文件到新文件
  10965. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  10966. // new FileStream(newFilePath, FileMode.CreateNew)
  10967. using (var stream = new MemoryStream())
  10968. {
  10969. workbook.Write(stream, true);
  10970. stream.Flush();
  10971. stream.Seek(0, SeekOrigin.Begin);
  10972. MemoryStream memoryStream = new MemoryStream();
  10973. stream.CopyTo(memoryStream);
  10974. memoryStream.Seek(0, SeekOrigin.Begin);
  10975. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  10976. }
  10977. workbook.Close();
  10978. workbook.Dispose();
  10979. }
  10980. catch (Exception ex)
  10981. {
  10982. jw.Msg = "出现异常!" + ex.Message;
  10983. return Ok(jw);
  10984. }
  10985. }
  10986. if (Zips.Count > 0)
  10987. {
  10988. IOOperatorHelper io = new IOOperatorHelper();
  10989. var byts = io.ConvertZipStream(Zips);
  10990. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  10991. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  10992. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  10993. }
  10994. else
  10995. {
  10996. jw.Msg = "暂无生成文件!";
  10997. }
  10998. return Ok(jw);
  10999. }
  11000. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  11001. {
  11002. string outStr = string.Empty;
  11003. switch (i)
  11004. {
  11005. case 0:
  11006. outStr = arr[0].SidName;
  11007. break;
  11008. case 1:
  11009. outStr = arr[0].DataPriceStr;
  11010. break;
  11011. case 2:
  11012. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  11013. break;
  11014. case 4:
  11015. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  11016. break;
  11017. case 7:
  11018. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11019. {
  11020. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  11021. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  11022. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  11023. }
  11024. break;
  11025. case 8:
  11026. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11027. {
  11028. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  11029. }
  11030. break;
  11031. case 9:
  11032. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11033. {
  11034. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  11035. }
  11036. break;
  11037. case 10:
  11038. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11039. {
  11040. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  11041. }
  11042. break;
  11043. }
  11044. return outStr;
  11045. }
  11046. #region OP行程单
  11047. /// <summary>
  11048. /// OP行程单初始化
  11049. /// </summary>
  11050. /// <param name="dto"></param>
  11051. /// <returns></returns>
  11052. [HttpPost]
  11053. public IActionResult InitOpTravel(InitOpTravelDto dto)
  11054. {
  11055. var jw = JsonView(false);
  11056. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  11057. var group = groupList.First();
  11058. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11059. if (group == null)
  11060. {
  11061. jw.Msg = "暂无团组!";
  11062. return Ok(jw);
  11063. }
  11064. group = groupList.Find(x => x.Id == diid);
  11065. if (group == null)
  11066. {
  11067. jw.Msg = "请输入正确的团组ID!";
  11068. return Ok(jw);
  11069. }
  11070. string city = string.Empty;
  11071. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  11072. if (blackCode.Count > 0)
  11073. {
  11074. var black = blackCode.First();
  11075. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  11076. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  11077. if (blackSp.Length > 0)
  11078. {
  11079. try
  11080. {
  11081. var cityArrCode = new List<string>(20);
  11082. foreach (var item in blackSp)
  11083. {
  11084. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  11085. var IndexSelect = itemSp[2];
  11086. var cityArrCodeLength = cityArrCode.Count - 1;
  11087. var startCity = IndexSelect.Substring(0, 3);
  11088. if (cityArrCodeLength > 0)
  11089. {
  11090. var arrEndCity = cityArrCode[cityArrCodeLength];
  11091. if (arrEndCity != startCity)
  11092. {
  11093. cityArrCode.Add(startCity.ToUpper());
  11094. }
  11095. }
  11096. else
  11097. {
  11098. cityArrCode.Add(startCity.ToUpper());
  11099. }
  11100. var endCity = IndexSelect.Substring(3, 3);
  11101. cityArrCode.Add(endCity.ToUpper());
  11102. }
  11103. var cityThree = string.Empty;
  11104. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  11105. cityThree = cityThree.TrimEnd(',');
  11106. if (string.IsNullOrWhiteSpace(cityThree))
  11107. {
  11108. throw new
  11109. Exception("error");
  11110. }
  11111. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  11112. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  11113. foreach (var item in cityArrCode)
  11114. {
  11115. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  11116. if (find != null)
  11117. {
  11118. city += find.City + "/";
  11119. }
  11120. else
  11121. {
  11122. city += item + "三字码未收入/";
  11123. }
  11124. }
  11125. city = city.TrimEnd('/');
  11126. }
  11127. catch (Exception e)
  11128. {
  11129. city = "黑屏代码格式不正确!";
  11130. }
  11131. }
  11132. }
  11133. else
  11134. {
  11135. city = "未录入黑屏代码";
  11136. }
  11137. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  11138. {
  11139. Date = x.Date,
  11140. Days = x.Days,
  11141. Diffgroup = x.Diffgroup,
  11142. Diid = x.Diid,
  11143. Traffic_First = x.Traffic_First,
  11144. Traffic_Second = x.Traffic_Second,
  11145. Trip = x.Trip,
  11146. WeekDay = x.WeekDay,
  11147. Id = x.Id
  11148. }).ToList();
  11149. jw.Data = new
  11150. {
  11151. groupList = groupList.Select(x => new
  11152. {
  11153. x.Id,
  11154. x.TeamName,
  11155. x.TourCode
  11156. }).ToList(),
  11157. groupInfo = new
  11158. {
  11159. group.VisitDays,
  11160. group.TourCode,
  11161. group.VisitPNumber,
  11162. group.TeamName,
  11163. city
  11164. },
  11165. OpTravelList
  11166. };
  11167. jw.Code = 200;
  11168. jw.Msg = "操作成功!";
  11169. return Ok(jw);
  11170. }
  11171. /// <summary>
  11172. /// 删除团组行程单
  11173. /// </summary>
  11174. /// <returns></returns>
  11175. [HttpPost]
  11176. public IActionResult DelTravel(DelOpTravelDto dto)
  11177. {
  11178. var jw = JsonView(false);
  11179. if (dto.UserId <= 0 || dto.Diid <= 0)
  11180. {
  11181. jw.Msg = "请输入正确的参数!";
  11182. return Ok(jw);
  11183. }
  11184. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  11185. .SetColumns(x => new Grp_TravelList
  11186. {
  11187. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11188. DeleteUserId = dto.UserId,
  11189. IsDel = 1,
  11190. }).ExecuteCommand();
  11191. jw = JsonView(true);
  11192. return Ok(jw);
  11193. }
  11194. /// <summary>
  11195. /// 行程单保存
  11196. /// </summary>
  11197. /// <returns></returns>
  11198. [HttpPost]
  11199. public IActionResult TravelSave(TravelSaveDto dto)
  11200. {
  11201. var jw = JsonView(false);
  11202. if (dto.Arr.Count > 0)
  11203. {
  11204. try
  11205. {
  11206. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  11207. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  11208. .ToList();
  11209. _sqlSugar.BeginTran();
  11210. foreach (var item in dto.Arr)
  11211. {
  11212. if (item.Id == 0)
  11213. {
  11214. throw new Exception("请传入正确的Id");
  11215. }
  11216. //比较上一次的差异
  11217. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  11218. if (findTravel != null)
  11219. {
  11220. item.Trip = item.Trip.Replace("[++]", string.Empty);
  11221. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  11222. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  11223. }
  11224. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  11225. .SetColumns(x => new Grp_TravelList
  11226. {
  11227. Trip = item.Trip
  11228. }).ExecuteCommand();
  11229. }
  11230. _sqlSugar.CommitTran();
  11231. jw = JsonView(true);
  11232. }
  11233. catch (Exception ex)
  11234. {
  11235. _sqlSugar.RollbackTran();
  11236. jw.Msg = "程序异常!" + ex.Message;
  11237. }
  11238. }
  11239. else
  11240. {
  11241. jw.Msg = "请传入正确的参数!";
  11242. }
  11243. return Ok(jw);
  11244. }
  11245. private string CheckStr(string original, string changed)
  11246. {
  11247. // 创建diff_match_patch对象
  11248. var dmp = new diff_match_patch();
  11249. // 计算差异
  11250. List<Diff> diffs = dmp.diff_main(original, changed);
  11251. // 清理和合并差异
  11252. dmp.diff_cleanupSemantic(diffs);
  11253. // 使用StringBuilder构建最终的字符串
  11254. StringBuilder finalString = new StringBuilder();
  11255. // 输出差异结果,并构建变动后的字符串
  11256. foreach (Diff diff in diffs)
  11257. {
  11258. switch (diff.operation)
  11259. {
  11260. case Operation.EQUAL:
  11261. // 相等的部分,直接添加到最终字符串
  11262. finalString.Append(diff.text);
  11263. break;
  11264. case Operation.INSERT:
  11265. // 插入的部分,添加标记并添加到最终字符串
  11266. finalString.Append("[++]" + diff.text + "[++]");
  11267. break;
  11268. case Operation.DELETE:
  11269. // 删除的部分,不添加到最终字符串
  11270. //finalString.Append("[++]" + diff.text + "[++]");
  11271. break;
  11272. }
  11273. }
  11274. // 输出变动后的字符串
  11275. return finalString.ToString();
  11276. }
  11277. private class tagContent
  11278. {
  11279. public DateTime Date { get; set; }
  11280. public string StartTag { get; set; }
  11281. public string EndTag { get; set; }
  11282. public string Content { get; set; }
  11283. public static int tagLength { get { return 3; } }
  11284. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  11285. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  11286. public bool IsFinally { get; set; }
  11287. }
  11288. private List<string> ExtractContentBetweenTags(string input, string tag)
  11289. {
  11290. List<string> results = new List<string>();
  11291. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  11292. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  11293. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  11294. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  11295. string[] strValueArr = new string[1];
  11296. foreach (System.Text.RegularExpressions.Match match in matches)
  11297. {
  11298. var strValue = match.Groups[1].Value;
  11299. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  11300. }
  11301. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  11302. return results;
  11303. }
  11304. /// <summary>
  11305. /// 导出行程单
  11306. /// </summary>
  11307. /// <param name="dto"></param>
  11308. /// <returns></returns>
  11309. [HttpPost]
  11310. public IActionResult ExportTravel(ExportTravelDto dto)
  11311. {
  11312. var jw = JsonView(false);
  11313. jw.Data = "";
  11314. int diid = 0;
  11315. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  11316. if (Find == null)
  11317. {
  11318. jw.Msg = "请选择正确的团组!";
  11319. return Ok(jw);
  11320. }
  11321. else
  11322. {
  11323. diid = Find.Id;
  11324. }
  11325. //数据源
  11326. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  11327. DataTable dtBlack = null;
  11328. try
  11329. {
  11330. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  11331. }
  11332. catch (Exception)
  11333. {
  11334. jw.Msg = "机票黑屏代码有误!";
  11335. return Ok(jw);
  11336. }
  11337. string CityStr = string.Empty;
  11338. if (dtBlack.Rows.Count == 0)
  11339. {
  11340. jw.Msg = "机票黑屏代码有误!";
  11341. return Ok(jw);
  11342. }
  11343. else
  11344. {
  11345. foreach (DataRow row in dtBlack.Rows)
  11346. {
  11347. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11348. {
  11349. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  11350. return Ok(jw);
  11351. }
  11352. }
  11353. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  11354. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  11355. }
  11356. // 指定的文字
  11357. var targetTextDic = new Dictionary<string, List<string>>();
  11358. //创建数据源Table
  11359. DataTable dtSource = new DataTable();
  11360. dtSource.Columns.Add("Days", typeof(string));
  11361. dtSource.Columns.Add("Date", typeof(string));
  11362. dtSource.Columns.Add("Week", typeof(string));
  11363. dtSource.Columns.Add("Traffic", typeof(string));
  11364. dtSource.Columns.Add("Trip", typeof(string));
  11365. //获取数据,放到datatable
  11366. foreach (var item in _travelList)
  11367. {
  11368. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  11369. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  11370. .Replace(tagContent.TagFormat.Item2, string.Empty)
  11371. .Replace("[++]", string.Empty);
  11372. DataRow dr = dtSource.NewRow();
  11373. dr["Days"] = item.Days;
  11374. dr["Date"] = item.Date;
  11375. dr["Week"] = item.WeekDay;
  11376. dr["Traffic"] = item.Traffic_First
  11377. + "\r\n"
  11378. + item.Traffic_Second;
  11379. dr["Trip"] = item.Trip;
  11380. dtSource.Rows.Add(dr);
  11381. }
  11382. Dictionary<string, string> dic = new Dictionary<string, string>();
  11383. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  11384. dic.Add("City", CityStr);
  11385. dic.Add("Days", Find.VisitDays.ToString());
  11386. dic.Add("DeleCode", Find.TourCode);
  11387. dic.Add("Pnum", Find.VisitPNumber.ToString());
  11388. //模板路径
  11389. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  11390. //载入模板
  11391. Document doc = null;
  11392. DocumentBuilder builder = null;
  11393. try
  11394. {
  11395. //载入模板
  11396. doc = new Document(tempPath);
  11397. builder = new DocumentBuilder(doc);
  11398. }
  11399. catch (Exception)
  11400. {
  11401. jw.Msg = "模板位置不存在!";
  11402. return Ok(jw);
  11403. }
  11404. foreach (var key in dic.Keys)
  11405. {
  11406. Bookmark bookmark = doc.Range.Bookmarks[key];
  11407. if (bookmark != null)
  11408. {
  11409. builder.MoveToBookmark(key);
  11410. builder.Write(dic[key]);
  11411. }
  11412. }
  11413. //获取word里所有表格
  11414. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11415. //获取所填表格的序数
  11416. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11417. try
  11418. {
  11419. //循环赋值
  11420. for (int i = 0; i < dtSource.Rows.Count; i++)
  11421. {
  11422. builder.MoveToCell(0, i + 1, 0, 0);
  11423. builder.Write(dtSource.Rows[i]["Days"].ToString());
  11424. builder.MoveToCell(0, i + 1, 1, 0);
  11425. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  11426. builder.MoveToCell(0, i + 1, 2, 0);
  11427. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  11428. var trip = dtSource.Rows[i]["Trip"].ToString();
  11429. builder.MoveToCell(0, i + 1, 3, 0);
  11430. builder.Write(trip);
  11431. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  11432. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11433. // 获取特定索引的段落
  11434. Paragraph paragraph = (Paragraph)paragraphs[0];
  11435. Run run = paragraph.Runs[0];
  11436. Aspose.Words.Font font = run.Font;
  11437. font.Name = "黑体";
  11438. //设置双休红色
  11439. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  11440. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11441. paragraph = (Paragraph)paragraphs[1];
  11442. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  11443. {
  11444. run = paragraph.Runs[0];
  11445. font = run.Font;
  11446. font.Color = Color.Red;
  11447. }
  11448. }
  11449. }
  11450. catch (Exception ex)
  11451. {
  11452. }
  11453. //删除多余行
  11454. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  11455. {
  11456. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  11457. }
  11458. var targetTextList = new List<string>();
  11459. // 遍历文档中的表格
  11460. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11461. {
  11462. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11463. {
  11464. var cellIndex = 0;
  11465. foreach (Cell cell in row.Cells)
  11466. {
  11467. if (cellIndex == 1 && row.Cells.Count == 4)
  11468. {
  11469. foreach (var target in targetTextDic.Keys)
  11470. {
  11471. if (cell.GetText().Contains(target))
  11472. {
  11473. targetTextList = targetTextDic[target];
  11474. break;
  11475. }
  11476. }
  11477. }
  11478. // 遍历单元格中的所有段落
  11479. foreach (Paragraph paragraph in cell.Paragraphs)
  11480. {
  11481. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  11482. List<Run> runs = new List<Run>();
  11483. foreach (Run run in paragraph.Runs)
  11484. {
  11485. runs.Add(run);
  11486. }
  11487. foreach (Run run in runs)
  11488. {
  11489. foreach (var targetText in targetTextList)
  11490. {
  11491. // 检查文字是否包含指定文字
  11492. if (run.Text.Contains(targetText))
  11493. {
  11494. // 将包含的部分设置为红色
  11495. HighlightText(run, targetText, Color.Red);
  11496. }
  11497. }
  11498. }
  11499. }
  11500. cellIndex++;
  11501. }
  11502. }
  11503. }
  11504. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  11505. if (!Directory.Exists(savePath))
  11506. {
  11507. try
  11508. {
  11509. Directory.CreateDirectory(savePath);
  11510. }
  11511. catch
  11512. {
  11513. }
  11514. }
  11515. string path = savePath + Find.TeamName + "出访日程";
  11516. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  11517. try
  11518. {
  11519. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  11520. string postfix = ".docx";
  11521. if (dto.IsPDF == 1)
  11522. {
  11523. saveFormat = Aspose.Words.SaveFormat.Pdf;
  11524. postfix = ".pdf";
  11525. }
  11526. doc.Save(path + postfix, saveFormat);
  11527. jw = JsonView(true, "导出成功", ftpPath + postfix);
  11528. }
  11529. catch (Exception)
  11530. {
  11531. jw = JsonView(false);
  11532. }
  11533. return Ok(jw);
  11534. }
  11535. /// <summary>
  11536. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  11537. /// </summary>
  11538. /// <param name="num"></param>
  11539. /// <returns></returns>
  11540. string GetNum(string num)
  11541. {
  11542. string str = "";
  11543. switch (num)
  11544. {
  11545. case "1":
  11546. str = "一";
  11547. break;
  11548. case "2":
  11549. str = "二";
  11550. break;
  11551. case "3":
  11552. str = "三";
  11553. break;
  11554. case "4":
  11555. str = "四";
  11556. break;
  11557. case "5":
  11558. str = "五";
  11559. break;
  11560. case "6":
  11561. str = "六";
  11562. break;
  11563. case "7":
  11564. str = "七";
  11565. break;
  11566. case "8":
  11567. str = "八";
  11568. break;
  11569. case "9":
  11570. str = "九";
  11571. break;
  11572. case "10":
  11573. str = "十";
  11574. break;
  11575. case "11":
  11576. str = "十一";
  11577. break;
  11578. case "12":
  11579. str = "十二";
  11580. break;
  11581. case "一":
  11582. str = "1";
  11583. break;
  11584. case "二":
  11585. str = "2";
  11586. break;
  11587. case "三":
  11588. str = "3";
  11589. break;
  11590. case "四":
  11591. str = "4";
  11592. break;
  11593. case "五":
  11594. str = "5";
  11595. break;
  11596. case "六":
  11597. str = "6";
  11598. break;
  11599. case "七":
  11600. str = "7";
  11601. break;
  11602. case "八":
  11603. str = "8";
  11604. break;
  11605. case "九":
  11606. str = "9";
  11607. break;
  11608. case "十":
  11609. str = "10";
  11610. break;
  11611. case "十一":
  11612. str = "11";
  11613. break;
  11614. case "十二":
  11615. str = "12";
  11616. break;
  11617. }
  11618. return str;
  11619. }
  11620. // 高亮包含指定文字的部分
  11621. void HighlightText(Run run, string targetText, Color color)
  11622. {
  11623. string text = run.Text;
  11624. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  11625. if (startIndex >= 0)
  11626. {
  11627. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  11628. // 前部分
  11629. if (startIndex > 0)
  11630. {
  11631. Run beforeRun = (Run)run.Clone(true);
  11632. beforeRun.Text = text.Substring(0, startIndex);
  11633. parentParagraph.InsertBefore(beforeRun, run);
  11634. }
  11635. // 匹配部分
  11636. Run matchRun = (Run)run.Clone(true);
  11637. matchRun.Text = text.Substring(startIndex, targetText.Length);
  11638. matchRun.Font.Color = color;
  11639. parentParagraph.InsertBefore(matchRun, run);
  11640. // 后部分
  11641. if (startIndex + targetText.Length < text.Length)
  11642. {
  11643. Run afterRun = (Run)run.Clone(true);
  11644. afterRun.Text = text.Substring(startIndex + targetText.Length);
  11645. parentParagraph.InsertBefore(afterRun, run);
  11646. }
  11647. // 删除原始Run
  11648. run.Remove();
  11649. }
  11650. }
  11651. #endregion
  11652. #endregion
  11653. #region 团组成本
  11654. /// <summary>
  11655. /// 团组成本数据初始化
  11656. /// </summary>
  11657. /// <param name="dto"></param>
  11658. /// <returns></returns>
  11659. [HttpPost]
  11660. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  11661. {
  11662. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  11663. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  11664. WHEN COUNT(*) >= 0 THEN 'True'
  11665. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  11666. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  11667. ").ToList(); //团组列表
  11668. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  11669. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  11670. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  11671. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  11672. if (groupinfoValue != null)
  11673. {
  11674. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  11675. var spArr = new string[1] { countryArr };
  11676. if (countryArr.Contains("|"))
  11677. {
  11678. spArr = countryArr.Split("|");
  11679. }
  11680. else if (countryArr.Contains("、"))
  11681. {
  11682. spArr = countryArr.Split("、");
  11683. }
  11684. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  11685. {
  11686. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  11687. if (dbQueryCountry != null)
  11688. {
  11689. visaCountryInfoArr.Add(dbQueryCountry);
  11690. }
  11691. }
  11692. }
  11693. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  11694. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  11695. var create = _GroupCostRepository.
  11696. CreateGroupCostByBlackCode(dto.Diid);
  11697. if (groupCost.Count == 0 && create.Code == 0)
  11698. {
  11699. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  11700. }
  11701. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  11702. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  11703. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  11704. groupCostMap = groupCostMap.Select(x =>
  11705. {
  11706. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  11707. {
  11708. x.Date = dataForamt.ToString("yyyy-MM-dd");
  11709. }
  11710. return x;
  11711. }).ToList();
  11712. //GroupCostParameter.Add(new
  11713. // Grp_GroupCostParameter());
  11714. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  11715. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  11716. return Ok(JsonView(new
  11717. {
  11718. groupList,
  11719. groupInfo,
  11720. groupChecks,
  11721. groupCost = groupCostMap,
  11722. hotelNumber,
  11723. GroupCostParameter = GroupCostParameterMap,
  11724. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  11725. {
  11726. x.VisaCountry,
  11727. x.VisaPrice,
  11728. x.Id,
  11729. }).ToList(),
  11730. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  11731. blackCodeIsTrue = create.Code == 0 ? true : false,
  11732. hotelIsTrue = hotelIsTrue,
  11733. }));
  11734. }
  11735. /// <summary>
  11736. /// 团组成本信息保存
  11737. /// </summary>
  11738. /// <param name="dto"></param>
  11739. /// <returns></returns>
  11740. [HttpPost]
  11741. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  11742. {
  11743. if (dto.Diid <= 0 || dto.Userid <= 0)
  11744. {
  11745. return Ok(JsonView(false));
  11746. }
  11747. JsonView jw = null;
  11748. bool isTrue = false;
  11749. #region 复制团组成本
  11750. //if (dto.Diid == 2581)
  11751. //{
  11752. // dto.Diid = 2599;
  11753. // dto.CheckBoxs.ForEach(x =>
  11754. // {
  11755. // x.Diid = 2599;
  11756. // });
  11757. // dto.GroupCosts.ForEach(x =>
  11758. // {
  11759. // x.Diid = 2599;
  11760. // });
  11761. // dto.CostTypeHotelNumbers.ForEach(x =>
  11762. // {
  11763. // x.Diid = 2599;
  11764. // });
  11765. // dto.GroupCostParameters.ForEach(x =>
  11766. // {
  11767. // x.DiId = 2599;
  11768. // });
  11769. //}
  11770. #endregion
  11771. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  11772. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  11773. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  11774. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  11775. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  11776. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  11777. try
  11778. {
  11779. _sqlSugar.BeginTran();
  11780. isTrue = await _GroupCostRepository.
  11781. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  11782. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  11783. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  11784. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  11785. _sqlSugar.CommitTran();
  11786. jw = JsonView(true, "保存成功!", isTrue);
  11787. }
  11788. catch (Exception)
  11789. {
  11790. _sqlSugar.RollbackTran();
  11791. jw = JsonView(false);
  11792. }
  11793. return Ok(jw);
  11794. }
  11795. /// <summary>
  11796. /// 司兼导数据
  11797. /// </summary>
  11798. /// <param name="dto"></param>
  11799. /// <returns></returns>
  11800. [HttpPost]
  11801. public IActionResult GetCarGuides(CarGuidesDto dto)
  11802. {
  11803. JsonView jw = null;
  11804. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  11805. jw = JsonView(true, "获取成功!", Data);
  11806. return Ok(jw);
  11807. }
  11808. /// <summary>
  11809. /// 导游数据
  11810. /// </summary>
  11811. /// <param name="dto"></param>
  11812. /// <returns></returns>
  11813. [HttpPost]
  11814. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  11815. {
  11816. JsonView jw = null;
  11817. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  11818. // 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
  11819. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  11820. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  11821. jw = JsonView(true, "获取成功!", Data);
  11822. return Ok(jw);
  11823. }
  11824. /// <summary>
  11825. /// 成本车数据
  11826. /// </summary>
  11827. /// <param name="dto"></param>
  11828. /// <returns></returns>
  11829. [HttpPost]
  11830. public IActionResult GetCarInfo(CarGuidesDto dto)
  11831. {
  11832. JsonView jw = null;
  11833. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  11834. jw = JsonView(true, "获取成功!", Data);
  11835. return Ok(jw);
  11836. }
  11837. /// <summary>
  11838. /// 景点数据
  11839. /// </summary>
  11840. /// <param name="dto"></param>
  11841. /// <returns></returns>
  11842. [HttpPost]
  11843. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  11844. {
  11845. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  11846. return Ok(JsonView(true, "获取成功!", Data));
  11847. }
  11848. /// <summary>
  11849. /// 成本通知
  11850. /// </summary>
  11851. /// <param name="dto"></param>
  11852. /// <returns></returns>
  11853. [HttpPost]
  11854. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  11855. {
  11856. if (dto.Diid < 0)
  11857. {
  11858. return Ok(JsonView(false));
  11859. }
  11860. JsonView jw = null;
  11861. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  11862. if (GroupCostParameter != null)
  11863. {
  11864. int IsShare = 0;
  11865. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  11866. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  11867. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  11868. string msg = string.Empty;
  11869. if (isTrue)
  11870. {
  11871. if (IsShare == 0)
  11872. {
  11873. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  11874. }
  11875. else
  11876. {
  11877. #region 企微通知对应岗位用户
  11878. try
  11879. {
  11880. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  11881. }
  11882. catch (Exception ex)
  11883. {
  11884. }
  11885. #endregion
  11886. msg = "通知成功,其他模块操作人员可见此成本信息!";
  11887. }
  11888. jw = JsonView(isTrue, msg, new { IsShare });
  11889. }
  11890. else
  11891. {
  11892. msg = "修改失败!";
  11893. jw = JsonView(isTrue, msg);
  11894. }
  11895. }
  11896. else
  11897. {
  11898. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  11899. }
  11900. return Ok(jw);
  11901. }
  11902. /// <summary>
  11903. /// 导出报价单
  11904. /// </summary>
  11905. /// <param name="dto"></param>
  11906. /// <returns></returns>
  11907. [HttpPost]
  11908. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  11909. {
  11910. if (dto.Diid == 0)
  11911. {
  11912. return Ok(JsonView(false, "请传递团组id"));
  11913. }
  11914. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  11915. if (deleInfo.Code != 0)
  11916. {
  11917. return Ok(JsonView(false, "团组信息查询失败!"));
  11918. }
  11919. var di = deleInfo.Data as DelegationInfoWebView;
  11920. if (di != null)
  11921. {
  11922. di.TeamName = di.TeamName.Replace("|", "、");
  11923. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  11924. //文件名
  11925. string strFileName = di.TeamName + "-收款账单.doc";
  11926. //获取模板
  11927. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  11928. //载入模板
  11929. Document doc = new Document(tmppath);
  11930. decimal TotalPrice = 0.00M;
  11931. string itemStr = string.Empty;
  11932. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  11933. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  11934. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  11935. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  11936. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  11937. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  11938. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  11939. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  11940. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  11941. foreach (var cost in groupCostType)
  11942. {
  11943. var List = cost.ToList();
  11944. if (cost.Key == "A")
  11945. {
  11946. foreach (var ListItem in List)
  11947. {
  11948. if (ListItem.number > 0)
  11949. {
  11950. if (ListItem.code.Contains("TBR"))
  11951. {
  11952. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11953. }
  11954. else
  11955. {
  11956. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11957. }
  11958. TotalPrice += (ListItem.number * ListItem.price);
  11959. }
  11960. }
  11961. }
  11962. else
  11963. {
  11964. itemStr = itemStr.Insert(0, "A段\r\n");
  11965. itemStr += "B段\r\n";
  11966. foreach (var ListItem in List)
  11967. {
  11968. if (ListItem.number > 0)
  11969. {
  11970. if (ListItem.code.Contains("TBR"))
  11971. {
  11972. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11973. }
  11974. else
  11975. {
  11976. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11977. }
  11978. TotalPrice += (ListItem.number * ListItem.price);
  11979. }
  11980. }
  11981. }
  11982. }
  11983. #region 替换Word模板书签内容
  11984. Dictionary<string, string> marks = new Dictionary<string, string>();
  11985. marks.Add("To", di.ClientUnit);//付款方
  11986. marks.Add("ToTel", di.TellPhone);//付款方电话
  11987. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  11988. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  11989. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  11990. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  11991. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  11992. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  11993. marks.Add("PayItemContent", itemStr);//详细信息
  11994. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  11995. #endregion
  11996. ////注
  11997. //if (doc.Range.Bookmarks["Attention"] != null)
  11998. //{
  11999. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  12000. // mark.Text = frList[0].Attention;
  12001. //}
  12002. foreach (var item in marks.Keys)
  12003. {
  12004. if (doc.Range.Bookmarks[item] != null)
  12005. {
  12006. Bookmark mark = doc.Range.Bookmarks[item];
  12007. mark.Text = marks[item];
  12008. }
  12009. }
  12010. byte[] bytes = null;
  12011. using (MemoryStream stream = new MemoryStream())
  12012. {
  12013. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  12014. bytes = stream.ToArray();
  12015. }
  12016. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  12017. return Ok(JsonView(true, "", new
  12018. {
  12019. Data = bytes,
  12020. strFileName,
  12021. }));
  12022. }
  12023. else
  12024. {
  12025. return Ok(JsonView(false, "团组信息不存在!"));
  12026. }
  12027. }
  12028. /// <summary>
  12029. /// 导出团组成本
  12030. /// </summary>
  12031. /// <param name="dto"></param>
  12032. /// <returns></returns>
  12033. [HttpPost]
  12034. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  12035. {
  12036. var jw = JsonView(false);
  12037. if (dto.Diid == 0)
  12038. {
  12039. return Ok(JsonView(false, "请传递团组id"));
  12040. }
  12041. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12042. if (deleInfo.Code != 0)
  12043. {
  12044. return Ok(JsonView(false, "团组信息查询失败!"));
  12045. }
  12046. var di = deleInfo.Data as DelegationInfoWebView;
  12047. if (di == null)
  12048. {
  12049. return Ok(JsonView(false, "团组信息查询失败!"));
  12050. }
  12051. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  12052. WorkbookDesigner designer = new WorkbookDesigner();
  12053. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  12054. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  12055. for (int i = 0; i < List_GC.Count; i++)
  12056. {
  12057. GroupCost_Excel gc = new GroupCost_Excel();
  12058. gc.Id = List_GC[i].Id;
  12059. gc.Diid = List_GC[i].Diid.ToString();
  12060. gc.DAY = List_GC[i].DAY;
  12061. string week = "";
  12062. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  12063. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  12064. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  12065. gc.ITIN = List_GC[i].ITIN;
  12066. gc.CarType = List_GC[i].CarType;
  12067. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  12068. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  12069. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  12070. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  12071. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  12072. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  12073. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  12074. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  12075. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  12076. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  12077. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  12078. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  12079. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12080. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12081. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  12082. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  12083. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  12084. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  12085. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  12086. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  12087. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  12088. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  12089. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  12090. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  12091. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  12092. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  12093. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  12094. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  12095. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  12096. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  12097. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  12098. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  12099. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  12100. List_GC1.Add(gc);
  12101. }
  12102. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  12103. dt.TableName = "TB";
  12104. //报表标题等不用dt的值
  12105. designer.SetDataSource("TeamName", dto.title.TeamName);
  12106. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  12107. designer.SetDataSource("Tax", dto.title.Tax);
  12108. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  12109. designer.SetDataSource("Currency", dto.title.Currency);
  12110. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  12111. designer.SetDataSource("Rate", dto.title.Rate);
  12112. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  12113. var Aparams = hotels.Find(x => x.Type == "Default");
  12114. if (Aparams == null)
  12115. {
  12116. return Ok(jw);
  12117. }
  12118. //酒店数量
  12119. var txtSGRNumber = Aparams.SGR.ToString();
  12120. var txtTBRNumber = Aparams.TBR.ToString();
  12121. var txtJSESNumber = Aparams.JSES.ToString();
  12122. var txtSUITENumbe = Aparams.SUITE.ToString();
  12123. if (dto.costType == "B")
  12124. {
  12125. Aparams = hotels.Find(x => x.Type == "A");
  12126. var Bparams = hotels.Find(x => x.Type == "B");
  12127. if (Aparams == null || Bparams == null)
  12128. {
  12129. return Ok(jw);
  12130. }
  12131. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  12132. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  12133. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  12134. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  12135. }
  12136. designer.SetDataSource("SGRNumber", txtSGRNumber);
  12137. designer.SetDataSource("TBRNumber", txtTBRNumber);
  12138. designer.SetDataSource("JSESNumber", txtJSESNumber);
  12139. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  12140. var ws = designer.Workbook.Worksheets[0];
  12141. int Row = List_GC.Count;
  12142. int startIndex = 11;
  12143. int HideRows = 0;
  12144. List<int> hideRowsList = new List<int>();
  12145. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  12146. #region A段left数据
  12147. var left = dto.leftInfo.Find(x => x.Type == "A");
  12148. if (left == null)
  12149. {
  12150. return Ok(jw);
  12151. }
  12152. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  12153. if (leftBindData != null)
  12154. {
  12155. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  12156. designer.SetDataSource("VisaRS", leftBindData.rs);
  12157. designer.SetDataSource("VisaXS", leftBindData.xs);
  12158. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12159. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12160. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12161. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12162. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12163. }
  12164. else
  12165. {
  12166. hideRowsList.Add(Row + startIndex + HideRows);
  12167. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12168. }
  12169. HideRows += 2;
  12170. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  12171. if (leftBindData != null)
  12172. {
  12173. designer.SetDataSource("BXDRCB", leftBindData.cb);
  12174. designer.SetDataSource("BXRS", leftBindData.rs);
  12175. designer.SetDataSource("BXXS", leftBindData.xs);
  12176. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12177. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12178. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12179. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12180. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12181. }
  12182. else
  12183. {
  12184. hideRowsList.Add(Row + startIndex + HideRows);
  12185. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12186. }
  12187. HideRows += 2;
  12188. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12189. if (leftBindData != null)
  12190. {
  12191. designer.SetDataSource("HSDRCB", leftBindData.cb);
  12192. designer.SetDataSource("HSRS", leftBindData.rs);
  12193. designer.SetDataSource("HSXS", leftBindData.xs);
  12194. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12195. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12196. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12197. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12198. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12199. }
  12200. else
  12201. {
  12202. hideRowsList.Add(Row + startIndex + HideRows);
  12203. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12204. }
  12205. HideRows += 2;
  12206. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12207. if (leftBindData != null)
  12208. {
  12209. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  12210. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  12211. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  12212. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12213. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12214. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12215. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12216. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12217. }
  12218. else
  12219. {
  12220. hideRowsList.Add(Row + startIndex + HideRows);
  12221. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12222. }
  12223. HideRows += 2;
  12224. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12225. if (leftBindData != null)
  12226. {
  12227. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  12228. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  12229. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  12230. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12231. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12232. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12233. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12234. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12235. }
  12236. else
  12237. {
  12238. hideRowsList.Add(Row + startIndex + HideRows);
  12239. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12240. }
  12241. HideRows += 2;
  12242. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12243. if (leftBindData != null)
  12244. {
  12245. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  12246. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  12247. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  12248. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12249. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12250. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12251. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12252. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12253. }
  12254. else
  12255. {
  12256. hideRowsList.Add(Row + startIndex + HideRows);
  12257. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12258. }
  12259. HideRows += 2;
  12260. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12261. if (leftBindData != null)
  12262. {
  12263. ////TBR
  12264. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  12265. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  12266. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  12267. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12268. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12269. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12270. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12271. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12272. }
  12273. else
  12274. {
  12275. hideRowsList.Add(Row + startIndex + HideRows);
  12276. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12277. }
  12278. HideRows += 2;
  12279. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12280. if (leftBindData != null)
  12281. {
  12282. ////SGR
  12283. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  12284. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  12285. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  12286. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12287. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12288. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12289. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12290. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12291. }
  12292. else
  12293. {
  12294. hideRowsList.Add(Row + startIndex + HideRows);
  12295. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12296. }
  12297. HideRows += 2;
  12298. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12299. if (leftBindData != null)
  12300. {
  12301. ////JS/ES
  12302. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  12303. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  12304. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  12305. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12306. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12307. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12308. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12309. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12310. }
  12311. else
  12312. {
  12313. hideRowsList.Add(Row + startIndex + HideRows);
  12314. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12315. }
  12316. HideRows += 2;
  12317. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12318. if (leftBindData != null)
  12319. {
  12320. ////SUITE
  12321. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  12322. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  12323. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  12324. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12325. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12326. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12327. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12328. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12329. }
  12330. else
  12331. {
  12332. hideRowsList.Add(Row + startIndex + HideRows);
  12333. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12334. }
  12335. HideRows += 2;
  12336. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12337. if (leftBindData != null)
  12338. {
  12339. designer.SetDataSource("DJDRCB", leftBindData.cb);
  12340. designer.SetDataSource("DJRS", leftBindData.rs);
  12341. designer.SetDataSource("DJXS", leftBindData.xs);
  12342. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12343. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12344. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12345. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12346. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12347. }
  12348. else
  12349. {
  12350. hideRowsList.Add(Row + startIndex + HideRows);
  12351. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12352. }
  12353. HideRows += 2;
  12354. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12355. if (leftBindData != null)
  12356. {
  12357. designer.SetDataSource("HCPCB", leftBindData.cb);
  12358. designer.SetDataSource("HCPRS", leftBindData.rs);
  12359. designer.SetDataSource("HCPXS", leftBindData.xs);
  12360. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12361. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12362. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12363. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12364. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12365. }
  12366. else
  12367. {
  12368. hideRowsList.Add(Row + startIndex + HideRows);
  12369. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12370. }
  12371. HideRows += 2;
  12372. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12373. if (leftBindData != null)
  12374. {
  12375. designer.SetDataSource("CPCB", leftBindData.cb);
  12376. designer.SetDataSource("CPRS", leftBindData.rs);
  12377. designer.SetDataSource("CPXS", leftBindData.xs);
  12378. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12379. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12380. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12381. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12382. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12383. }
  12384. else
  12385. {
  12386. hideRowsList.Add(Row + startIndex + HideRows);
  12387. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12388. }
  12389. HideRows += 2;
  12390. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12391. if (leftBindData != null)
  12392. {
  12393. designer.SetDataSource("GWDRCD", leftBindData.cb);
  12394. designer.SetDataSource("GWRS", leftBindData.rs);
  12395. designer.SetDataSource("GWXS", leftBindData.xs);
  12396. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12397. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12398. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12399. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12400. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12401. }
  12402. else
  12403. {
  12404. hideRowsList.Add(Row + startIndex + HideRows);
  12405. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12406. }
  12407. HideRows += 2;
  12408. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12409. if (leftBindData != null)
  12410. {
  12411. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  12412. designer.SetDataSource("LYJRS", leftBindData.rs);
  12413. designer.SetDataSource("LYJXS", leftBindData.xs);
  12414. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12415. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12416. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12417. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12418. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12419. }
  12420. else
  12421. {
  12422. hideRowsList.Add(Row + startIndex + HideRows);
  12423. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12424. }
  12425. #endregion
  12426. #region A段Right信息
  12427. var right = dto.rightInfo.Find(x => x.Type == "A");
  12428. if (right == null)
  12429. {
  12430. return Ok(jw);
  12431. }
  12432. HideRows += 4;
  12433. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12434. if (rightBindData != null)
  12435. {
  12436. //经济舱 + 双人间 TBR
  12437. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  12438. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  12439. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12440. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  12441. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12442. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12443. designer.SetDataSource("lblJJCTBRZLR", (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("经济舱 SGR"));
  12454. if (rightBindData != null)
  12455. {
  12456. //经济舱 + 单人间 SGR
  12457. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  12458. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  12459. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12460. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  12461. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12462. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12463. designer.SetDataSource("lblJJCSGRZLR", (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("公务舱 SGR"));
  12474. if (rightBindData != null)
  12475. {
  12476. //公务舱 + 单人间 SGR
  12477. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  12478. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  12479. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12480. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  12481. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12482. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12483. designer.SetDataSource("lblGWCSGRZLR", (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("公务舱 JS/ES"));
  12494. if (rightBindData != null)
  12495. {
  12496. //公务舱 + 小套房 JSES
  12497. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  12498. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  12499. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12500. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  12501. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12502. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12503. designer.SetDataSource("lblGWCJSESZLR", (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("公务舱 SUITE"));
  12514. if (rightBindData != null)
  12515. {
  12516. //公务舱 + 小套房 JSES
  12517. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  12518. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  12519. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12520. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  12521. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12522. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12523. designer.SetDataSource("lblGWCSUITEZLR", (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("lblJJCSUITEDRCB", rightBindData.cb);
  12538. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  12539. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12540. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  12541. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12542. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12543. designer.SetDataSource("lblJJCSUITEZLR", (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. HideRows += 2;
  12553. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12554. if (rightBindData != null)
  12555. {
  12556. //头等舱 + 小套房 JSES
  12557. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  12558. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  12559. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12560. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  12561. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12562. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12563. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12564. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12565. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12566. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12567. }
  12568. else
  12569. {
  12570. hideRowsList.Add(Row + startIndex + HideRows);
  12571. }
  12572. HideRows += 2;
  12573. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12574. if (rightBindData != null)
  12575. {
  12576. //头等舱 + 大套房
  12577. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  12578. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  12579. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12580. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  12581. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12582. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12583. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12584. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12585. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12586. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12587. }
  12588. else
  12589. {
  12590. hideRowsList.Add(Row + startIndex + HideRows);
  12591. }
  12592. #endregion
  12593. #region B段标题清空
  12594. designer.SetDataSource("CostBDRCB", "");
  12595. designer.SetDataSource("CostBRS", "");
  12596. designer.SetDataSource("CostBXS", "");
  12597. designer.SetDataSource("CostBZCB", "");
  12598. designer.SetDataSource("CostBDRBJ", "");
  12599. designer.SetDataSource("CostBZBJ", "");
  12600. designer.SetDataSource("CostBDRLR", "");
  12601. designer.SetDataSource("CostBZLR", "");
  12602. designer.SetDataSource("CostBDRCBOM", "");
  12603. designer.SetDataSource("CostBRSOM", "");
  12604. designer.SetDataSource("CostBZCBOM", "");
  12605. designer.SetDataSource("CostBDRBJOM", "");
  12606. designer.SetDataSource("CostBZBJOM", "");
  12607. designer.SetDataSource("CostBDRLROM", "");
  12608. designer.SetDataSource("CostBZLROM", "");
  12609. #endregion
  12610. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  12611. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  12612. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  12613. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  12614. designer.SetDataSource("DJName", "地接(CNY)");
  12615. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  12616. designer.SetDataSource("CPName", "地接-船票(CNY)");
  12617. designer.SetDataSource("GWName", "公务(CNY)");
  12618. designer.SetDataSource("YQHName", "邀请函(CNY)");
  12619. designer.SetDataSource("LYJName", "零用金(CNY)");
  12620. designer.SetDataSource("HSName", "核酸检测(CNY)");
  12621. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  12622. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  12623. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  12624. designer.SetDataSource("BXName", "保险(CNY)");
  12625. designer.SetDataSource("VisaName", "签证(CNY)");
  12626. #region B段基本数据
  12627. if (dto.costType == "B")
  12628. {
  12629. left = dto.leftInfo.Find(x => x.Type == "B");
  12630. if (left == null)
  12631. {
  12632. return Ok(jw);
  12633. }
  12634. #region B段left数据
  12635. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12636. if (leftBindData != null)
  12637. {
  12638. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  12639. designer.SetDataSource("BHSRS", leftBindData.rs);
  12640. designer.SetDataSource("BHSXS", leftBindData.xs);
  12641. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12642. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12643. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12644. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12645. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12646. }
  12647. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12648. if (leftBindData != null)
  12649. {
  12650. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  12651. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  12652. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  12653. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12654. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12655. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12656. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12657. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12658. }
  12659. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12660. if (leftBindData != null)
  12661. {
  12662. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  12663. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  12664. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  12665. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12666. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12667. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12668. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12669. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12670. }
  12671. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12672. if (leftBindData != null)
  12673. {
  12674. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  12675. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  12676. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  12677. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12678. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12679. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12680. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12681. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12682. }
  12683. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12684. if (leftBindData != null)
  12685. {
  12686. designer.SetDataSource("BHCPCB", leftBindData.cb);
  12687. designer.SetDataSource("BHCPRS", leftBindData.rs);
  12688. designer.SetDataSource("BHCPXS", leftBindData.xs);
  12689. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12690. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12691. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12692. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12693. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12694. }
  12695. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12696. if (leftBindData != null)
  12697. {
  12698. designer.SetDataSource("BCPCB", leftBindData.cb);
  12699. designer.SetDataSource("BCPRS", leftBindData.rs);
  12700. designer.SetDataSource("BCPXS", leftBindData.xs);
  12701. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12702. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12703. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12704. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12705. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12706. }
  12707. //TBR
  12708. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12709. if (leftBindData != null)
  12710. {
  12711. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  12712. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  12713. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  12714. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12715. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12716. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12717. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12718. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12719. }
  12720. //SGR
  12721. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12722. if (leftBindData != null)
  12723. {
  12724. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  12725. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  12726. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  12727. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12728. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12729. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12730. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12731. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12732. }
  12733. //JS/ES
  12734. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12735. if (leftBindData != null)
  12736. {
  12737. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  12738. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  12739. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  12740. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12741. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12742. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12743. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12744. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12745. }
  12746. //SUITE
  12747. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12748. if (leftBindData != null)
  12749. {
  12750. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  12751. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  12752. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  12753. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12754. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12755. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12756. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12757. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12758. }
  12759. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12760. if (leftBindData != null)
  12761. {
  12762. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  12763. designer.SetDataSource("BDJRS", leftBindData.rs);
  12764. designer.SetDataSource("BDJXS", leftBindData.xs);
  12765. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12766. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12767. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12768. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12769. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12770. }
  12771. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12772. if (leftBindData != null)
  12773. {
  12774. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  12775. designer.SetDataSource("BGWRS", leftBindData.rs);
  12776. designer.SetDataSource("BGWXS", leftBindData.xs);
  12777. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12778. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12779. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12780. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12781. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12782. }
  12783. #region 优化方案
  12784. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  12785. //excelBind.Add("零用金", new {
  12786. //cb="",
  12787. //rs="",
  12788. //xs ="",
  12789. //zcb = "",
  12790. //});
  12791. #endregion
  12792. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12793. if (leftBindData != null)
  12794. {
  12795. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  12796. designer.SetDataSource("BLYJRS", leftBindData.rs);
  12797. designer.SetDataSource("BLYJXS", leftBindData.xs);
  12798. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12799. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12800. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12801. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12802. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12803. }
  12804. #endregion
  12805. #region B段Right信息
  12806. right = dto.rightInfo.Find(x => x.Type == "B");
  12807. if (right == null)
  12808. {
  12809. return Ok(jw);
  12810. }
  12811. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12812. if (rightBindData != null)
  12813. {
  12814. //经济舱 + 双人间 TBR
  12815. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  12816. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  12817. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12818. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  12819. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12820. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12821. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12822. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12823. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12824. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12825. }
  12826. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12827. if (rightBindData != null)
  12828. {
  12829. //经济舱 + 单人间 SGR
  12830. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  12831. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  12832. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12833. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  12834. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12835. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12836. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12837. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12838. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12839. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12840. }
  12841. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12842. if (rightBindData != null)
  12843. {
  12844. //公务舱 + 单人间 SGR
  12845. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  12846. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  12847. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12848. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  12849. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12850. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12851. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12852. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12853. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12854. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12855. }
  12856. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12857. if (rightBindData != null)
  12858. {
  12859. //公务舱 + 小套房 JSES
  12860. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  12861. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  12862. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12863. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  12864. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12865. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12866. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12867. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12868. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12869. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12870. }
  12871. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12872. if (rightBindData != null)
  12873. {
  12874. //公务舱 + 小套房 JSES
  12875. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  12876. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  12877. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12878. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  12879. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12880. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12881. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12882. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12883. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12884. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12885. }
  12886. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12887. if (rightBindData != null)
  12888. {
  12889. //经济舱 + 大套房
  12890. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  12891. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  12892. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12893. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  12894. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12895. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12896. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12897. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12898. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12899. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12900. }
  12901. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12902. if (rightBindData != null)
  12903. {
  12904. //头等舱 + 小套房 JSES
  12905. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  12906. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  12907. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12908. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  12909. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12910. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12911. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12912. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12913. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12914. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12915. }
  12916. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12917. if (rightBindData != null)
  12918. {
  12919. //头等舱 + 大套房
  12920. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  12921. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  12922. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12923. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  12924. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12925. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12926. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12927. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12928. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12929. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12930. }
  12931. #endregion
  12932. #region 标题
  12933. designer.SetDataSource("CostBDRCB", "单人成本");
  12934. designer.SetDataSource("CostBRS", "人数");
  12935. designer.SetDataSource("CostBXS", "系数");
  12936. designer.SetDataSource("CostBZCB", "总成本");
  12937. designer.SetDataSource("CostBDRBJ", "单人报价");
  12938. designer.SetDataSource("CostBZBJ", "总报价");
  12939. designer.SetDataSource("CostBDRLR", "单人利润");
  12940. designer.SetDataSource("CostBZLR", "总利润");
  12941. designer.SetDataSource("CostBDRCBOM", "单人成本");
  12942. designer.SetDataSource("CostBRSOM", "人数");
  12943. designer.SetDataSource("CostBZCBOM", "总成本");
  12944. designer.SetDataSource("CostBDRBJOM", "单人报价");
  12945. designer.SetDataSource("CostBZBJOM", "总报价");
  12946. designer.SetDataSource("CostBDRLROM", "单人利润");
  12947. designer.SetDataSource("CostBZLROM", "总利润");
  12948. #endregion
  12949. }
  12950. #endregion
  12951. designer.SetDataSource("TzZCB2", TzZCB2);
  12952. designer.SetDataSource("TzZBJ2", TzZBJ2);
  12953. designer.SetDataSource("TzZLR2", TzZLR2);
  12954. string[] dataSourceKeys = new string[]
  12955. {
  12956. "VF",
  12957. "TGS",
  12958. "TGOF",
  12959. "TGM",
  12960. "TGA",
  12961. "TGTF",
  12962. "TGEF",
  12963. "CFM",
  12964. "CFOF",
  12965. "B",
  12966. "L",
  12967. "D",
  12968. "TBR",
  12969. "SGR",
  12970. "JSES",
  12971. "Suite",
  12972. "TV",
  12973. "1L",
  12974. "IF",
  12975. "EF",
  12976. "BRF",
  12977. "TE",
  12978. "TGT",
  12979. "DRVT",
  12980. "PC",
  12981. "TLF",
  12982. "ECT"
  12983. };
  12984. foreach (var item in dataSourceKeys)
  12985. {
  12986. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  12987. if (find != null)
  12988. {
  12989. designer.SetDataSource(item, find.text);
  12990. }
  12991. else
  12992. {
  12993. designer.SetDataSource(item, 0);
  12994. }
  12995. }
  12996. designer.SetDataSource(dt);
  12997. //根据数据源处理生成报表内容
  12998. designer.Process();
  12999. designer.Workbook.Worksheets[0].Name = "清单";
  13000. Worksheet sheet = designer.Workbook.Worksheets[0];
  13001. foreach (var Rowindex in hideRowsList)
  13002. {
  13003. ws.Cells.HideRows(Rowindex, 2);
  13004. }
  13005. byte[] bytes = null;
  13006. string strFileName = di.TeamName + "-团组-成本.xls";
  13007. using (MemoryStream stream = new MemoryStream())
  13008. {
  13009. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  13010. bytes = stream.ToArray();
  13011. }
  13012. return Ok(JsonView(true, "", new
  13013. {
  13014. Data = bytes,
  13015. strFileName,
  13016. }));
  13017. }
  13018. /// <summary>
  13019. /// 导出客户报表
  13020. /// </summary>
  13021. /// <returns></returns>
  13022. [HttpPost]
  13023. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  13024. {
  13025. var jw = JsonView(false);
  13026. if (dto.Diid == 0)
  13027. {
  13028. return Ok(JsonView(false, "请传递团组id"));
  13029. }
  13030. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13031. if (deleInfo.Code != 0)
  13032. {
  13033. return Ok(JsonView(false, "团组信息查询失败!"));
  13034. }
  13035. var di = deleInfo.Data as DelegationInfoWebView;
  13036. if (di == null)
  13037. {
  13038. return Ok(JsonView(false, "团组信息查询失败!"));
  13039. }
  13040. //文件名
  13041. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  13042. //获取模板
  13043. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  13044. //载入模板
  13045. Document doc = new Document(tmppath);
  13046. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  13047. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  13048. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  13049. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  13050. var AParameter = ParameterList.Find(x => x.CostType == "A");
  13051. var BParameter = ParameterList.Find(x => x.CostType == "B");
  13052. if (AParameter == null)
  13053. {
  13054. return Ok(JsonView(false, "系数不存在!"));
  13055. }
  13056. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  13057. , TzAirDesc, TzZCost;
  13058. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  13059. = TzAirDesc = TzZCost = string.Empty;
  13060. TzNumber = AParameter.CostTypenumber.ToString();
  13061. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  13062. CarGuides1 = dto.CarGuides1;
  13063. Meal = dto.Meal;
  13064. SubsidizedMeals = dto.SubsidizedMeals;
  13065. NightRepair = dto.NightRepair;
  13066. AttractionsTickets = dto.AttractionsTickets;
  13067. MiscellaneousFees = dto.MiscellaneousFees;
  13068. ATip = dto.ATip;
  13069. TzHotelDesc = "";
  13070. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  13071. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  13072. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  13073. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  13074. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  13075. TzAirDesc = "";
  13076. TzZCost = dto.TzZCost;
  13077. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  13078. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  13079. var index = 1;
  13080. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  13081. foreach (var item in TzHotelDescArr)
  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. var hotelText = string.Empty;
  13093. switch (item)
  13094. {
  13095. case "SGR":
  13096. hotelText = "单人间";
  13097. break;
  13098. case "JSES":
  13099. hotelText = "小套房";
  13100. break;
  13101. case "SUITE":
  13102. hotelText = "套房";
  13103. break;
  13104. case "TBR":
  13105. hotelText = "双人间";
  13106. break;
  13107. }
  13108. if (item != "TBR")
  13109. {
  13110. 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";
  13111. }
  13112. else
  13113. {
  13114. 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";
  13115. }
  13116. index++;
  13117. }
  13118. }
  13119. }
  13120. index = 1;
  13121. foreach (var item in TzAirDescArr)
  13122. {
  13123. if (AinfoArr != null)
  13124. {
  13125. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13126. if (Ainfo != null)
  13127. {
  13128. if (int.Parse(Ainfo.rs) <= 0)
  13129. {
  13130. continue;
  13131. }
  13132. 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";
  13133. index++;
  13134. }
  13135. }
  13136. }
  13137. if (dto.costType == "B")
  13138. {
  13139. if (BParameter == null)
  13140. {
  13141. return Ok(JsonView(false, "B段系数不存在!"));
  13142. }
  13143. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  13144. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  13145. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  13146. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  13147. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  13148. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  13149. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  13150. foreach (var item in TzHotelDescArr)
  13151. {
  13152. if (AinfoArr != null)
  13153. {
  13154. TzHotelDesc += "B段信息 \r\n";
  13155. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13156. if (Ainfo != null)
  13157. {
  13158. if (int.Parse(Ainfo.rs) <= 0)
  13159. {
  13160. continue;
  13161. }
  13162. var hotelText = string.Empty;
  13163. switch (item)
  13164. {
  13165. case "SGR":
  13166. hotelText = "单人间";
  13167. break;
  13168. case "JSES":
  13169. hotelText = "小套房";
  13170. break;
  13171. case "SUITE":
  13172. hotelText = "套房";
  13173. break;
  13174. case "TBR":
  13175. hotelText = "双人间";
  13176. break;
  13177. }
  13178. if (item != "TBR")
  13179. {
  13180. 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";
  13181. }
  13182. else
  13183. {
  13184. 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";
  13185. }
  13186. index++;
  13187. }
  13188. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  13189. }
  13190. }
  13191. index = 1;
  13192. foreach (var item in TzAirDescArr)
  13193. {
  13194. if (AinfoArr != null)
  13195. {
  13196. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13197. if (Ainfo != null)
  13198. {
  13199. if (int.Parse(Ainfo.rs) <= 0)
  13200. {
  13201. continue;
  13202. }
  13203. 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";
  13204. index++;
  13205. }
  13206. }
  13207. }
  13208. }
  13209. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  13210. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  13211. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  13212. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  13213. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  13214. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  13215. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  13216. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  13217. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  13218. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  13219. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  13220. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  13221. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  13222. DickeyValue.Add("Visa", Visa); // 签证单人报价
  13223. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  13224. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  13225. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  13226. DickeyValue.Add("TzZCost", TzZCost);
  13227. foreach (var key in DickeyValue.Keys)
  13228. {
  13229. if (doc.Range.Bookmarks[key] != null)
  13230. {
  13231. Bookmark mark = doc.Range.Bookmarks[key];
  13232. mark.Text = DickeyValue[key];
  13233. }
  13234. }
  13235. byte[] bytes = null;
  13236. string strFileName = di.TeamName + "-客户报价.doc";
  13237. using (MemoryStream stream = new MemoryStream())
  13238. {
  13239. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13240. bytes = stream.ToArray();
  13241. }
  13242. return Ok(JsonView(true, "", new
  13243. {
  13244. Data = bytes,
  13245. strFileName,
  13246. }));
  13247. }
  13248. /// <summary>
  13249. /// 团组成本 各模块(酒店,地接,机票)成本提示
  13250. /// </summary>
  13251. /// <param name="dto"></param>
  13252. /// <returns></returns>
  13253. [HttpPost]
  13254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13255. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  13256. {
  13257. try
  13258. {
  13259. #region 参数验证
  13260. if (dto.DiId < 0)
  13261. {
  13262. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  13263. }
  13264. List<int> cTableIds = new List<int>() {
  13265. 76 ,//酒店预订
  13266. 77 ,//行程
  13267. 79 ,//车/导游地接
  13268. 80 ,//签证
  13269. 81 ,//邀请/公务活
  13270. 82 ,//团组客户保险
  13271. 85 ,//机票预订
  13272. 98 ,//其他款项
  13273. 285 ,//收款退还
  13274. 751 ,//酒店早餐
  13275. 1015 // 超支费用
  13276. };
  13277. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  13278. {
  13279. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  13280. }
  13281. #endregion
  13282. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  13283. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  13284. if (_GroupCostParameters.Count <= 0)
  13285. {
  13286. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  13287. }
  13288. if (_GroupCostParameters[0].IsShare == 0)
  13289. {
  13290. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  13291. }
  13292. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13293. //处理date为空问题
  13294. if (_GroupCosts.Count > 0)
  13295. {
  13296. for (int i = 0; i < _GroupCosts.Count; i++)
  13297. {
  13298. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  13299. {
  13300. if (i > 0)
  13301. {
  13302. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  13303. }
  13304. }
  13305. }
  13306. }
  13307. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  13308. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  13309. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  13310. string currCode = "";
  13311. #region currCode 验证
  13312. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  13313. if (isInt)
  13314. {
  13315. var currData = currDatas.Find(it => it.Id == intCurrency);
  13316. if (currData != null)
  13317. {
  13318. currCode = currData.Name;
  13319. }
  13320. }
  13321. else
  13322. {
  13323. currCode = _GroupCostParameters[0].Currency.Trim();
  13324. }
  13325. #endregion
  13326. //op,酒店单段模式存储
  13327. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  13328. {
  13329. CurrencyCode = currCode,
  13330. Rate = _GroupCostParameters[0].Rate,
  13331. CostType = _GroupCostParameters[0].CostType,
  13332. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  13333. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  13334. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  13335. };
  13336. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  13337. if (_GroupCostParameters.Count == 2)
  13338. {
  13339. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  13340. }
  13341. foreach (var item in _GroupCostParameters)
  13342. {
  13343. decimal _rate = 1;
  13344. decimal _rate1 = item.Rate;
  13345. decimal _scale = 1;
  13346. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  13347. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  13348. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  13349. //if (userInfo != null)
  13350. //{
  13351. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  13352. // {
  13353. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  13354. // {
  13355. // _scale = 1.00M;
  13356. // }
  13357. // }
  13358. //}
  13359. #endregion
  13360. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  13361. {
  13362. CurrencyCode = currCode,
  13363. Rate = _rate1,
  13364. CostType = item.CostType,
  13365. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  13366. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  13367. CostTypeNumber = item.CostTypenumber
  13368. };
  13369. if (_GroupCostParameters.Count > 1)
  13370. {
  13371. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  13372. }
  13373. else
  13374. {
  13375. modulePromptInfo.CostTypeNumber = item.LYJRS;
  13376. }
  13377. if (dto.CTable == 79)//
  13378. {
  13379. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  13380. modulePromptInfo.TotalCost = item.DJCB;
  13381. }
  13382. List<string> costTypes = new List<string>() { "A", "B" };
  13383. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  13384. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  13385. if (_GroupCostsDuplicates.Count() == 1)
  13386. {
  13387. _GroupCostsTypeData = _GroupCosts;
  13388. }
  13389. else
  13390. {
  13391. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  13392. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  13393. }
  13394. /*
  13395. * 76 酒店预订
  13396. * 77 行程
  13397. * 79 车/导游地接
  13398. * 80 签证
  13399. * 81 邀请/公务活动
  13400. * 82 团组客户保险
  13401. * 85 机票预订
  13402. * 98 其他款项
  13403. * 285 收款退还
  13404. * 751 酒店早餐
  13405. * 1015 超支费用
  13406. */
  13407. switch (dto.CTable)
  13408. {
  13409. case 76: // 酒店预订
  13410. _ModuleSubPromptInfo.AddRange(
  13411. _GroupCostsTypeData.Select(it => new
  13412. {
  13413. it.DAY,
  13414. it.Date,
  13415. it.ACCON,
  13416. it.ITIN,
  13417. it.SGR,
  13418. it.TBR,
  13419. it.JS_ES,
  13420. it.Suite
  13421. })
  13422. );
  13423. break;
  13424. case 79: // 车/导游地接
  13425. _ModuleSubPromptInfo.AddRange(
  13426. _GroupCostsTypeData.Select(it => new
  13427. {
  13428. Date = it.Date, //日期
  13429. CarFee = it.CarCost * _rate * _scale, //车费用
  13430. CarType = it.CarType, //车型
  13431. DriverFee = it.CFS * _rate * _scale, //司机工资
  13432. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  13433. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  13434. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  13435. GuideFee = it.TGS * _rate * _scale, //导游费用
  13436. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  13437. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  13438. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  13439. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  13440. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  13441. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  13442. Breakfast = it.B * _rate * _scale, //早餐费
  13443. Lunch = it.L * _rate * _scale, //午餐费
  13444. Dinner = it.D * _rate * _scale, //晚餐费
  13445. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  13446. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  13447. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  13448. TicketFee = it.EF * _rate * _scale, //门票费
  13449. TicketRemark = it.EFR, //门票费描述
  13450. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  13451. TravelSupplies = it.TE * _rate * _scale, //出行物资
  13452. SpentCash = it.PC * _rate * _scale, //零用金
  13453. LeadersFee = it.TLF * _rate * _scale, //领队费
  13454. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  13455. })
  13456. );
  13457. break;
  13458. case 85: // 机票
  13459. List<dynamic> datas = new List<dynamic>();
  13460. datas.Add(
  13461. new
  13462. {
  13463. AirType = "经济舱",
  13464. AirNum = item.JJCRS,
  13465. AirDRCB = item.JJCCB,
  13466. AirZCB = (item.JJCRS * item.JJCCB)
  13467. }
  13468. );
  13469. datas.Add(
  13470. new
  13471. {
  13472. AirType = "公务舱",
  13473. AirNum = item.GWCRS,
  13474. AirDRCB = item.GWCCB,
  13475. AirZCB = (item.GWCRS * item.GWCCB)
  13476. }
  13477. );
  13478. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13479. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  13480. modulePromptInfo.Data = new
  13481. {
  13482. airFeeData = datas,
  13483. airInitData = initDatas
  13484. };
  13485. _ModulePromptInfos.Add(modulePromptInfo);
  13486. break;
  13487. default:
  13488. break;
  13489. }
  13490. }
  13491. if (dto.CTable != 85)
  13492. {
  13493. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  13494. _ModulePromptInfos.Add(_ModulePromptInfo);
  13495. }
  13496. _view.ModulePromptInfos = _ModulePromptInfos;
  13497. return Ok(JsonView(true, "操作成功!", _view));
  13498. }
  13499. catch (Exception ex)
  13500. {
  13501. return Ok(JsonView(false, ex.Message));
  13502. }
  13503. }
  13504. /// <summary>
  13505. /// 根据黑屏代码重新生成行程
  13506. /// </summary>
  13507. /// <param name="dto"></param>
  13508. /// <returns></returns>
  13509. [HttpPost]
  13510. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  13511. {
  13512. var jw = JsonView(false);
  13513. var Create = _GroupCostRepository.
  13514. CreateGroupCostByBlackCode(dto.Diid);
  13515. jw.Msg = Create.Msg;
  13516. if (Create.Code == 0)
  13517. {
  13518. jw.Code = 200;
  13519. jw.Data = new
  13520. {
  13521. groupCost = Create.Data,
  13522. blackCodeIsTrue = true
  13523. };
  13524. }
  13525. else
  13526. {
  13527. jw.Code = 400;
  13528. jw.Data = new
  13529. {
  13530. groupCost = Create.Data,
  13531. blackCodeIsTrue = false,
  13532. };
  13533. }
  13534. return Ok(jw);
  13535. }
  13536. /// <summary>
  13537. /// 成本获取OP历史车费用
  13538. /// </summary>
  13539. /// <param name="dto"></param>
  13540. /// <returns></returns>
  13541. [HttpPost]
  13542. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  13543. {
  13544. var jw = JsonView(false);
  13545. try
  13546. {
  13547. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  13548. //获取现有所有车的数据
  13549. if (!dto.Param.IsNullOrWhiteSpace())
  13550. {
  13551. string sql = $@"
  13552. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  13553. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  13554. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  13555. 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
  13556. AND gctggr.ServiceEndTime is not NULL
  13557. ORDER by gctggrc.id DESC
  13558. ";
  13559. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  13560. var numeberResult = await Task.Run(() =>
  13561. {
  13562. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  13563. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  13564. return numberArr;
  13565. });
  13566. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  13567. foreach (var item in numeberResult)
  13568. {
  13569. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  13570. {
  13571. Country = "数据异常!",
  13572. City = string.Empty,
  13573. };
  13574. item.Area = find.Country + " " + find.City;
  13575. }
  13576. dbResult.AddRange(numeberResult);
  13577. if (dto.Param.Contains("、"))
  13578. {
  13579. var sp = dto.Param.Split("、");
  13580. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13581. .Where(x =>
  13582. {
  13583. return System.Array.Exists(sp, e =>
  13584. {
  13585. bool where = false;
  13586. if (x.Area != null)
  13587. {
  13588. where = x.Area.Contains(e);
  13589. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13590. {
  13591. return false;
  13592. }
  13593. }
  13594. if (x.PriceName != null && !where)
  13595. {
  13596. where = x.PriceName.Contains(e);
  13597. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13598. {
  13599. return false;
  13600. }
  13601. }
  13602. return where;
  13603. });
  13604. }).ToList();
  13605. }
  13606. else
  13607. {
  13608. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13609. .Where(x =>
  13610. {
  13611. bool where = false;
  13612. if (x.Area != null)
  13613. {
  13614. where = x.Area.Contains(dto.Param);
  13615. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13616. {
  13617. return false;
  13618. }
  13619. }
  13620. if (x.PriceName != null && !where)
  13621. {
  13622. where = x.PriceName.Contains(dto.Param);
  13623. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13624. {
  13625. return false;
  13626. }
  13627. }
  13628. return where;
  13629. }
  13630. )
  13631. .ToList();
  13632. }
  13633. }
  13634. var view = dbResult.Select(x =>
  13635. {
  13636. decimal dp = 0.00M;
  13637. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  13638. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  13639. if (string.IsNullOrWhiteSpace(x.DatePrice))
  13640. {
  13641. if (startB && endB)
  13642. {
  13643. var timesp = endD.Subtract(startD);
  13644. if ((timesp.Days + 1) != 0)
  13645. {
  13646. dp = x.Price / (timesp.Days + 1);
  13647. }
  13648. }
  13649. }
  13650. else
  13651. {
  13652. dp = x.Price;
  13653. }
  13654. return new
  13655. {
  13656. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  13657. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  13658. x.Area,
  13659. x.id,
  13660. price = x.Price.ToString("F2"),
  13661. x.PriceName,
  13662. x.PriceContent,
  13663. x.TeamName,
  13664. x.DatePrice,
  13665. dayPrice = dp.ToString("F2"),
  13666. };
  13667. }).OrderByDescending(x => x.id).ToList();
  13668. jw = JsonView(true, "获取成功!", view);
  13669. }
  13670. catch (Exception e)
  13671. {
  13672. jw = JsonView(false, e.Message);
  13673. }
  13674. return Ok(jw);
  13675. }
  13676. #endregion
  13677. #region 酒店预订 新 雷怡 2023-12-28 17:45
  13678. /// <summary>
  13679. /// 酒店预订
  13680. /// 酒店费用列表 根据团组Id查询
  13681. /// </summary>
  13682. /// <param name="_dto"></param>
  13683. /// <returns></returns>
  13684. [HttpPost]
  13685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13686. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  13687. {
  13688. #region 参数验证
  13689. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13690. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13691. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13692. #region 团组操作权限验证 76 酒店预定模块
  13693. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13694. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13695. #endregion
  13696. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13697. #region 页面操作权限验证
  13698. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13699. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13700. #endregion
  13701. #endregion
  13702. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  13703. }
  13704. /// <summary>
  13705. /// 酒店预订
  13706. /// 基础数据
  13707. /// </summary>
  13708. /// <param name="_dto"></param>
  13709. /// <returns></returns>
  13710. [HttpPost]
  13711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13712. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  13713. {
  13714. #region 参数验证
  13715. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13716. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13717. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13718. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13719. #region 页面操作权限验证
  13720. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13721. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13722. #endregion
  13723. #region 团组操作权限验证 76 酒店预定模块
  13724. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13725. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13726. #endregion
  13727. #endregion
  13728. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  13729. }
  13730. /// <summary>
  13731. /// 酒店预订
  13732. /// 创建 入住卷号码
  13733. /// </summary>
  13734. /// <param name="_dto"></param>
  13735. /// <returns></returns>
  13736. [HttpPost]
  13737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13738. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  13739. {
  13740. #region 参数验证
  13741. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13742. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13743. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13744. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13745. #region 页面操作权限验证
  13746. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13747. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13748. #endregion
  13749. #region 团组操作权限验证 76 酒店预定模块
  13750. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13751. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13752. #endregion
  13753. #endregion
  13754. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  13755. if (data.Code != 0)
  13756. {
  13757. return Ok(JsonView(false, data.Msg));
  13758. }
  13759. return Ok(JsonView(true, data.Msg, data.Data));
  13760. }
  13761. /// <summary>
  13762. /// 酒店预订
  13763. /// 详情
  13764. /// </summary>
  13765. /// <param name="_dto"></param>
  13766. /// <returns></returns>
  13767. [HttpPost]
  13768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13769. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  13770. {
  13771. #region 参数验证
  13772. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  13773. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13774. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  13775. #region 团组操作权限验证 76 酒店预定模块
  13776. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13777. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13778. #endregion
  13779. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13780. #region 页面操作权限验证
  13781. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13782. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13783. #endregion
  13784. #endregion
  13785. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  13786. }
  13787. /// <summary>
  13788. /// 酒店预订
  13789. /// Add Or Edit
  13790. /// </summary>
  13791. /// <param name="_dto"></param>
  13792. /// <returns></returns>
  13793. [HttpPost]
  13794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13795. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  13796. {
  13797. #region 参数验证
  13798. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13799. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13800. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13801. #region 团组操作权限验证 76 酒店预定模块
  13802. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13803. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13804. #endregion
  13805. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13806. #region 页面操作权限验证
  13807. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13808. if (_dto.Id == 0) // Add
  13809. {
  13810. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13811. }
  13812. else if (_dto.Id > 1) // Edit
  13813. {
  13814. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  13815. }
  13816. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  13817. #endregion
  13818. #endregion
  13819. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  13820. if (_view.Code != 200)
  13821. {
  13822. return Ok(_view);
  13823. }
  13824. #region 成本无酒店价格数据进入超支
  13825. _sqlSugar.BeginTran();
  13826. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  13827. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  13828. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  13829. for (int i = 0; i < groupCost.Count; i++)
  13830. {
  13831. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  13832. {
  13833. groupCost[i].Date = groupCost[i - 1].Date;
  13834. }
  13835. }
  13836. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  13837. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  13838. List<Fin_GroupExtraCostDto_OP>();
  13839. if (start_Bool && end_Bool)
  13840. {
  13841. while (start_Time < end_Time)
  13842. {
  13843. foreach (var item in groupCost_Grp)
  13844. {
  13845. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  13846. {
  13847. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  13848. {
  13849. extraCostList.Add(new
  13850. Fin_GroupExtraCostDto_OP
  13851. {
  13852. Area = _dto.AreaId,
  13853. coefficient = 1.5M,
  13854. createUser = _dto.UserId,
  13855. currency = _dto.CardPriceCurrency,
  13856. diId = _dto.DiId,
  13857. ManagerConfirm = 0,
  13858. SupervisorConfirm = 0,
  13859. SYsupervisorConfirm = 0,
  13860. editType = 1,
  13861. PortType = 1,
  13862. price = _dto.CardPrice,
  13863. PriceCount = 1,
  13864. priceType = 1027,
  13865. priceDetailType = 1044,
  13866. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  13867. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  13868. });
  13869. }
  13870. }
  13871. }
  13872. start_Time = start_Time.AddDays(1);
  13873. }
  13874. }
  13875. if (extraCostList.Any())
  13876. {
  13877. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  13878. }
  13879. _sqlSugar.CommitTran();
  13880. #endregion
  13881. #region 应用推送
  13882. try
  13883. {
  13884. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  13885. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  13886. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  13887. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  13888. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  13889. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  13890. var diId = _dto.DiId;
  13891. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13892. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13893. #region 操作记录
  13894. var opInfo = new Crm_TableOperationRecord()
  13895. {
  13896. TableName = "Grp_HotelReservations",
  13897. PortType = _dto.PortType,
  13898. DataId = hotelId,
  13899. CreateUserId = _dto.UserId
  13900. };
  13901. //var opStatus = OperationEnum.NoOperation;
  13902. if (_dto.Id < 1) //添加操作
  13903. {
  13904. opInfo.OperationItem = OperationEnum.Add;
  13905. }
  13906. else if (_dto.Id > 0)
  13907. {
  13908. opInfo.OperationItem = OperationEnum.Edit;
  13909. }
  13910. string opRemark = string.Empty;
  13911. if (ccpInfo != null)
  13912. {
  13913. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  13914. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  13915. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  13916. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  13917. }
  13918. opInfo.Remark = opRemark;
  13919. await _tableorRep.AddAsync(opInfo);
  13920. #endregion
  13921. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  13922. //2024-10-21 新增LZ UID
  13923. var userIds = new List<int>() { 21 };
  13924. string title = $"费用审核";
  13925. string content = "";
  13926. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13927. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13928. try
  13929. {
  13930. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  13931. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  13932. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  13933. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  13934. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  13935. }
  13936. catch (Exception ex)
  13937. {
  13938. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  13939. }
  13940. }
  13941. catch (Exception ex)
  13942. {
  13943. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  13944. }
  13945. try
  13946. {
  13947. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  13948. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  13949. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  13950. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  13951. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  13952. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  13953. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13954. //自动审核
  13955. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  13956. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  13957. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  13958. //2024-10-21 新增LZ UID
  13959. var userIds = new List<int>() { 21 };
  13960. string title = $"系统通知";
  13961. var diId = _dto.DiId;
  13962. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13963. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13964. string content = "";
  13965. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13966. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13967. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13968. }
  13969. catch (Exception ex)
  13970. {
  13971. }
  13972. #endregion
  13973. return Ok(_view);
  13974. }
  13975. /// <summary>
  13976. /// 酒店自动审核测试
  13977. /// Add Or Edit
  13978. /// </summary>
  13979. /// <param name="diid"></param>
  13980. /// <param name="dataId"></param>
  13981. /// <returns></returns>
  13982. [HttpPost]
  13983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13984. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  13985. {
  13986. #region 应用推送
  13987. try
  13988. {
  13989. //自动审核
  13990. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  13991. }
  13992. catch (Exception ex)
  13993. {
  13994. return Ok(JsonView(false, "操作失败"));
  13995. }
  13996. #endregion
  13997. return Ok(JsonView(false, "操作成功"));
  13998. }
  13999. /// <summary>
  14000. /// 酒店预订
  14001. /// Del
  14002. /// </summary>
  14003. /// <param name="_dto"></param>
  14004. /// <returns></returns>
  14005. [HttpPost]
  14006. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14007. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  14008. {
  14009. #region 参数验证
  14010. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14011. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14012. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14013. #region 团组操作权限验证 76 酒店预定模块
  14014. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14015. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14016. #endregion
  14017. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14018. #region 页面操作权限验证
  14019. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14020. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14021. #endregion
  14022. #endregion
  14023. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  14024. #region 操作记录
  14025. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  14026. {
  14027. TableName = "Grp_HotelReservations",
  14028. PortType = _dto.PortType,
  14029. OperationItem = OperationEnum.Del,
  14030. DataId = _dto.Id,
  14031. CreateUserId = _dto.UserId
  14032. });
  14033. #endregion
  14034. return Ok(data);
  14035. }
  14036. /// <summary>
  14037. /// 酒店预订
  14038. /// 生成VOUCHER
  14039. /// 2024.05.06 之前版本
  14040. /// </summary>
  14041. /// <param name="_dto"></param>
  14042. /// <returns></returns>
  14043. [HttpPost]
  14044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14045. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  14046. {
  14047. try
  14048. {
  14049. #region 参数验证
  14050. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14051. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14052. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14053. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  14054. #region 团组操作权限验证 76 酒店预定模块
  14055. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14056. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14057. #endregion
  14058. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14059. #region 页面操作权限验证
  14060. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14061. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14062. #endregion
  14063. #endregion
  14064. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  14065. //判断数据是否完整
  14066. if (hr != null)
  14067. {
  14068. if (!string.IsNullOrEmpty(hr.DetermineNo))
  14069. {
  14070. string strFileName = "HotelStatement/";
  14071. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14072. if (dele != null)
  14073. strFileName += dele.TourCode;
  14074. //载入模板
  14075. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  14076. Document doc = new Document(sss);
  14077. DocumentBuilder builder = new DocumentBuilder(doc);
  14078. #region 替换Word模板书签内容
  14079. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  14080. //入住卷预定号码
  14081. if (doc.Range.Bookmarks["VNO"] != null)
  14082. {
  14083. Bookmark mark = doc.Range.Bookmarks["VNO"];
  14084. mark.Text = hr.CheckNumber;
  14085. }
  14086. //酒店时间
  14087. if (doc.Range.Bookmarks["Date"] != null)
  14088. {
  14089. Bookmark mark = doc.Range.Bookmarks["Date"];
  14090. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14091. }
  14092. //团号
  14093. if (doc.Range.Bookmarks["TNo"] != null)
  14094. {
  14095. Bookmark mark = doc.Range.Bookmarks["TNo"];
  14096. mark.Text = dele.TourCode;
  14097. }
  14098. //预定号码
  14099. if (doc.Range.Bookmarks["BookingId"] != null)
  14100. {
  14101. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  14102. mark.Text = hr.ReservationsNo;
  14103. }
  14104. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  14105. {
  14106. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  14107. mark.Text = hr.DetermineNo;
  14108. }
  14109. //酒店城市
  14110. if (doc.Range.Bookmarks["City"] != null)
  14111. {
  14112. Bookmark mark = doc.Range.Bookmarks["City"];
  14113. mark.Text = hr.City;
  14114. }
  14115. //酒店名称
  14116. if (doc.Range.Bookmarks["HName"] != null)
  14117. {
  14118. Bookmark mark = doc.Range.Bookmarks["HName"];
  14119. mark.Text = hr.HotelName;
  14120. }
  14121. //酒店地址
  14122. if (doc.Range.Bookmarks["Address"] != null)
  14123. {
  14124. Bookmark mark = doc.Range.Bookmarks["Address"];
  14125. mark.Text = hr.HotelAddress;
  14126. }
  14127. //酒店电话
  14128. if (doc.Range.Bookmarks["Tel"] != null)
  14129. {
  14130. Bookmark mark = doc.Range.Bookmarks["Tel"];
  14131. mark.Text = hr.HotelTel;
  14132. }
  14133. //酒店传真
  14134. if (doc.Range.Bookmarks["Fax"] != null)
  14135. {
  14136. Bookmark mark = doc.Range.Bookmarks["Fax"];
  14137. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  14138. {
  14139. mark.Text = hr.HotelFax;
  14140. }
  14141. }
  14142. //入住时间
  14143. if (doc.Range.Bookmarks["CIn"] != null)
  14144. {
  14145. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14146. Bookmark mark = doc.Range.Bookmarks["CIn"];
  14147. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  14148. }
  14149. //退房时间
  14150. if (doc.Range.Bookmarks["COut"] != null)
  14151. {
  14152. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14153. Bookmark mark = doc.Range.Bookmarks["COut"];
  14154. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14155. }
  14156. //客户名称
  14157. if (doc.Range.Bookmarks["GName"] != null)
  14158. {
  14159. string guestName = "";
  14160. string[] clients = new string[] { };
  14161. if (hr.GuestName.Contains(","))
  14162. {
  14163. clients = hr.GuestName.Split(",");
  14164. }
  14165. else
  14166. {
  14167. clients = new string[] { hr.GuestName };
  14168. }
  14169. List<int> clientIds_int = new List<int>();
  14170. if (clients.Length > 0)
  14171. {
  14172. foreach (var item in clients)
  14173. {
  14174. if (item.IsNumeric())
  14175. {
  14176. clientIds_int.Add(int.Parse(item));
  14177. }
  14178. }
  14179. }
  14180. if (clientIds_int.Count > 0)
  14181. {
  14182. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  14183. foreach (var client in _clientDatas)
  14184. {
  14185. //男
  14186. if (client.Sex == 0) guestName += $"Mr.";
  14187. //女
  14188. else if (client.Sex == 1) guestName += $"Ms.";
  14189. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  14190. {
  14191. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  14192. }
  14193. //guestName += $"{client.Pinyin},";
  14194. }
  14195. if (guestName.Length > 0)
  14196. {
  14197. guestName = guestName.Substring(0, guestName.Length - 1);
  14198. }
  14199. }
  14200. else
  14201. {
  14202. guestName = hr.GuestName;
  14203. }
  14204. Bookmark mark = doc.Range.Bookmarks["GName"];
  14205. mark.Text = guestName;
  14206. }
  14207. //房间介绍
  14208. if (doc.Range.Bookmarks["ROOM"] != null)
  14209. {
  14210. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  14211. mark.Text = hr.RoomExplanation;
  14212. }
  14213. //报价描述
  14214. if (doc.Range.Bookmarks["NOTE"] != null)
  14215. {
  14216. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  14217. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  14218. if (ss != null)
  14219. mark.Text = ss.Name;
  14220. }
  14221. //入住时间
  14222. if (doc.Range.Bookmarks["CheckIn"] != null)
  14223. {
  14224. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14225. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  14226. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14227. }
  14228. //退房时间
  14229. if (doc.Range.Bookmarks["CheckOut"] != null)
  14230. {
  14231. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14232. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  14233. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14234. }
  14235. //日期
  14236. if (doc.Range.Bookmarks["DT"] != null)
  14237. {
  14238. Bookmark mark = doc.Range.Bookmarks["DT"];
  14239. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14240. }
  14241. //名称
  14242. if (doc.Range.Bookmarks["VName"] != null)
  14243. {
  14244. Bookmark mark = doc.Range.Bookmarks["VName"];
  14245. mark.Text = hr.HotelName;
  14246. }
  14247. //号码
  14248. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  14249. {
  14250. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  14251. mark.Text = hr.CheckNumber;
  14252. }
  14253. #endregion
  14254. strFileName += "VOUCHER.doc";
  14255. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14256. doc.Save(fileDir);
  14257. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14258. return Ok(JsonView(true, "操作成功!", Url));
  14259. }
  14260. else
  14261. {
  14262. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  14263. }
  14264. }
  14265. else
  14266. {
  14267. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  14268. }
  14269. }
  14270. catch (Exception ex)
  14271. {
  14272. return Ok(JsonView(false, ex.Message));
  14273. }
  14274. }
  14275. /// <summary>
  14276. /// 酒店预订
  14277. /// 生成VOUCHER
  14278. /// 2024.05.06 之后版本
  14279. /// </summary>
  14280. /// <param name="_dto"></param>
  14281. /// <returns></returns>
  14282. [HttpPost]
  14283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14284. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  14285. {
  14286. #region 参数验证
  14287. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14288. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14289. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14290. #region 团组操作权限验证 76 酒店预定模块
  14291. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14292. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14293. #endregion
  14294. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14295. #region 页面操作权限验证
  14296. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14297. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14298. #endregion
  14299. #endregion
  14300. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  14301. //判断数据是否完整
  14302. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14303. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14304. string strFileName = "HotelStatement/";
  14305. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14306. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  14307. #region 数据处理
  14308. List<int> guestIds = new List<int>();
  14309. //int index = 0;
  14310. foreach (var item in hrDtas)
  14311. {
  14312. if (item.GuestName.Contains(","))
  14313. {
  14314. string[] guestIdArr = item.GuestName.Split(',');
  14315. foreach (var guestIdStr in guestIdArr)
  14316. {
  14317. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  14318. if (guestBool)
  14319. {
  14320. guestIds.Add(guestId);
  14321. }
  14322. }
  14323. }
  14324. else guestNames += item.GuestName;
  14325. var voucherInfo = new HotelVoucherInfoView()
  14326. {
  14327. HotelName = item.HotelName,
  14328. CheckInDate = item.CheckInDate,
  14329. CheckOutDate = item.CheckOutDate,
  14330. ConfirmationNumber = item.DetermineNo.Trim(),
  14331. RoomType = item.RoomExplanation
  14332. };
  14333. vouchers.Add(voucherInfo);
  14334. }
  14335. if (guestIds.Count > 0)
  14336. {
  14337. guestIds = guestIds.Distinct().ToList();
  14338. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  14339. if (guestDatas.Count > 0)
  14340. {
  14341. guestNames = "";
  14342. foreach (var guest in guestDatas)
  14343. {
  14344. string guestName = "";
  14345. if (guest.Sex == 0) guestName += @"MR.";
  14346. else if (guest.Sex == 1) guestName += @"MS.";
  14347. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14348. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14349. guestNames += @$"{guestName.Trim()}、";
  14350. }
  14351. if (guestNames.Length > 0)
  14352. {
  14353. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14354. }
  14355. }
  14356. }
  14357. #endregion
  14358. //载入模板
  14359. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  14360. Document doc = new Document(sss);
  14361. DocumentBuilder builder = new DocumentBuilder(doc);
  14362. if (doc.Range.Bookmarks["GuestName"] != null)
  14363. {
  14364. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  14365. mark.Text = guestNames;
  14366. }
  14367. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14368. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  14369. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  14370. for (int i = 1; i <= vouchers.Count; i++)
  14371. {
  14372. HotelVoucherInfoView hviv = vouchers[i - 1];
  14373. builder.MoveToCell(0, i, 0, 0);
  14374. builder.Write(hviv.HotelName);
  14375. builder.MoveToCell(0, i, 1, 0);
  14376. builder.Write(hviv.CheckInDate);
  14377. builder.MoveToCell(0, i, 2, 0);
  14378. builder.Write(hviv.CheckOutDate);
  14379. builder.MoveToCell(0, i, 3, 0);
  14380. builder.Write(hviv.RoomType);
  14381. builder.MoveToCell(0, i, 4, 0);
  14382. builder.Write(hviv.ConfirmationNumber);
  14383. }
  14384. //删除多余行
  14385. int currRowIndex = vouchers.Count + 1;
  14386. int delRows = 21 - currRowIndex;
  14387. if (delRows > 0)
  14388. {
  14389. for (int i = 0; i < delRows; i++)
  14390. {
  14391. table.Rows.RemoveAt(currRowIndex);
  14392. //cultivateRowIndex++;
  14393. }
  14394. }
  14395. strFileName += "VOUCHER.docx";
  14396. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14397. doc.Save(fileDir);
  14398. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14399. return Ok(JsonView(true, "操作成功!", Url));
  14400. }
  14401. /// <summary>
  14402. /// 酒店预订
  14403. /// 生成VOUCHER 批量生成
  14404. /// New
  14405. /// </summary>
  14406. /// <param name="_dto"></param>
  14407. /// <returns></returns>
  14408. [HttpPost]
  14409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14410. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  14411. {
  14412. #region 参数验证
  14413. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14414. if (_dto.PageId < 1) _dto.PageId = 28;
  14415. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14416. #region 团组操作权限验证 76 酒店预定模块
  14417. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14418. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14419. #endregion
  14420. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14421. #region 页面操作权限验证
  14422. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14423. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14424. #endregion
  14425. #endregion
  14426. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  14427. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  14428. .OrderBy(x => x.CheckInDate)
  14429. .ToListAsync();
  14430. //判断数据是否完整
  14431. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14432. string strFileName = "HotelStatement/";
  14433. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14434. if (dele != null)
  14435. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  14436. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  14437. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  14438. .Where(it => it.IsDel == 0)
  14439. .ToListAsync();
  14440. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  14441. for (int i = 0; i < hrDtas.Count; i++)
  14442. {
  14443. string guestNames = string.Empty;
  14444. List<int> guestIds = new List<int>();
  14445. var item = hrDtas[i];
  14446. //处理客户姓名
  14447. if (item.GuestName.Contains(","))
  14448. {
  14449. string[] guestIdArr = item.GuestName.Split(',');
  14450. foreach (var guestIdStr in guestIdArr)
  14451. if (int.TryParse(guestIdStr, out int guestId))
  14452. guestIds.Add(guestId);
  14453. }
  14454. else
  14455. {
  14456. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  14457. if (guestIdBool)
  14458. {
  14459. guestIds.Add(guestId);
  14460. }
  14461. //NaN
  14462. if (item.GuestName.Contains("NaN"))
  14463. {
  14464. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  14465. }
  14466. }
  14467. if (guestIds.Count > 0)
  14468. {
  14469. guestIds = guestIds.Distinct().ToList();
  14470. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  14471. if (guestDatas1.Count > 0)
  14472. {
  14473. guestNames = "";
  14474. foreach (var guest in guestDatas1)
  14475. {
  14476. string guestName = "";
  14477. if (guest.Sex == 0) guestName += @"MR.";
  14478. else if (guest.Sex == 1) guestName += @"MS.";
  14479. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14480. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14481. guestNames += @$"{guestName.Trim()}、";
  14482. }
  14483. if (guestNames.Length > 0)
  14484. {
  14485. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14486. }
  14487. }
  14488. }
  14489. //if (!string.IsNullOrEmpty(guestNames))
  14490. //{
  14491. hrDtas[i].GuestName = guestNames;
  14492. //}
  14493. }
  14494. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  14495. Document doc = new Document();
  14496. DocumentBuilder builder = new DocumentBuilder(doc);
  14497. try
  14498. {
  14499. builder.MoveToDocumentStart();
  14500. foreach (var item in hrDtas)
  14501. {
  14502. //标题
  14503. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14504. builder.ParagraphFormat.LineSpacing = 1;
  14505. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14506. builder.ParagraphFormat.Style.Font.Size = 9;
  14507. builder.ParagraphFormat.Style.Font.Bold = true;
  14508. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14509. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  14510. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14511. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14512. builder.ParagraphFormat.LineSpacing = 1;
  14513. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14514. builder.ParagraphFormat.Style.Font.Size = 9;
  14515. builder.ParagraphFormat.Style.Font.Bold = true;
  14516. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  14517. builder.StartTable();
  14518. // 设置边框颜色
  14519. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  14520. //设置边框样式
  14521. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  14522. //表格
  14523. #region 第一行
  14524. builder.InsertCell();
  14525. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14526. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14527. //builder.CellFormat.AllowAutoFit = false;
  14528. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14529. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14530. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14531. builder.CellFormat.WrapText = true; //自动换行
  14532. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14533. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  14534. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14535. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14536. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14537. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14538. builder.Write("TOUR NO:");
  14539. builder.InsertCell();
  14540. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14541. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14542. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14543. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14544. builder.ParagraphFormat.Style.Font.Bold = false;
  14545. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14546. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14547. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14548. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14549. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14550. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14551. builder.Write($"{dele?.TourCode ?? "-"}");
  14552. builder.InsertCell();
  14553. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14554. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14555. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14556. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14557. builder.ParagraphFormat.Style.Font.Bold = false;
  14558. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14559. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14560. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14561. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14562. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14563. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14564. builder.Write($"CITY:");
  14565. builder.InsertCell();
  14566. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14567. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14568. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14569. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14570. builder.ParagraphFormat.Style.Font.Bold = false;
  14571. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14572. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14573. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14574. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14575. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14576. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14577. builder.Write($"{item.City}");
  14578. builder.EndRow();
  14579. #endregion
  14580. #region 第二行
  14581. builder.InsertCell();
  14582. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14583. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14584. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14585. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14586. builder.ParagraphFormat.Style.Font.Bold = false;
  14587. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14588. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14589. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14590. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14591. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14592. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14593. builder.Write("CONFIRMATION NO:");
  14594. builder.InsertCell();
  14595. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14596. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14597. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14598. builder.ParagraphFormat.Style.Font.Bold = false;
  14599. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14600. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14601. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14602. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14603. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14604. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14605. builder.CellFormat.VerticalMerge = CellMerge.None;
  14606. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14607. builder.Write($"{item.DetermineNo}");
  14608. builder.InsertCell();
  14609. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14610. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14611. builder.InsertCell();
  14612. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14613. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14614. builder.EndRow();
  14615. #endregion
  14616. #region 第三行
  14617. builder.InsertCell();
  14618. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14619. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14620. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14621. builder.ParagraphFormat.Style.Font.Bold = false;
  14622. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14623. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14624. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14625. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14626. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14627. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14628. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14629. builder.Write($"HOTEL NAME:");
  14630. builder.InsertCell();
  14631. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14632. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14633. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14634. builder.ParagraphFormat.Style.Font.Bold = false;
  14635. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14636. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14637. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14638. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14639. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14640. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14641. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14642. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14643. builder.Write($"{item.HotelName}");
  14644. builder.InsertCell();
  14645. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14646. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14647. builder.InsertCell();
  14648. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14649. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14650. builder.EndRow();
  14651. #endregion
  14652. #region 第四行
  14653. builder.InsertCell();
  14654. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14655. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14656. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14657. builder.ParagraphFormat.Style.Font.Bold = false;
  14658. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14659. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14660. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14661. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14662. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14663. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14664. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14665. builder.Write($"HOTEL ADDRESS:");
  14666. builder.InsertCell();
  14667. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14668. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14669. builder.ParagraphFormat.Style.Font.Size = 8;
  14670. builder.ParagraphFormat.Style.Font.Bold = false;
  14671. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14672. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14673. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14674. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14675. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14676. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14677. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14678. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14679. builder.Write($"{item.HotelAddress}");
  14680. builder.InsertCell();
  14681. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14682. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14683. builder.InsertCell();
  14684. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14685. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14686. builder.EndRow();
  14687. #endregion
  14688. #region 第五行
  14689. builder.InsertCell();
  14690. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14691. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14692. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14693. builder.ParagraphFormat.Style.Font.Bold = false;
  14694. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14695. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14696. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14697. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14698. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14699. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14700. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14701. builder.Write("TEL:");
  14702. builder.InsertCell();
  14703. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14704. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14705. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14706. builder.ParagraphFormat.Style.Font.Bold = false;
  14707. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14708. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14709. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14710. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14711. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14712. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14713. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14714. builder.Write($"{item.HotelTel}");
  14715. builder.InsertCell();
  14716. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14717. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14718. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14719. builder.ParagraphFormat.Style.Font.Bold = false;
  14720. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14721. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14722. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14723. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14724. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14725. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14726. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14727. builder.Write($"FAX:");
  14728. builder.InsertCell();
  14729. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14730. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14731. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14732. builder.ParagraphFormat.Style.Font.Bold = false;
  14733. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14734. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14735. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14736. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14737. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14738. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14739. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14740. builder.Write($"{item.HotelFax}");
  14741. builder.EndRow();
  14742. #endregion
  14743. #region 第六行
  14744. builder.InsertCell();
  14745. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14746. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14747. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14748. builder.ParagraphFormat.Style.Font.Bold = false;
  14749. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14750. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14751. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14752. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14753. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14754. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14755. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14756. builder.Write("CHECK IN:");
  14757. builder.InsertCell();
  14758. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14759. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14760. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14761. builder.ParagraphFormat.Style.Font.Bold = false;
  14762. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14763. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14764. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14765. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14766. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14767. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14768. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14769. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  14770. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14771. builder.Write($"{checkInStr}");
  14772. builder.InsertCell();
  14773. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14774. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14775. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14776. builder.ParagraphFormat.Style.Font.Bold = false;
  14777. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14778. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14779. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14780. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14781. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14782. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14783. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14784. builder.Write($"CHECK OUT:");
  14785. builder.InsertCell();
  14786. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14787. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14788. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14789. builder.ParagraphFormat.Style.Font.Bold = false;
  14790. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14791. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14792. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14793. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14794. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14795. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14796. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14797. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  14798. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  14799. builder.Write($"{checkOutStr}");
  14800. builder.EndRow();
  14801. #endregion
  14802. #region 第七行
  14803. builder.InsertCell();
  14804. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14805. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14806. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14807. builder.ParagraphFormat.Style.Font.Bold = false;
  14808. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14809. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14810. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14811. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14812. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14813. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14814. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14815. builder.Write($"GUEST NAME:");
  14816. builder.InsertCell();
  14817. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14818. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14819. builder.ParagraphFormat.Style.Font.Size = 8;
  14820. builder.ParagraphFormat.Style.Font.Bold = false;
  14821. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14822. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14823. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14824. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14825. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14826. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14827. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14828. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14829. builder.Write($"{item.GuestName}");
  14830. builder.InsertCell();
  14831. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14832. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14833. builder.InsertCell();
  14834. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14835. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14836. builder.EndRow();
  14837. #endregion
  14838. #region 第八行
  14839. builder.InsertCell();
  14840. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14841. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14842. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14843. builder.ParagraphFormat.Style.Font.Bold = false;
  14844. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14845. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14846. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14847. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14848. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14849. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14850. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14851. builder.Write($"ROOM TYPE:");
  14852. builder.InsertCell();
  14853. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14854. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14855. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14856. builder.ParagraphFormat.Style.Font.Bold = false;
  14857. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14858. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14859. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14860. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14861. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14862. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14863. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14864. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14865. builder.Write($"{item.RoomExplanation}");
  14866. builder.InsertCell();
  14867. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14868. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14869. builder.InsertCell();
  14870. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14871. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14872. builder.EndRow();
  14873. #endregion
  14874. #region 第九行
  14875. builder.InsertCell();
  14876. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14877. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14878. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14879. builder.ParagraphFormat.Style.Font.Bold = false;
  14880. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14881. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14882. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14883. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14884. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14885. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14886. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14887. builder.Write($"NOTE:");
  14888. builder.InsertCell();
  14889. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14890. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14891. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14892. builder.ParagraphFormat.Style.Font.Bold = false;
  14893. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14894. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14895. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14896. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14897. 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.");
  14898. builder.InsertCell();
  14899. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14900. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14901. builder.InsertCell();
  14902. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14903. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14904. builder.EndRow();
  14905. #endregion
  14906. builder.EndTable();
  14907. //换行
  14908. builder.Writeln("");
  14909. builder.Writeln("");
  14910. }
  14911. #region 获取文档中的所有表格 设置文字自适应
  14912. // 获取文档中的所有表格。
  14913. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14914. {
  14915. // 遍历表格中的所有行。
  14916. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14917. {
  14918. foreach (Cell cell in row.Cells)
  14919. {
  14920. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  14921. cellFormat.Width = 0;
  14922. }
  14923. }
  14924. }
  14925. #endregion
  14926. #region 设置页眉
  14927. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  14928. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  14929. if (System.IO.File.Exists(voucherHeaderPath))
  14930. {
  14931. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  14932. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  14933. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  14934. Shape shape = builder.InsertImage(imageBytes);
  14935. // 调整图片位置
  14936. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  14937. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  14938. shape.Top = 50; // 将图片距离页眉上边缘的距离
  14939. shape.Left = 0; // 将图片距离页面左边缘的距离
  14940. shape.Width = 81; // 设置图片宽度
  14941. shape.Height = 36; // 设置图片高度
  14942. }
  14943. //靠右
  14944. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  14945. //// 设置页脚上下边距
  14946. //builder.PageSetup.HeaderDistance = 42;
  14947. // 添加页眉线
  14948. Aspose.Words.Border borderHeader = null;
  14949. try
  14950. {
  14951. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  14952. }
  14953. catch (Exception e)
  14954. {
  14955. // TODO Auto-generated catch block
  14956. //e.printStackTrace();
  14957. }
  14958. borderHeader.Shadow = true;
  14959. borderHeader.DistanceFromText = 2;
  14960. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  14961. #endregion
  14962. }
  14963. catch (Exception ex)
  14964. {
  14965. }
  14966. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14967. doc.Save(fileDir);
  14968. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14969. return Ok(JsonView(true, "操作成功!", Url));
  14970. }
  14971. /// <summary>
  14972. /// 酒店预订
  14973. /// 生成 预定成本 Excel
  14974. /// </summary>
  14975. /// <param name="_dto"></param>
  14976. /// <returns></returns>
  14977. [HttpPost]
  14978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14979. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  14980. {
  14981. #region 参数验证
  14982. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  14983. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  14984. if (!vadalitorRes.IsValid)
  14985. {
  14986. var errors = new StringBuilder();
  14987. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  14988. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  14989. }
  14990. #region 团组操作权限验证 76 酒店预定模块
  14991. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14992. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14993. #endregion
  14994. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14995. #region 页面操作权限验证
  14996. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14997. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14998. #endregion
  14999. #endregion
  15000. decimal _rate = 1.00M;
  15001. string _currency = string.Empty;
  15002. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  15003. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15004. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  15005. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15006. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  15007. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  15008. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  15009. if (_GroupCostParameter == null)
  15010. {
  15011. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  15012. bool isIntType = int.TryParse(_currency, out int currId);
  15013. if (isIntType)
  15014. {
  15015. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15016. }
  15017. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15018. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15019. if (currInfo == null)
  15020. {
  15021. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15022. }
  15023. else _rate = currInfo.Rate;
  15024. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  15025. {
  15026. _rate = _GroupCostParameter.Rate;
  15027. }
  15028. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15029. //string strFileName = "HotelStatement/";
  15030. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15031. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15032. var rateDatas = new List<dynamic>();
  15033. #region 数据处理
  15034. foreach (var item in hrDtas)
  15035. {
  15036. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15037. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15038. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15039. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15040. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15041. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  15042. {
  15043. continue;
  15044. }
  15045. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15046. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  15047. string singleRoomFeeStr = string.Empty,
  15048. doubleRoomFeeStr = string.Empty,
  15049. suiteRoomFeeStr = string.Empty,
  15050. otherRoomFeeStr = string.Empty,
  15051. payMoneyStr = string.Empty,
  15052. cardPriceStr = string.Empty;
  15053. if (roomCurr.Equals("CNY"))
  15054. {
  15055. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  15056. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15057. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15058. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15059. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15060. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  15061. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  15062. }
  15063. else
  15064. {
  15065. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15066. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15067. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15068. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15069. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15070. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15071. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15072. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15073. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15074. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15075. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  15076. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  15077. if (ccpPaymentCurrency.Equals("CNY"))
  15078. {
  15079. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  15080. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15081. }
  15082. else
  15083. {
  15084. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  15085. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  15086. }
  15087. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  15088. if (hotelcardPriceCurrency.Equals("CNY"))
  15089. {
  15090. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15091. }
  15092. else
  15093. {
  15094. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  15095. }
  15096. }
  15097. string breakfastPriceStr = string.Empty,
  15098. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15099. governmentRentStr = string.Empty,
  15100. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15101. cityTaxStr = string.Empty,
  15102. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15103. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  15104. if (!string.IsNullOrEmpty(breakfastCurrency1))
  15105. {
  15106. if (breakfastCurrency1.Equals("CNY"))
  15107. {
  15108. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15109. }
  15110. else
  15111. {
  15112. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  15113. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  15114. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  15115. }
  15116. }
  15117. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15118. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  15119. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  15120. {
  15121. if (governmentRentCurrency.Equals("CNY"))
  15122. {
  15123. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15124. }
  15125. else
  15126. {
  15127. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  15128. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  15129. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  15130. }
  15131. }
  15132. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15133. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  15134. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  15135. {
  15136. if (cityTaxStrCurrency1.Equals("CNY"))
  15137. {
  15138. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15139. }
  15140. else
  15141. {
  15142. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  15143. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  15144. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  15145. }
  15146. }
  15147. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15148. int payDId = roomInfo?.PayDId ?? 0;
  15149. pcfds.Add(new HotelReservations_PCFD_View()
  15150. {
  15151. City = item.City,
  15152. HotelName = item.HotelName,
  15153. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15154. // SingleRoomCount = item.SingleRoomCount,
  15155. SingleRoomPrice = singleRoomFeeStr,
  15156. // DoubleRoomCount = item.DoubleRoomCount,
  15157. DoubleRoomPrice = doubleRoomFeeStr,
  15158. //SuiteRoomCount = item.SuiteRoomCount,
  15159. SuiteRoomPrice = suiteRoomFeeStr,
  15160. OtherRoomPrice = otherRoomFeeStr,
  15161. //OtherRoomCount = item.OtherRoomCount,
  15162. BreakfastPrice = breakfastPriceStr,
  15163. GovernmentRent = governmentRentStr,
  15164. CityTax = cityTaxStr,
  15165. RoomExplanation = item.RoomExplanation,
  15166. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15167. PayTime = roomInfo?.ConsumptionDate,
  15168. BankNo = roomInfo?.BankNo,
  15169. PayMoney = payMoneyStr,
  15170. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15171. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15172. CardPrice = cardPriceStr,
  15173. Remark = ccpInfo.Remark
  15174. });
  15175. }
  15176. #endregion
  15177. //载入模板
  15178. WorkbookDesigner designer = new WorkbookDesigner();
  15179. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15180. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15181. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15182. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15183. var rateDatas1 = rateDatas.Distinct();
  15184. var rateStr = string.Empty;
  15185. foreach (var item in rateDatas1)
  15186. {
  15187. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  15188. }
  15189. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  15190. designer.SetDataSource("Opertor", userInfo.CnName);
  15191. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15192. dt.TableName = "ViewMyHotelReservations";
  15193. designer.SetDataSource(dt);
  15194. designer.Process();
  15195. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15196. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15197. designer.Workbook.Save(serverPath);
  15198. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15199. #region 删除指定行
  15200. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15201. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15202. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15203. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15204. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15205. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15206. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15207. cssIndex = dt.Columns["CityTax"].Ordinal,
  15208. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15209. remarkIndex = dt.Columns["Remark"].Ordinal;
  15210. //删除指定列
  15211. foreach (DataRow item in dt.Rows)
  15212. {
  15213. string singleStr = item["SingleRoomPrice"].ToString();
  15214. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15215. if (containsDigitButNotZero1) singleDel = false;
  15216. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15217. string doubleStr = item["DoubleRoomPrice"].ToString();
  15218. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15219. if (containsDigitButNotZero2) doubleDel = false;
  15220. string suiteStr = item["SuiteRoomPrice"].ToString();
  15221. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15222. if (containsDigitButNotZero3) suiteDel = false;
  15223. string otherStr = item["OtherRoomPrice"].ToString();
  15224. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15225. if (containsDigitButNotZero4) otherDel = false;
  15226. string zcStr = item["BreakfastPrice"].ToString();
  15227. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15228. if (containsDigitButNotZero5) zcDel = false;
  15229. string dsStr = item["GovernmentRent"].ToString();
  15230. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15231. if (containsDigitButNotZero6) dsDel = false;
  15232. string cssStr = item["CityTax"].ToString();
  15233. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15234. if (containsDigitButNotZero7) cssDel = false;
  15235. string cpStr = item["ConsumptionPatterns"].ToString();
  15236. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15237. string remarkStr = item["Remark"].ToString();
  15238. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15239. }
  15240. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15241. DeleteColumn(serverPath, cpIndex, cpDel);
  15242. DeleteColumn(serverPath, dsIndex, dsDel);
  15243. DeleteColumn(serverPath, cssIndex, cssDel);
  15244. DeleteColumn(serverPath, zcIndex, zcDel);
  15245. DeleteColumn(serverPath, otherIndex, otherDel);
  15246. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15247. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15248. DeleteColumn(serverPath, singleIndex, singleDel);
  15249. #endregion
  15250. //只保留第一个表格
  15251. DeleteSheet(serverPath);
  15252. return Ok(JsonView(true, "操作成功", url = rst));
  15253. }
  15254. else
  15255. {
  15256. _currency = _GroupCostParameter.Currency;
  15257. bool isIntType = int.TryParse(_currency, out int currId);
  15258. if (isIntType)
  15259. {
  15260. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15261. }
  15262. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15263. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15264. if (currInfo == null)
  15265. {
  15266. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15267. }
  15268. if (!_currency.ToUpper().Equals("CNY"))
  15269. {
  15270. _rate = _GroupCostParameter.Rate;
  15271. }
  15272. _rate = currInfo.Rate;
  15273. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15274. //string strFileName = "HotelStatement/";
  15275. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15276. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15277. #region 数据处理
  15278. foreach (var item in hrDtas)
  15279. {
  15280. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15281. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15282. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15283. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15284. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15285. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15286. string singleRoomFeeStr = string.Empty,
  15287. doubleRoomFeeStr = string.Empty,
  15288. suiteRoomFeeStr = string.Empty,
  15289. otherRoomFeeStr = string.Empty,
  15290. payMoneyStr = string.Empty,
  15291. cardPriceStr = string.Empty;
  15292. if (roomCurr.Equals(_currency))
  15293. {
  15294. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  15295. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  15296. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  15297. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  15298. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  15299. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  15300. }
  15301. else
  15302. {
  15303. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15304. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15305. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15306. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15307. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15308. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15309. }
  15310. string breakfastPriceStr = string.Empty,
  15311. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15312. governmentRentStr = string.Empty,
  15313. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15314. cityTaxStrStr = string.Empty,
  15315. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15316. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  15317. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  15318. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  15319. int payDId = roomInfo?.PayDId ?? 0;
  15320. pcfds.Add(new HotelReservations_PCFD_View()
  15321. {
  15322. City = item.City,
  15323. HotelName = item.HotelName,
  15324. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15325. // SingleRoomCount = item.SingleRoomCount,
  15326. SingleRoomPrice = singleRoomFeeStr,
  15327. // DoubleRoomCount = item.DoubleRoomCount,
  15328. DoubleRoomPrice = doubleRoomFeeStr,
  15329. //SuiteRoomCount = item.SuiteRoomCount,
  15330. SuiteRoomPrice = suiteRoomFeeStr,
  15331. OtherRoomPrice = otherRoomFeeStr,
  15332. //OtherRoomCount = item.OtherRoomCount,
  15333. BreakfastPrice = breakfastPriceStr,
  15334. GovernmentRent = governmentRentStr,
  15335. CityTax = cityTaxStrStr,
  15336. RoomExplanation = item.RoomExplanation,
  15337. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15338. PayTime = roomInfo?.ConsumptionDate,
  15339. BankNo = roomInfo?.BankNo,
  15340. PayMoney = payMoneyStr,
  15341. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15342. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15343. CardPrice = cardPriceStr,
  15344. Remark = ccpInfo.Remark
  15345. });
  15346. }
  15347. #endregion
  15348. //载入模板
  15349. WorkbookDesigner designer = new WorkbookDesigner();
  15350. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15351. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15352. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15353. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15354. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  15355. designer.SetDataSource("Opertor", userInfo.CnName);
  15356. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15357. dt.TableName = "ViewMyHotelReservations";
  15358. designer.SetDataSource(dt);
  15359. designer.Process();
  15360. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15361. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15362. designer.Workbook.Save(serverPath);
  15363. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15364. #region 删除指定行
  15365. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15366. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15367. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15368. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15369. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15370. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15371. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15372. cssIndex = dt.Columns["CityTax"].Ordinal,
  15373. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15374. remarkIndex = dt.Columns["Remark"].Ordinal;
  15375. //删除指定列
  15376. foreach (DataRow item in dt.Rows)
  15377. {
  15378. string singleStr = item["SingleRoomPrice"].ToString();
  15379. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15380. if (containsDigitButNotZero1) singleDel = false;
  15381. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15382. string doubleStr = item["DoubleRoomPrice"].ToString();
  15383. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15384. if (containsDigitButNotZero2) doubleDel = false;
  15385. string suiteStr = item["SuiteRoomPrice"].ToString();
  15386. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15387. if (containsDigitButNotZero3) suiteDel = false;
  15388. string otherStr = item["OtherRoomPrice"].ToString();
  15389. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15390. if (containsDigitButNotZero4) otherDel = false;
  15391. string zcStr = item["BreakfastPrice"].ToString();
  15392. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15393. if (containsDigitButNotZero5) zcDel = false;
  15394. string dsStr = item["GovernmentRent"].ToString();
  15395. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15396. if (containsDigitButNotZero6) dsDel = false;
  15397. string cssStr = item["CityTax"].ToString();
  15398. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15399. if (containsDigitButNotZero7) cssDel = false;
  15400. string cpStr = item["ConsumptionPatterns"].ToString();
  15401. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15402. string remarkStr = item["Remark"].ToString();
  15403. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15404. }
  15405. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15406. DeleteColumn(serverPath, cpIndex, cpDel);
  15407. DeleteColumn(serverPath, dsIndex, dsDel);
  15408. DeleteColumn(serverPath, cssIndex, cssDel);
  15409. DeleteColumn(serverPath, zcIndex, zcDel);
  15410. DeleteColumn(serverPath, otherIndex, otherDel);
  15411. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15412. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15413. DeleteColumn(serverPath, singleIndex, singleDel);
  15414. #endregion
  15415. //只保留第一个表格
  15416. DeleteSheet(serverPath);
  15417. return Ok(JsonView(true, "操作成功", url = rst));
  15418. }
  15419. //return Ok(JsonView(false));
  15420. }
  15421. /// <summary>
  15422. /// 删除指定列
  15423. /// </summary>
  15424. /// <param name="file"></param>
  15425. /// <param name="columnIndex"></param>
  15426. /// <param name="isDel"></param>
  15427. private void DeleteColumn(string file, int columnIndex, bool isDel)
  15428. {
  15429. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15430. //wb.Save(file);
  15431. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  15432. if (sheet1 != null)
  15433. {
  15434. if (isDel)
  15435. {
  15436. Cells cells = sheet1.Cells;
  15437. cells.DeleteColumn(columnIndex);
  15438. }
  15439. }
  15440. wb.Save(file);
  15441. }
  15442. /// <summary>
  15443. /// 删除sheet
  15444. /// </summary>
  15445. /// <param name="file"></param>
  15446. /// <param name="sheetName"></param>
  15447. private void DeleteSheet(string file, string sheetName = "")
  15448. {
  15449. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15450. //wb.Save(file);
  15451. List<string> sheets = new List<string>();
  15452. foreach (var item in wb.Worksheets)
  15453. {
  15454. sheets.Add(item.Name);
  15455. }
  15456. if (sheets.Count > 0)
  15457. {
  15458. sheets.RemoveAt(0);//不删除第一个sheet
  15459. foreach (var item in sheets)
  15460. {
  15461. wb.Worksheets.RemoveAt(item);
  15462. }
  15463. }
  15464. wb.Save(file);
  15465. }
  15466. /// <summary>
  15467. /// 酒店预订
  15468. /// 确认单
  15469. /// </summary>
  15470. /// <param name="_dto"></param>
  15471. /// <returns></returns>
  15472. [HttpPost]
  15473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15474. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  15475. {
  15476. try
  15477. {
  15478. #region 参数验证
  15479. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15480. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15481. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15482. #region 团组操作权限验证 76 酒店预定模块
  15483. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15484. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15485. #endregion
  15486. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15487. #region 页面操作权限验证
  15488. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15489. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15490. #endregion
  15491. #endregion
  15492. //团组信息
  15493. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  15494. //酒店数据
  15495. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  15496. if (listhoteldata.Count < 0)
  15497. {
  15498. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  15499. }
  15500. //利datatable存储
  15501. DataTable dt = new DataTable();
  15502. dt.Columns.Add("CheckInDate", typeof(string));
  15503. dt.Columns.Add("City", typeof(string));
  15504. dt.Columns.Add("Hotel", typeof(string));
  15505. dt.Columns.Add("Room", typeof(string));
  15506. for (int i = 0; i < listhoteldata.Count; i++)
  15507. {
  15508. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  15509. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  15510. while (dayStart < dayEnd)
  15511. {
  15512. string temp = "";
  15513. DataRow row = dt.NewRow();
  15514. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  15515. row["City"] = listhoteldata[i].City;
  15516. row["Hotel"] = listhoteldata[i].HotelName;
  15517. if (listhoteldata[i].SingleRoomCount > 0)
  15518. {
  15519. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  15520. }
  15521. if (listhoteldata[i].DoubleRoomCount > 0)
  15522. {
  15523. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  15524. }
  15525. if (listhoteldata[i].SuiteRoomCount > 0)
  15526. {
  15527. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  15528. }
  15529. if (listhoteldata[i].OtherRoomCount > 0)
  15530. {
  15531. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  15532. }
  15533. row["Room"] = temp;
  15534. dt.Rows.Add(row);
  15535. dayStart = dayStart.AddDays(1);
  15536. }
  15537. }
  15538. Dictionary<string, string> dic = new Dictionary<string, string>();
  15539. dic.Add("Dele", di.TeamName);
  15540. dic.Add("City", di.VisitCountry);
  15541. //模板路径
  15542. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  15543. //载入模板
  15544. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  15545. DocumentBuilder builder = new DocumentBuilder(doc);
  15546. foreach (var key in dic.Keys)
  15547. {
  15548. builder.MoveToBookmark(key);
  15549. builder.Write(dic[key]);
  15550. }
  15551. //获取word里所有表格
  15552. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15553. //获取所填表格的序数
  15554. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  15555. var rowStart = tableOne.Rows[0]; //获取第1行
  15556. //循环赋值
  15557. for (int i = 0; i < dt.Rows.Count; i++)
  15558. {
  15559. builder.MoveToCell(0, i + 1, 0, 0);
  15560. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  15561. builder.MoveToCell(0, i + 1, 1, 0);
  15562. builder.Write(dt.Rows[i]["City"].ToString());
  15563. builder.MoveToCell(0, i + 1, 2, 0);
  15564. builder.Write(dt.Rows[i]["Hotel"].ToString());
  15565. builder.MoveToCell(0, i + 1, 3, 0);
  15566. builder.Write(dt.Rows[i]["Room"].ToString());
  15567. }
  15568. //删除多余行
  15569. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  15570. {
  15571. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  15572. }
  15573. string strFileName = di.TeamName + "酒店确认单.doc";
  15574. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  15575. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  15576. return Ok(JsonView(true, "成功", url));
  15577. }
  15578. catch (Exception ex)
  15579. {
  15580. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  15581. }
  15582. }
  15583. #endregion
  15584. #region 团组状态
  15585. /// <summary>
  15586. /// 团组状态列表 Page
  15587. /// </summary>
  15588. /// <param name="dto">团组列表请求dto</param>
  15589. /// <returns></returns>
  15590. [HttpPost]
  15591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15592. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  15593. {
  15594. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15595. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  15596. {
  15597. string sqlWhere = string.Empty;
  15598. if (dto.IsSure == 0) //未完成
  15599. {
  15600. sqlWhere += string.Format(@" And IsSure = 0");
  15601. }
  15602. else if (dto.IsSure == 1) //已完成
  15603. {
  15604. sqlWhere += string.Format(@" And IsSure = 1");
  15605. }
  15606. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  15607. {
  15608. string tj = dto.SearchCriteria;
  15609. 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}%')",
  15610. tj, tj, tj, tj, tj);
  15611. }
  15612. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  15613. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  15614. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  15615. From (
  15616. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  15617. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  15618. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  15619. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  15620. From Grp_DelegationInfo gdi
  15621. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  15622. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  15623. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  15624. Where gdi.IsDel = 0 {0}
  15625. ) temp ", sqlWhere);
  15626. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  15627. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  15628. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  15629. }
  15630. else
  15631. {
  15632. return Ok(JsonView(false, "查询失败"));
  15633. }
  15634. }
  15635. /// <summary>
  15636. /// 团组状态
  15637. /// 设置操作完成
  15638. /// </summary>
  15639. /// <param name="dto">团组列表请求dto</param>
  15640. /// <returns></returns>
  15641. [HttpPost]
  15642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15643. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  15644. {
  15645. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15646. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  15647. {
  15648. Id = dto.Id,
  15649. IsSure = 1
  15650. };
  15651. var result = await _sqlSugar.Updateable(_DelegationInfo)
  15652. .UpdateColumns(it => new { it.IsSure })
  15653. .WhereColumns(it => new { it.Id })
  15654. .ExecuteCommandAsync();
  15655. if (result > 0)
  15656. {
  15657. return Ok(JsonView(true, "操作完成!"));
  15658. }
  15659. return Ok(JsonView(false, "操作失败!"));
  15660. }
  15661. #endregion
  15662. #region 保险费用录入
  15663. /// <summary>
  15664. /// 根据团组Id查询保险费用列表
  15665. /// </summary>
  15666. /// <param name="dto"></param>
  15667. /// <returns></returns>
  15668. [HttpPost]
  15669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15670. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  15671. {
  15672. Result groupData = await _customersRep.CustomersByDiId(dto);
  15673. if (groupData.Code != 0)
  15674. {
  15675. return Ok(JsonView(false, groupData.Msg));
  15676. }
  15677. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15678. }
  15679. /// <summary>
  15680. /// 根据保险费用Id查询保险费用详细
  15681. /// </summary>
  15682. /// <param name="dto"></param>
  15683. /// <returns></returns>
  15684. [HttpPost]
  15685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15686. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  15687. {
  15688. try
  15689. {
  15690. Result groupData = await _customersRep.CustomersById(dto);
  15691. if (groupData.Code != 0)
  15692. {
  15693. return Ok(JsonView(false, groupData.Msg));
  15694. }
  15695. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15696. }
  15697. catch (Exception ex)
  15698. {
  15699. return Ok(JsonView(false, ex.Message));
  15700. }
  15701. }
  15702. /// <summary>
  15703. /// 保险费用录入页面初始化绑定
  15704. /// </summary>
  15705. /// <param name="dto"></param>
  15706. /// <returns></returns>
  15707. [HttpPost]
  15708. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15709. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  15710. {
  15711. try
  15712. {
  15713. Result groupData = await _customersRep.CustomersInitialize(dto);
  15714. if (groupData.Code != 0)
  15715. {
  15716. return Ok(JsonView(false, groupData.Msg));
  15717. }
  15718. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15719. }
  15720. catch (Exception ex)
  15721. {
  15722. return Ok(JsonView(false, ex.Message));
  15723. }
  15724. }
  15725. /// <summary>
  15726. /// 保险费用操作(Status:1.新增,2.修改)
  15727. /// </summary>
  15728. /// <param name="dto"></param>
  15729. /// <returns></returns>
  15730. [HttpPost]
  15731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15732. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  15733. {
  15734. Result groupData = await _customersRep.OpCustomers(dto);
  15735. if (groupData.Code != 0)
  15736. {
  15737. return Ok(JsonView(false, groupData.Msg));
  15738. }
  15739. #region 应用推送
  15740. try
  15741. {
  15742. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  15743. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  15744. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  15745. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  15746. //自动审核
  15747. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  15748. //2024-10-21 新增LZ UID
  15749. var userIds = new List<int>() { 21 };
  15750. string title = $"系统通知";
  15751. var diId = dto.DiId;
  15752. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15753. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15754. string content = "";
  15755. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15756. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15757. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  15758. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  15759. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  15760. }
  15761. catch (Exception ex)
  15762. {
  15763. }
  15764. #endregion
  15765. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15766. }
  15767. /// <summary>
  15768. /// 保险文件上传
  15769. /// </summary>
  15770. /// <param name="file"></param>
  15771. /// <returns></returns>
  15772. [HttpPost]
  15773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15774. public async Task<IActionResult> UploadCus(IFormFile file)
  15775. {
  15776. try
  15777. {
  15778. if (file != null)
  15779. {
  15780. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15781. //文件名称
  15782. string projectFileName = file.FileName;
  15783. //上传的文件的路径
  15784. string filePath = "";
  15785. if (!Directory.Exists(fileDir))
  15786. {
  15787. Directory.CreateDirectory(fileDir);
  15788. }
  15789. //上传的文件的路径
  15790. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  15791. using (FileStream fs = System.IO.File.Create(filePath))
  15792. {
  15793. file.CopyTo(fs);
  15794. fs.Flush();
  15795. }
  15796. return Ok(JsonView(true, "上传成功!", projectFileName));
  15797. }
  15798. else
  15799. {
  15800. return Ok(JsonView(false, "上传失败!"));
  15801. }
  15802. }
  15803. catch (Exception ex)
  15804. {
  15805. return Ok(JsonView(false, "程序错误!"));
  15806. throw;
  15807. }
  15808. }
  15809. /// <summary>
  15810. /// 保险删除指定文件
  15811. /// </summary>
  15812. /// <param name="dto"></param>
  15813. /// <returns></returns>
  15814. [HttpPost]
  15815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15816. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  15817. {
  15818. try
  15819. {
  15820. string filePath = "";
  15821. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15822. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  15823. //int id = 0;
  15824. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  15825. // 删除该文件
  15826. try
  15827. {
  15828. System.IO.File.Delete(filePath);
  15829. 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()
  15830. {
  15831. Attachment = "",
  15832. }).ExecuteCommandAsync();
  15833. if (result != 0)
  15834. {
  15835. return Ok(JsonView(true, "成功!"));
  15836. }
  15837. else
  15838. {
  15839. return Ok(JsonView(false, "失败!"));
  15840. }
  15841. }
  15842. catch (Exception)
  15843. {
  15844. 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()
  15845. {
  15846. Attachment = "",
  15847. }).ExecuteCommandAsync();
  15848. if (result != 0)
  15849. {
  15850. return Ok(JsonView(true, "成功!"));
  15851. }
  15852. else
  15853. {
  15854. return Ok(JsonView(false, "失败!"));
  15855. }
  15856. }
  15857. }
  15858. catch (Exception ex)
  15859. {
  15860. return Ok(JsonView(false, "程序错误!"));
  15861. throw;
  15862. }
  15863. }
  15864. /// <summary>
  15865. /// 保险费用操作(删除)
  15866. /// </summary>
  15867. /// <param name="dto"></param>
  15868. /// <returns></returns>
  15869. [HttpPost]
  15870. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15871. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  15872. {
  15873. try
  15874. {
  15875. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  15876. if (!res)
  15877. {
  15878. return Ok(JsonView(false, "删除失败"));
  15879. }
  15880. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  15881. {
  15882. IsDel = 1,
  15883. DeleteUserId = dto.DeleteUserId,
  15884. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  15885. }).ExecuteCommandAsync();
  15886. return Ok(JsonView(true, "删除成功!"));
  15887. }
  15888. catch (Exception ex)
  15889. {
  15890. return Ok(JsonView(false, "程序错误!"));
  15891. throw;
  15892. }
  15893. }
  15894. #endregion
  15895. #region 接团客户名单 PageId 104
  15896. /// <summary>
  15897. /// 接团客户名单
  15898. /// 迁移数据(慎用!)
  15899. /// </summary>
  15900. /// <returns></returns>
  15901. [HttpPost]
  15902. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15903. public async Task<IActionResult> PostTourClientListChange()
  15904. {
  15905. try
  15906. {
  15907. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  15908. //var groupClinetData1
  15909. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  15910. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  15911. int updateCount = 0;
  15912. if (oldOAClientList.Count > 0)
  15913. {
  15914. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  15915. _sqlSugar.BeginTran();
  15916. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  15917. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  15918. foreach (var item in oldOAClientList)
  15919. {
  15920. int comId = 0;
  15921. string format = "yyyy-MM-dd HH:mm:ss";
  15922. string data11 = "1990-01-01 00:00";
  15923. var data1 = IsValidDate(item.OPdate, format);
  15924. if (data1) data11 = item.OPdate;
  15925. //客户公司验证
  15926. if (!string.IsNullOrEmpty(item.Company))
  15927. {
  15928. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  15929. if (clientComInfo == null) // add
  15930. {
  15931. var addInfo = new Crm_CustomerCompany()
  15932. {
  15933. CompanyAbbreviation = "",
  15934. CompanyFullName = item.Company,
  15935. Address = "",
  15936. PostCodes = "",
  15937. LastedOpUserId = item.OPer,
  15938. LastedOpDt = Convert.ToDateTime(data11),
  15939. CreateUserId = item.OPer,
  15940. CreateTime = Convert.ToDateTime(data11),
  15941. IsDel = 0
  15942. };
  15943. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  15944. if (comId1 > 0) comId = comId1;
  15945. }
  15946. else comId = clientComInfo.Id;
  15947. }
  15948. //客户人员验证
  15949. int clientId = 0;
  15950. string name = item.LastName + item.Name;
  15951. if (!string.IsNullOrEmpty(name))
  15952. {
  15953. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  15954. if (clientInfo == null)
  15955. {
  15956. DateTime? dateTime = null;
  15957. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  15958. if (isDt) dateTime = birthDayDt;
  15959. var addInfo1 = new Crm_DeleClient()
  15960. {
  15961. CrmCompanyId = comId,
  15962. DiId = -1,
  15963. LastName = item.LastName,
  15964. FirstName = item.Name,
  15965. OldName = "",
  15966. Pinyin = item.Pinyin,
  15967. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  15968. Marriage = 0,
  15969. Phone = item.Phone,
  15970. Job = item.Job,
  15971. BirthDay = dateTime
  15972. };
  15973. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  15974. if (clientId1 > 0) clientId = clientId1;
  15975. }
  15976. else clientId = clientInfo.Id;
  15977. }
  15978. if (clientId < 1)
  15979. {
  15980. continue;
  15981. }
  15982. int airType = 0;
  15983. if (item.AirType == "超经舱") airType = 459;
  15984. else if (item.AirType == "公务舱") airType = 458;
  15985. else if (item.AirType == "经济舱") airType = 460;
  15986. else if (item.AirType == "其他") airType = 565;
  15987. else if (item.AirType == "头等舱") airType = 457;
  15988. var _TourClientListEntity = new Grp_TourClientList()
  15989. {
  15990. DiId = item.Diid,
  15991. ClientId = clientId,
  15992. CreateUserId = item.OPer,
  15993. CreateTime = Convert.ToDateTime(data11),
  15994. Remark = item.Remark,
  15995. IsDel = item.Isdel,
  15996. ShippingSpaceTypeId = airType,
  15997. ShippingSpaceSpecialNeeds = item.AirRemark,
  15998. HotelSpecialNeeds = item.RoomType
  15999. };
  16000. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  16001. if (_TourClientList > 0)
  16002. {
  16003. updateCount++;
  16004. }
  16005. }
  16006. _sqlSugar.CommitTran();
  16007. }
  16008. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  16009. }
  16010. catch (Exception ex)
  16011. {
  16012. _sqlSugar.RollbackTran();
  16013. return Ok(JsonView(false, ex.Message));
  16014. }
  16015. //return Ok(JsonView(true));
  16016. }
  16017. private bool IsValidDate(string dateString, string format)
  16018. {
  16019. DateTime dateValue;
  16020. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  16021. return valid;
  16022. }
  16023. /// <summary>
  16024. /// 接团客户名单
  16025. /// 根据团组Id查询List
  16026. /// </summary>
  16027. /// <param name="_dto"></param>
  16028. /// <returns></returns>
  16029. [HttpPost]
  16030. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16031. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  16032. {
  16033. #region 参数验证
  16034. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  16035. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  16036. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  16037. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16038. #region 页面操作权限验证
  16039. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16040. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16041. #endregion
  16042. #endregion
  16043. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  16044. if (viewData.Code != 0)
  16045. {
  16046. return Ok(JsonView(false, viewData.Msg));
  16047. }
  16048. return Ok(JsonView(viewData.Data));
  16049. }
  16050. /// <summary>
  16051. /// 接团客户名单
  16052. /// 基础数据 Init
  16053. /// </summary>
  16054. /// <param name="_dto"></param>
  16055. /// <returns></returns>
  16056. [HttpPost]
  16057. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16058. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  16059. {
  16060. #region 参数验证
  16061. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16062. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16063. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16064. #region 页面操作权限验证
  16065. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16066. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16067. #endregion
  16068. #endregion
  16069. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  16070. }
  16071. /// <summary>
  16072. /// 接团客户名单
  16073. /// 根据 Id查询 Details
  16074. /// </summary>
  16075. /// <param name="_dto"></param>
  16076. /// <returns></returns>
  16077. [HttpPost]
  16078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16079. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  16080. {
  16081. #region 参数验证
  16082. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16083. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16084. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16085. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16086. #region 页面操作权限验证
  16087. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16088. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16089. #endregion
  16090. #endregion
  16091. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  16092. if (viewData.Code != 0)
  16093. {
  16094. return Ok(JsonView(false, viewData.Msg));
  16095. }
  16096. return Ok(JsonView(viewData.Data));
  16097. }
  16098. /// <summary>
  16099. /// 接团客户名单
  16100. /// Add Or Edit
  16101. /// </summary>
  16102. /// <param name="_dto"></param>
  16103. /// <returns></returns>
  16104. [HttpPost]
  16105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16106. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  16107. {
  16108. #region 参数验证
  16109. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16110. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16111. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16112. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16113. #region 页面操作权限验证
  16114. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16115. if (_dto.Id == 0) //添加
  16116. {
  16117. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16118. }
  16119. else if (_dto.Id >= 0) //修改
  16120. {
  16121. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16122. }
  16123. #endregion
  16124. #endregion
  16125. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  16126. if (viewData.Code != 0)
  16127. {
  16128. return Ok(JsonView(false, viewData.Msg));
  16129. }
  16130. return Ok(JsonView(true));
  16131. }
  16132. /// <summary>
  16133. /// 接团客户名单
  16134. /// json字符串 AddMultiple(添加多个)
  16135. /// </summary>
  16136. /// <param name="_dto"></param>
  16137. /// <returns></returns>
  16138. [HttpPost]
  16139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16140. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  16141. {
  16142. #region 参数验证
  16143. string jsonLabel = _dto.JsonLabel;
  16144. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16145. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16146. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16147. #region 页面操作权限验证
  16148. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16149. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16150. #endregion
  16151. #endregion
  16152. var request = new TourClientListAddMultipleDto();
  16153. request.DiId = _dto.DiId;
  16154. request.UserId = _dto.UserId;
  16155. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  16156. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  16157. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  16158. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  16159. var infos = new List<TourClientListInfo>();
  16160. foreach (var data in datas)
  16161. {
  16162. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  16163. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  16164. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  16165. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  16166. {
  16167. continue;
  16168. }
  16169. infos.Add(new TourClientListInfo()
  16170. {
  16171. IsAccompany = 1,
  16172. LastName = lastName,
  16173. FirstName = firstName,
  16174. Pinyin = lastNameEn + @"/" + firstNameEn,
  16175. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  16176. CompanyFullName = data.CompanyFullName,
  16177. Job = data.Job
  16178. });
  16179. }
  16180. if (infos.Any())
  16181. {
  16182. var viewData = await _tourClientListRep._AddMultiple(request);
  16183. if (viewData.Code != 0)
  16184. {
  16185. return Ok(JsonView(false, viewData.Msg));
  16186. }
  16187. return Ok(JsonView(true));
  16188. }
  16189. return Ok(JsonView(false));
  16190. }
  16191. /// <summary>
  16192. /// 接团客户名单
  16193. /// AddMultiple(添加多个)
  16194. /// </summary>
  16195. /// <param name="_dto"></param>
  16196. /// <returns></returns>
  16197. [HttpPost]
  16198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16199. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  16200. {
  16201. #region 参数验证
  16202. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16203. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16204. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16205. #region 页面操作权限验证
  16206. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16207. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16208. #endregion
  16209. #endregion
  16210. var viewData = await _tourClientListRep._AddMultiple(_dto);
  16211. if (viewData.Code != 0)
  16212. {
  16213. return Ok(JsonView(false, viewData.Msg));
  16214. }
  16215. return Ok(JsonView(true));
  16216. }
  16217. /// <summary>
  16218. /// 接团客户名单
  16219. /// Del
  16220. /// </summary>
  16221. /// <param name="_dto"></param>
  16222. /// <returns></returns>
  16223. [HttpPost]
  16224. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16225. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  16226. {
  16227. #region 参数验证
  16228. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16229. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16230. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16231. #region 页面操作权限验证
  16232. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16233. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16234. #endregion
  16235. #endregion
  16236. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  16237. if (viewData.Code != 0)
  16238. {
  16239. return Ok(JsonView(false, viewData.Msg));
  16240. }
  16241. return Ok(JsonView(true));
  16242. }
  16243. /// <summary>
  16244. /// 接团客户名单
  16245. /// 文件下载 客户名单
  16246. /// </summary>
  16247. /// <param name="_dto"></param>
  16248. /// <returns></returns>
  16249. [HttpPost]
  16250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16251. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  16252. {
  16253. #region 参数验证
  16254. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16255. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16256. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  16257. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16258. #region 页面操作权限验证
  16259. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16260. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16261. #endregion
  16262. #endregion
  16263. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  16264. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  16265. From Grp_TourClientList tcl
  16266. Left Join
  16267. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  16268. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  16269. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  16270. From Crm_DeleClient dc
  16271. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  16272. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  16273. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  16274. Where dc.IsDel = 0) temp
  16275. On temp.DcId =tcl.ClientId
  16276. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  16277. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  16278. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  16279. //载入模板
  16280. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  16281. if (_dto.Language == 1)
  16282. {
  16283. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  16284. }
  16285. //载入模板
  16286. var doc = new Document(tempPath);
  16287. DocumentBuilder builder = new DocumentBuilder(doc);
  16288. //获取word里所有表格
  16289. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16290. //获取所填表格的序数
  16291. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16292. var rowStart = tableOne.Rows[0]; //获取第1行
  16293. if (_dto.Language == 0)
  16294. {
  16295. //循环赋值
  16296. for (int i = 0; i < DcList.Count; i++)
  16297. {
  16298. EncryptionProcessor.DecryptProperties(DcList[i]);
  16299. builder.MoveToCell(0, i + 1, 0, 0);
  16300. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  16301. builder.MoveToCell(0, i + 1, 1, 0);
  16302. int sex = DcList[i].Sex;
  16303. string sexStr = string.Empty;
  16304. if (sex == 0) sexStr = "男";
  16305. else if (sex == 1) sexStr = "女";
  16306. else sexStr = "未设置";
  16307. builder.Write(sexStr);
  16308. builder.MoveToCell(0, i + 1, 2, 0);
  16309. string birthDay = DcList[i].BirthDay;
  16310. string birthDayStr = string.Empty;
  16311. if (!string.IsNullOrEmpty(birthDay))
  16312. {
  16313. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  16314. }
  16315. builder.Write(birthDayStr);
  16316. builder.MoveToCell(0, i + 1, 3, 0);
  16317. string company = "";
  16318. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16319. {
  16320. company = DcList[i].CompanyFullName.ToString();
  16321. }
  16322. builder.Write(company);
  16323. builder.MoveToCell(0, i + 1, 4, 0);
  16324. builder.Write(DcList[i].Job);
  16325. }
  16326. }
  16327. else if (_dto.Language == 1)
  16328. {
  16329. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  16330. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  16331. List<string> transArrayStr = new List<string>();
  16332. string transStrRes1 = "";
  16333. for (int i = 0; i < DcList.Count; i++)
  16334. {
  16335. var dc = DcList[i];
  16336. EncryptionProcessor.DecryptProperties(dc);
  16337. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  16338. if (dc.Job.Equals("暂无")) dc.Job = "-";
  16339. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  16340. if (DcList.Count - 1 == i) transStrRes1 += str1;
  16341. else transStrRes1 += $"{str1}|";
  16342. }
  16343. //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";
  16344. string transStrRes = "";
  16345. if (transStrRes1.Length > 0)
  16346. {
  16347. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  16348. }
  16349. //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
  16350. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  16351. //List<string> transArray = new List<string> { };
  16352. List<TranslateInfo> transArray = new List<TranslateInfo>();
  16353. if (transStrRes.Contains("|"))
  16354. {
  16355. string[] transArray1 = transStrRes.Split('|');
  16356. if (transArray1.Length > 0)
  16357. {
  16358. foreach (var item in transArray1)
  16359. {
  16360. if (item.Contains("&"))
  16361. {
  16362. string[] transArray2 = item.Split('&');
  16363. int index = 0;
  16364. string companyName = "", job = "";
  16365. if (transArray2.Length > 0)
  16366. {
  16367. bool success = int.TryParse(transArray2[0].Trim(), out index);
  16368. if (1 < transArray2.Length) companyName = transArray2[1];
  16369. if (2 < transArray2.Length) job = transArray2[2];
  16370. }
  16371. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  16372. }
  16373. }
  16374. }
  16375. }
  16376. //循环赋值
  16377. for (int i = 0; i < DcList.Count; i++)
  16378. {
  16379. string PYName = "";
  16380. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  16381. {
  16382. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  16383. string PY_First = DcList[i].Pinyin.Split('/')[1];
  16384. PYName = PY_First + " " + PY_Last;
  16385. }
  16386. else
  16387. {
  16388. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  16389. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  16390. PYName = PY_First + " " + PY_Last;
  16391. }
  16392. builder.MoveToCell(0, i + 1, 0, 0);
  16393. builder.Write(PYName);
  16394. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  16395. builder.MoveToCell(0, i + 1, 1, 0);
  16396. builder.Write(sex);
  16397. DateTime birthDt;
  16398. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  16399. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  16400. builder.MoveToCell(0, i + 1, 2, 0);
  16401. builder.Write(birthday);
  16402. string company = string.Empty, job = string.Empty;
  16403. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  16404. if (dcTransInfo != null)
  16405. {
  16406. company = dcTransInfo.CompanyName;
  16407. job = dcTransInfo.Job;
  16408. }
  16409. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16410. {
  16411. //查询对照表
  16412. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  16413. if (tempCec != null)
  16414. {
  16415. company = tempCec.enName;
  16416. }
  16417. //翻译
  16418. else
  16419. {
  16420. }
  16421. }
  16422. builder.MoveToCell(0, i + 1, 3, 0);
  16423. builder.Write(company);
  16424. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  16425. {
  16426. //查询对照表
  16427. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  16428. if (tempPec != null)
  16429. {
  16430. job = tempPec.enName;
  16431. }
  16432. //翻译
  16433. else
  16434. {
  16435. }
  16436. }
  16437. builder.MoveToCell(0, i + 1, 4, 0);
  16438. builder.Write(job);
  16439. }
  16440. }
  16441. //删除多余行
  16442. while (tableOne.Rows.Count > DcList.Count + 1)
  16443. {
  16444. tableOne.Rows.RemoveAt(DcList.Count + 1);
  16445. }
  16446. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  16447. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  16448. doc.Save(fileDir);
  16449. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  16450. return Ok(JsonView(true, "操作成功!", Url));
  16451. }
  16452. private class TranslateInfo
  16453. {
  16454. public int Index { get; set; }
  16455. public string CompanyName { get; set; }
  16456. public string Job { get; set; }
  16457. }
  16458. #endregion
  16459. #region 团组倒推表
  16460. /// <summary>
  16461. /// 倒推表基础数据
  16462. /// Init
  16463. /// </summary>
  16464. /// <returns></returns>
  16465. [HttpPost]
  16466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16467. public async Task<IActionResult> PostInvertedListInit()
  16468. {
  16469. var viewData = await _invertedListRep._Init();
  16470. if (viewData.Code != 0)
  16471. {
  16472. return Ok(JsonView(false, viewData.Msg));
  16473. }
  16474. return Ok(JsonView(viewData.Data));
  16475. }
  16476. /// <summary>
  16477. /// 倒推表
  16478. /// Info
  16479. /// </summary>
  16480. /// <param name="dto"></param>
  16481. /// <returns></returns>
  16482. [HttpPost]
  16483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16484. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  16485. {
  16486. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  16487. if (viewData.Code != 0)
  16488. {
  16489. return Ok(JsonView(false, viewData.Msg));
  16490. }
  16491. return Ok(JsonView(viewData.Data));
  16492. }
  16493. /// <summary>
  16494. /// 倒推表
  16495. /// Create
  16496. /// </summary>
  16497. /// <param name="dto"></param>
  16498. /// <returns></returns>
  16499. [HttpPost]
  16500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16501. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  16502. {
  16503. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  16504. if (viewData.Code != 0)
  16505. {
  16506. return Ok(JsonView(false, viewData.Msg));
  16507. }
  16508. return Ok(JsonView(viewData.Data));
  16509. }
  16510. /// <summary>
  16511. /// 倒推表
  16512. /// Update
  16513. /// </summary>
  16514. /// <param name="dto"></param>
  16515. /// <returns></returns>
  16516. [HttpPost]
  16517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16518. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  16519. {
  16520. var viewData = await _invertedListRep._Update(dto);
  16521. if (viewData.Code != 0)
  16522. {
  16523. return Ok(JsonView(false, viewData.Msg));
  16524. }
  16525. return Ok(JsonView(viewData.Data));
  16526. }
  16527. /// <summary>
  16528. /// 倒推表
  16529. /// File Download
  16530. /// </summary>
  16531. /// <param name="dto"></param>
  16532. /// <returns></returns>
  16533. [HttpPost]
  16534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16535. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  16536. {
  16537. var info2 = await _invertedListRep._Info(1, dto.DiId);
  16538. if (info2.Code != 0)
  16539. {
  16540. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  16541. }
  16542. var info1 = info2.Data as InvertedListInfoView;
  16543. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  16544. string teamName = "";
  16545. if (info != null) teamName = info.TeamName;
  16546. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  16547. var doc = new Document();
  16548. var builder = new DocumentBuilder(doc);
  16549. #region old insert
  16550. ////载入模板
  16551. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  16552. //Document doc = new Document(tempPath);
  16553. //DocumentBuilder builder = new DocumentBuilder(doc);
  16554. //利用键值对存放数据
  16555. //Dictionary<string, string> dic = new Dictionary<string, string>();
  16556. //dic.Add("TeamName", teamName);
  16557. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  16558. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  16559. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  16560. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  16561. //dic.Add("SQRemark", info1.ApprovalRemark);
  16562. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  16563. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  16564. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  16565. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  16566. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  16567. //dic.Add("QZRemark", info1.VisaInformationRemark);
  16568. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  16569. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  16570. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  16571. //dic.Add("CQRemark", info1.IssueVisaRemark);
  16572. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  16573. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  16574. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  16575. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  16576. //#region 填充word模板书签内容
  16577. //foreach (var key in dic.Keys)
  16578. //{
  16579. // builder.MoveToBookmark(key);
  16580. // builder.Write(dic[key]);
  16581. //}
  16582. //#endregion
  16583. #endregion
  16584. #region New Insert
  16585. string titleFont = $"仿宋",
  16586. contentFont = $"仿宋";
  16587. var fontColor = Color.FromArgb(64, 64, 64);
  16588. //设置标题 团组名称
  16589. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  16590. builder.Font.Name = titleFont;
  16591. builder.Font.Color = fontColor;
  16592. builder.Font.Size = 12;
  16593. builder.Font.Bold = true;
  16594. builder.Writeln(teamName);
  16595. //设置副标题 团组出访时间
  16596. builder.Font.Size = 12;
  16597. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  16598. builder.Writeln();
  16599. var backgroundColor = Color.FromArgb(199, 199, 199);
  16600. var table = builder.StartTable();
  16601. builder.InsertCell();
  16602. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  16603. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  16604. builder.CellFormat.Borders.LineWidth = 1;
  16605. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  16606. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  16607. builder.RowFormat.Height = 40;
  16608. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  16609. builder.Font.Name = contentFont;
  16610. builder.Font.Size = 12;
  16611. builder.Font.Bold = true;
  16612. builder.Font.Color = fontColor;
  16613. builder.Write("时间");
  16614. builder.InsertCell();
  16615. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  16616. builder.Write("流程");
  16617. builder.InsertCell();
  16618. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  16619. builder.Write("说明");
  16620. builder.EndRow();
  16621. //报批资料准备
  16622. if (info1.IsSelectedAirportd)
  16623. {
  16624. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  16625. }
  16626. //报批/提供送签资料
  16627. if (info1.IsSelectedApprovalData)
  16628. {
  16629. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  16630. }
  16631. //出批件护照办理
  16632. if (info1.IsSelectedIssueApproval)
  16633. {
  16634. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  16635. }
  16636. //签证资料准备
  16637. if (info1.IsSelectedVisaInfo)
  16638. {
  16639. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  16640. }
  16641. //送签
  16642. if (info1.IsSelectedSendVisa)
  16643. {
  16644. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  16645. }
  16646. //出签
  16647. if (info1.IsSelectedIssueVisa)
  16648. {
  16649. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  16650. }
  16651. //机票
  16652. if (info1.IsSelectedAirTicket)
  16653. {
  16654. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  16655. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  16656. }
  16657. //酒店
  16658. if (info1.IsSelectedHotel)
  16659. {
  16660. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  16661. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  16662. }
  16663. //开行前会
  16664. if (info1.IsSelectedPreTripMeeting)
  16665. {
  16666. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  16667. }
  16668. //送机
  16669. if (info1.IsSelectedAirportdDropOff)
  16670. {
  16671. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  16672. }
  16673. builder.EndTable();
  16674. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  16675. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  16676. for (int i = 0; i < table.Rows.Count; i++)
  16677. {
  16678. var row = table.Rows[i];
  16679. //设置宽度
  16680. row.Cells[0].CellFormat.Width = 20.00;
  16681. row.Cells[1].CellFormat.Width = 30.00;
  16682. row.Cells[2].CellFormat.Width = 50.00;
  16683. if (i != 0)
  16684. {
  16685. //边框设置
  16686. InvertedListFileDownloadSetBorders(row.Cells, 0);
  16687. InvertedListFileDownloadSetBorders(row.Cells, 1);
  16688. InvertedListFileDownloadSetBorders(row.Cells, 2);
  16689. }
  16690. }
  16691. #region 页脚插入图片
  16692. // 创建页脚
  16693. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  16694. doc.FirstSection.HeadersFooters.Add(footer);
  16695. Paragraph para = new Paragraph(doc);
  16696. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  16697. footer.AppendChild(para);
  16698. builder.MoveTo(para);
  16699. string imagePath = "./Images/FMGJ_Log.png";
  16700. builder.InsertImage(imagePath);
  16701. #endregion
  16702. #endregion
  16703. var fileDir = AppSettingsHelper.Get("WordBasePath");
  16704. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  16705. string filePath = fileDir + $@"InvertedList/{fileName}";
  16706. doc.Save(filePath);
  16707. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  16708. return Ok(JsonView(true, "操作成功!", Url));
  16709. }
  16710. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime,string content,string reamrk)
  16711. {
  16712. var fontColor = Color.FromArgb(64, 64, 64);
  16713. builder.InsertCell();
  16714. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  16715. builder.RowFormat.Height = 40;
  16716. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  16717. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  16718. builder.Font.Name = fontName;
  16719. builder.Font.Size = 8;
  16720. builder.Font.Bold = true;
  16721. builder.Font.Color = fontColor;
  16722. builder.Write(dateTime);
  16723. builder.InsertCell();
  16724. builder.Font.Size = 9;
  16725. builder.Font.Bold = true;
  16726. builder.Font.Color = fontColor;
  16727. builder.Write(content);
  16728. builder.InsertCell();
  16729. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  16730. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  16731. builder.Font.Size = 9;
  16732. builder.Font.Bold = false;
  16733. builder.Font.Color = fontColor;
  16734. builder.Write(reamrk);
  16735. builder.EndRow();
  16736. }
  16737. private void InvertedListFileDownloadSetBorders(CellCollection cell,int index)
  16738. {
  16739. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  16740. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  16741. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  16742. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  16743. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  16744. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  16745. }
  16746. #endregion
  16747. #region 会务倒推表
  16748. /// <summary>
  16749. /// 会务倒推表
  16750. /// Init
  16751. /// </summary>
  16752. /// <returns></returns>
  16753. [HttpPost]
  16754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16755. public async Task<IActionResult> InforRetrogressTableInit()
  16756. {
  16757. var groupData = await _groupRepository.PostShareGroupInfos(1);
  16758. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  16759. return Ok(JsonView(false, groupData.Msg));
  16760. }
  16761. /// <summary>
  16762. /// 会务倒推表
  16763. /// ExcelDownload
  16764. /// </summary>
  16765. /// <param name="dto"></param>
  16766. /// <returns></returns>
  16767. [HttpPost]
  16768. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  16769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16770. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  16771. {
  16772. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  16773. var validatorRes = await validator.ValidateAsync(dto);
  16774. if (!validatorRes.IsValid)
  16775. {
  16776. StringBuilder sb = new StringBuilder();
  16777. foreach (var item in validatorRes.Errors)
  16778. {
  16779. sb.AppendLine(item.ErrorMessage);
  16780. }
  16781. return Ok(JsonView(false, sb.ToString()));
  16782. }
  16783. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  16784. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  16785. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  16786. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  16787. #region Excel
  16788. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  16789. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  16790. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  16791. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  16792. var fileNamePrefix = string.Empty;
  16793. if (days >= 30)
  16794. {
  16795. tempPath += $"会务工作倒推进度表(30天).xlsx";
  16796. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  16797. }
  16798. else if (days < 30 && days > 7)
  16799. {
  16800. tempPath += $"会务工作倒推进度表(15天).xlsx";
  16801. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  16802. }
  16803. else if (days <= 7)
  16804. {
  16805. tempPath += $"会务工作倒推进度表(7天).xlsx";
  16806. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  16807. }
  16808. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  16809. fileName = CommonFun.ValidFileName(fileName);
  16810. //载入模板
  16811. WorkbookDesigner designer = new WorkbookDesigner();
  16812. designer.Workbook = new Workbook(tempPath);
  16813. designer.Process();
  16814. if (!Directory.Exists(savePath))
  16815. {
  16816. Directory.CreateDirectory(savePath);
  16817. }
  16818. string serverPath = $"{savePath}{fileName}";
  16819. designer.Workbook.Save(serverPath);
  16820. string rst = $"{servicePath}{ftpPath}{fileName}";
  16821. #endregion
  16822. return Ok(JsonView(new { url = rst }));
  16823. }
  16824. #endregion
  16825. #region 三公签证费用(签证费、代办费)
  16826. /// <summary>
  16827. /// 三公签证费用(签证费、代办费)
  16828. /// List
  16829. /// </summary>
  16830. /// <returns></returns>
  16831. [HttpPost]
  16832. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16833. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  16834. {
  16835. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  16836. if (_view.Code != 0)
  16837. {
  16838. return Ok(JsonView(false, _view.Msg));
  16839. }
  16840. return Ok(JsonView(true, "操作成功!", _view.Data));
  16841. }
  16842. /// <summary>
  16843. /// 三公签证费用(签证费、代办费)
  16844. /// Add Or Update
  16845. /// </summary>
  16846. /// <returns></returns>
  16847. [HttpPost]
  16848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16849. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  16850. {
  16851. var _view = await _visaFeeInfoRep._Update(_dto);
  16852. if (_view.Code != 0)
  16853. {
  16854. return Ok(JsonView(false, _view.Msg));
  16855. }
  16856. return Ok(JsonView(true, _view.Msg));
  16857. }
  16858. #endregion
  16859. #region 酒店询价
  16860. /// <summary>
  16861. /// 酒店询价
  16862. /// Init
  16863. /// </summary>
  16864. /// <returns></returns>
  16865. [HttpPost]
  16866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16867. public async Task<IActionResult> PostHotelInquiryInit()
  16868. {
  16869. var res = await _hotelInquiryRep._Init();
  16870. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16871. return Ok(JsonView(true, res.Msg, res.Data));
  16872. }
  16873. /// <summary>
  16874. /// 酒店询价
  16875. /// page Item
  16876. /// </summary>
  16877. /// <param name="_dto"></param>
  16878. /// <returns></returns>
  16879. [HttpPost]
  16880. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16881. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  16882. {
  16883. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  16884. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16885. var view = res.Data as PageDataViewBase;
  16886. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  16887. }
  16888. /// <summary>
  16889. /// 酒店询价
  16890. /// info
  16891. /// </summary>
  16892. /// <param name="_dto"></param>
  16893. /// <returns></returns>
  16894. [HttpPost]
  16895. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16896. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  16897. {
  16898. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  16899. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16900. return Ok(JsonView(true, res.Msg, res.Data));
  16901. }
  16902. /// <summary>
  16903. /// 酒店询价
  16904. /// Add Or Edit
  16905. /// </summary>
  16906. /// <param name="_dto"></param>
  16907. /// <returns></returns>
  16908. [HttpPost]
  16909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16910. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  16911. {
  16912. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  16913. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16914. return Ok(JsonView(true, res.Msg, res.Data));
  16915. }
  16916. /// <summary>
  16917. /// 酒店询价
  16918. /// Del
  16919. /// </summary>
  16920. /// <param name="_dto"></param>
  16921. /// <returns></returns>
  16922. [HttpPost]
  16923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16924. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  16925. {
  16926. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  16927. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16928. return Ok(JsonView(true, res.Msg, res.Data));
  16929. }
  16930. #endregion
  16931. #region 下载匹配op行程单
  16932. /// <summary>
  16933. /// 匹配op行程单
  16934. /// Init
  16935. /// </summary>
  16936. /// <param name="dto">团组列表请求dto</param>
  16937. /// <returns></returns>
  16938. [HttpPost]
  16939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16940. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  16941. {
  16942. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  16943. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  16944. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  16945. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  16946. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  16947. .Where(it => it.IsDel == 0)
  16948. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  16949. .OrderByDescending(it => it.CreateUserId)
  16950. .ToList();
  16951. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  16952. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  16953. var diids = groupInfos.Select(it => it.Id).ToList();
  16954. List<string> countrys = new List<string>();
  16955. foreach (var item in country)
  16956. {
  16957. var data = _groupRepository.FormartTeamName(item);
  16958. var dataArray = _groupRepository.GroupSplitCountry(data);
  16959. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  16960. }
  16961. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  16962. List<string> areaArray = new List<string>(); //GetGroupCityLine
  16963. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  16964. foreach (var item in areaItem)
  16965. {
  16966. string areaStr = item.Value;
  16967. if (!string.IsNullOrEmpty(areaStr))
  16968. {
  16969. string[] str1 = areaStr.Split("-");
  16970. if (str1.Length > 0)
  16971. {
  16972. areaArray.AddRange(str1);
  16973. }
  16974. }
  16975. }
  16976. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  16977. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  16978. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  16979. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  16980. .ToList();
  16981. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  16982. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  16983. .Where(it => countriesIds.Contains(it.Id))
  16984. .Select(it => new { it.Id, Name = it.Name_CN })
  16985. .ToList();
  16986. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  16987. .Select(it => it.TeamName).ToList();
  16988. stopwatch.Stop();
  16989. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  16990. }
  16991. ///// <summary>
  16992. ///// 匹配op行程单
  16993. ///// Init 查询区域数据
  16994. ///// </summary>
  16995. ///// <param name="dto">团组列表请求dto</param>
  16996. ///// <returns></returns>
  16997. //[HttpPost]
  16998. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16999. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  17000. //{
  17001. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17002. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  17003. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  17004. // if (string.IsNullOrEmpty(countriesDataStr))
  17005. // {
  17006. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  17007. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  17008. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  17009. // }
  17010. // else
  17011. // {
  17012. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  17013. // }
  17014. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  17015. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  17016. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  17017. // List<dynamic> childList = new List<dynamic>();
  17018. // int parentId = dto.CountriesId;
  17019. // if (provinceData.Count > 1)
  17020. // {
  17021. // foreach (var item1 in provinceData)
  17022. // {
  17023. // List<dynamic> childList1 = new List<dynamic>();
  17024. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  17025. // foreach (var item2 in citiesData1)
  17026. // {
  17027. // List<dynamic> childList2 = new List<dynamic>();
  17028. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17029. // foreach (var item3 in countiesData1)
  17030. // {
  17031. // childList2.Add(new
  17032. // {
  17033. // id = item3.Id,
  17034. // parentId = item2.Id,
  17035. // level = "district",
  17036. // name = item3.Name_CN,
  17037. // });
  17038. // }
  17039. // childList1.Add(new
  17040. // {
  17041. // id = item2.Id,
  17042. // parentId = item1.Id,
  17043. // level = "city",
  17044. // name = item2.Name_CN,
  17045. // childList = childList2
  17046. // });
  17047. // }
  17048. // childList.Add(new
  17049. // {
  17050. // id = item1.Id,
  17051. // parentId = parentId,
  17052. // level = "province",
  17053. // name = item1.Name_CN,
  17054. // childList = childList1
  17055. // });
  17056. // }
  17057. // //城市
  17058. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  17059. // foreach (var item2 in citiesData2)
  17060. // {
  17061. // List<dynamic> childList22 = new List<dynamic>();
  17062. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17063. // foreach (var item3 in countiesData1)
  17064. // {
  17065. // childList22.Add(new
  17066. // {
  17067. // id = item3.Id,
  17068. // parentId = item2.Id,
  17069. // level = "district",
  17070. // name = item3.Name_CN,
  17071. // });
  17072. // }
  17073. // childList.Add(new
  17074. // {
  17075. // id = item2.Id,
  17076. // parentId = parentId,
  17077. // level = "city",
  17078. // name = item2.Name_CN,
  17079. // childList = childList22
  17080. // });
  17081. // }
  17082. // }
  17083. // else
  17084. // {
  17085. // foreach (var item2 in citiesData)
  17086. // {
  17087. // string cname = item2.Name_CN;
  17088. // List<dynamic> childList1 = new List<dynamic>();
  17089. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17090. // foreach (var item3 in countiesData1)
  17091. // {
  17092. // childList1.Add(new
  17093. // {
  17094. // Id = item3.Id,
  17095. // parentId = item2.Id,
  17096. // level = "district",
  17097. // name = item3.Name_CN
  17098. // });
  17099. // }
  17100. // childList.Add(new
  17101. // {
  17102. // id = item2.Id,
  17103. // parentId = parentId,
  17104. // level = "city",
  17105. // name = item2.Name_CN,
  17106. // childList = childList1
  17107. // });
  17108. // }
  17109. // }
  17110. // stopwatch.Stop();
  17111. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  17112. //}
  17113. /// <summary>
  17114. /// 匹配op行程单
  17115. /// 接团信息列表 Page
  17116. /// </summary>
  17117. /// <param name="dto">团组列表请求dto</param>
  17118. /// <returns></returns>
  17119. [HttpPost]
  17120. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17121. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  17122. {
  17123. var swatch = new Stopwatch();
  17124. swatch.Start();
  17125. #region 参数验证
  17126. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17127. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17128. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17129. #region 页面操作权限验证
  17130. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17131. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  17132. #endregion
  17133. #endregion
  17134. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17135. {
  17136. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  17137. //string sqlWhere = "";
  17138. if (!string.IsNullOrEmpty(dto.Country))
  17139. {
  17140. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  17141. }
  17142. if (!string.IsNullOrEmpty(dto.Area))
  17143. {
  17144. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  17145. }
  17146. if (!string.IsNullOrEmpty(dto.TeamName))
  17147. {
  17148. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  17149. }
  17150. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  17151. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  17152. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  17153. swatch.Stop();
  17154. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  17155. }
  17156. else
  17157. {
  17158. return Ok(JsonView(false, "查询失败"));
  17159. }
  17160. }
  17161. /// <summary>
  17162. /// 匹配op行程单
  17163. /// 行程单下载
  17164. /// </summary>
  17165. /// <param name="dto">团组列表请求dto</param>
  17166. /// <returns></returns>
  17167. [HttpPost]
  17168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17169. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  17170. {
  17171. #region 参数验证
  17172. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17173. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17174. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17175. #region 页面操作权限验证
  17176. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17177. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  17178. #endregion
  17179. #endregion
  17180. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17181. {
  17182. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  17183. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  17184. }
  17185. else
  17186. {
  17187. return Ok(JsonView(false, "下载失败!"));
  17188. }
  17189. }
  17190. #endregion
  17191. #region 国家信息 数据 注释
  17192. //[HttpPost]
  17193. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  17194. //{
  17195. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  17196. // foreach (var item in dto)
  17197. // {
  17198. // infos.Add(new Grp_GroupsTaskAssignment()
  17199. // {
  17200. // DIId = item,
  17201. // CTId = 82,
  17202. // UId = 248,
  17203. // IsEnable = 1,
  17204. // CreateUserId = 233,
  17205. // CreateTime = DateTime.Now,
  17206. // IsDel = 0
  17207. // });
  17208. // infos.Add(new Grp_GroupsTaskAssignment()
  17209. // {
  17210. // DIId = item,
  17211. // CTId = 82,
  17212. // UId = 286,
  17213. // IsEnable = 1,
  17214. // CreateUserId = 233,
  17215. // CreateTime = DateTime.Now,
  17216. // IsDel = 0
  17217. // });
  17218. // }
  17219. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  17220. // return Ok("操作成功");
  17221. //}
  17222. //public class paramJsonDto
  17223. //{
  17224. // public List<CountriesInfo> str { get; set; }
  17225. //}
  17226. //[HttpPost]
  17227. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  17228. //{
  17229. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  17230. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  17231. // List<Sys_Cities> cities = new List<Sys_Cities>();
  17232. // List<Sys_Cities> districts = new List<Sys_Cities>();
  17233. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17234. // _sqlSugar.BeginTran();
  17235. // int countitiesIndex = 0;
  17236. // foreach (var item in dto.str)
  17237. // {
  17238. // dynamic data = item.c;
  17239. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  17240. // if (data != null)
  17241. // {
  17242. // countitiesIndex++;
  17243. // foreach (var item1 in data)
  17244. // {
  17245. // string cnname = item1.cn;
  17246. // string enname = item1.en;
  17247. // Sys_Cities provinceInfo = new Sys_Cities()
  17248. // {
  17249. // CountriesId = countriesId,
  17250. // Name_CN = cnname,
  17251. // Name_EN = enname,
  17252. // ParentId = 0,
  17253. // IsCapital = 1,
  17254. // CreateUserId = 208,
  17255. // CreateTime = DateTime.Now,
  17256. // IsDel = 0
  17257. // };
  17258. // if (item1.lv == "province") //省份
  17259. // {
  17260. // provinceInfo.Level = 1;
  17261. // int provinceId = 0;
  17262. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  17263. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  17264. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17265. // var data1 = item1.c;
  17266. // foreach (var item2 in data1)
  17267. // {
  17268. // if (item2.lv == "city")
  17269. // {
  17270. // string citycnname = item2.cn;
  17271. // string cityenname = item2.en;
  17272. // Sys_Cities cityInfo = new Sys_Cities()
  17273. // {
  17274. // CountriesId = countriesId,
  17275. // ParentId = provinceId,
  17276. // Level = 2,
  17277. // Name_CN = citycnname,
  17278. // Name_EN = cityenname,
  17279. // IsCapital = 1,
  17280. // CreateUserId = 208,
  17281. // CreateTime = DateTime.Now,
  17282. // IsDel = 0
  17283. // };
  17284. // if (item2.c != null)
  17285. // {
  17286. // int cityId = 0;
  17287. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  17288. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17289. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  17290. // foreach (var item3 in item2.c)
  17291. // {
  17292. // if (item3.lv == "district")
  17293. // {
  17294. // var districtInfo = new Sys_Cities()
  17295. // {
  17296. // CountriesId = countriesId,
  17297. // Name_CN = item3.cn,
  17298. // Name_EN = item3.en,
  17299. // Level = 3,
  17300. // ParentId = cityId,
  17301. // IsCapital = 1,
  17302. // CreateUserId = 208,
  17303. // CreateTime = DateTime.Now,
  17304. // IsDel = 0
  17305. // };
  17306. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17307. // //{
  17308. // districts.Add(districtInfo);
  17309. // //}
  17310. // }
  17311. // }
  17312. // }
  17313. // else
  17314. // {
  17315. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  17316. // //{
  17317. // cities.Add(cityInfo);
  17318. // //}
  17319. // }
  17320. // }
  17321. // }
  17322. // }
  17323. // else if (item1.lv == "city")//城市
  17324. // {
  17325. // provinceInfo.Level = 2;
  17326. // if (item1.c != null)
  17327. // {
  17328. // int cityId = 0;
  17329. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  17330. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17331. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17332. // foreach (var item3 in item1.c)
  17333. // {
  17334. // if (item3.lv == "district")
  17335. // {
  17336. // var districtInfo = new Sys_Cities()
  17337. // {
  17338. // CountriesId = countriesId,
  17339. // Name_CN = item3.cn,
  17340. // Name_EN = item3.en,
  17341. // Level = 3,
  17342. // ParentId = cityId,
  17343. // IsCapital = 1,
  17344. // CreateUserId = 208,
  17345. // CreateTime = DateTime.Now,
  17346. // IsDel = 0
  17347. // };
  17348. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17349. // //{
  17350. // districts.Add(districtInfo);
  17351. // //}
  17352. // }
  17353. // }
  17354. // }
  17355. // else
  17356. // {
  17357. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  17358. // //{
  17359. // cities.Add(provinceInfo);
  17360. // //}
  17361. // }
  17362. // }
  17363. // }
  17364. // }
  17365. // }
  17366. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  17367. // cities = cities.Distinct().ToList();
  17368. // districts = districts.Distinct().ToList();
  17369. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  17370. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  17371. // cities.AddRange(districts);
  17372. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  17373. // //_sqlSugar.RollbackTran();
  17374. // _sqlSugar.CommitTran();
  17375. // return Ok(JsonView(false, "操作成功!"));
  17376. //}
  17377. //[HttpPost]
  17378. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  17379. //{
  17380. // List<CountitiesInfo> infos = dto.MyProperty;
  17381. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  17382. // _sqlSugar.BeginTran();
  17383. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17384. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  17385. // foreach (var item in infos)
  17386. // {
  17387. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  17388. // if (countryInfo != null)
  17389. // {
  17390. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  17391. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  17392. // if (cityInfo1 != null)
  17393. // {
  17394. // cityInfo1.IsCapital = 0;
  17395. // cityInfos.Add(cityInfo1);
  17396. // }
  17397. // }
  17398. // }
  17399. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  17400. // .UpdateColumns(it => it.IsCapital)
  17401. // .WhereColumns(it => it.Id)
  17402. // .ExecuteCommand();
  17403. // //_sqlSugar.RollbackTran();
  17404. // _sqlSugar.CommitTran();
  17405. // return Ok(JsonView(false, "操作成功!"));
  17406. //}
  17407. //public class CounrtiesDto
  17408. //{
  17409. // public List<CountitiesInfo> MyProperty { get; set; }
  17410. //}
  17411. //public class CountitiesInfo
  17412. //{
  17413. // /// <summary>
  17414. // /// 圣约翰
  17415. // /// </summary>
  17416. // public string capital_name_chinese { get; set; }
  17417. // /// <summary>
  17418. // ///
  17419. // /// </summary>
  17420. // public string capital_name { get; set; }
  17421. // /// <summary>
  17422. // ///
  17423. // /// </summary>
  17424. // public string country_type { get; set; }
  17425. // /// <summary>
  17426. // /// 安提瓜和巴布达
  17427. // /// </summary>
  17428. // public string country_name_chinese { get; set; }
  17429. // /// <summary>
  17430. // /// 安提瓜和巴布达
  17431. // /// </summary>
  17432. // public string country_name_chinese_short { get; set; }
  17433. // /// <summary>
  17434. // /// 安提瓜和巴布达
  17435. // /// </summary>
  17436. // public string country_name_chinese_UN { get; set; }
  17437. // /// <summary>
  17438. // ///
  17439. // /// </summary>
  17440. // public string country_name_english_abbreviation { get; set; }
  17441. // /// <summary>
  17442. // ///
  17443. // /// </summary>
  17444. // public string country_name_english_formal { get; set; }
  17445. // /// <summary>
  17446. // ///
  17447. // /// </summary>
  17448. // public string country_name_english_UN { get; set; }
  17449. // /// <summary>
  17450. // ///
  17451. // /// </summary>
  17452. // public string continent_name { get; set; }
  17453. // /// <summary>
  17454. // ///
  17455. // /// </summary>
  17456. // public string subregion_name { get; set; }
  17457. // /// <summary>
  17458. // ///
  17459. // /// </summary>
  17460. // public string country_code2 { get; set; }
  17461. // /// <summary>
  17462. // ///
  17463. // /// </summary>
  17464. // public string country_code3 { get; set; }
  17465. // /// <summary>
  17466. // ///
  17467. // /// </summary>
  17468. // public string phone_code { get; set; }
  17469. //}
  17470. //public class CountriesInfo : BasicInfo
  17471. //{
  17472. // public List<CitiesInfo> c { get; set; }
  17473. //}
  17474. //public class CitiesInfo : BasicInfo
  17475. //{
  17476. // public List<AreaInfo> c { get; set; }
  17477. //}
  17478. //public class AreaInfo : BasicInfo
  17479. //{
  17480. // public List<AreaInfo> c { get; set; }
  17481. //}
  17482. //public class BasicInfo
  17483. //{
  17484. // public string code { get; set; }
  17485. // public string cn { get; set; }
  17486. // public string lv { get; set; }
  17487. // public string en { get; set; }
  17488. //}
  17489. #endregion
  17490. #region 查看邀请方
  17491. /// <summary>
  17492. /// 查看邀请方
  17493. /// 邀请方信息 Init
  17494. /// </summary>
  17495. /// <param name="dto"></param>
  17496. /// <returns></returns>
  17497. [HttpPost]
  17498. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17499. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  17500. {
  17501. string sqlWhere = string.Empty;
  17502. if (!string.IsNullOrEmpty(dto.Search))
  17503. {
  17504. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  17505. }
  17506. string sql = string.Format($@"Select
  17507. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  17508. Id,
  17509. UnitName
  17510. From Res_InvitationOfficialActivityData
  17511. Where IsDel = 0
  17512. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  17513. RefAsync<int> total = 0;
  17514. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17515. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  17516. }
  17517. /// <summary>
  17518. /// 查看邀请方
  17519. /// 国家信息 Init
  17520. /// </summary>
  17521. /// <param name="dto"></param>
  17522. /// <returns></returns>
  17523. [HttpPost]
  17524. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17525. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  17526. {
  17527. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  17528. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17529. var diids = groupInfos.Select(it => it.Id).ToList();
  17530. List<string> countrys = new List<string>();
  17531. foreach (var item in country)
  17532. {
  17533. var data = _groupRepository.FormartTeamName(item);
  17534. var dataArray = _groupRepository.GroupSplitCountry(data);
  17535. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17536. }
  17537. countrys = countrys.Distinct().ToList();
  17538. for (int i = 0; i < countrys.Count; i++)
  17539. {
  17540. string item = countrys[i];
  17541. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  17542. {
  17543. countrys.Remove(item);
  17544. i--;
  17545. }
  17546. }
  17547. RefAsync<int> total = 0;
  17548. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  17549. .Where(it => countrys.Contains(it.Name_CN))
  17550. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17551. .Select(it => new { id = it.Id, name = it.Name_CN })
  17552. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17553. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17554. }
  17555. /// <summary>
  17556. /// 查看邀请方
  17557. /// 城市信息 Init
  17558. /// </summary>
  17559. /// <param name="dto"></param>
  17560. /// <returns></returns>
  17561. [HttpPost]
  17562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17563. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  17564. {
  17565. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  17566. RefAsync<int> total = 0;
  17567. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  17568. .Where(it => it.CountriesId == dto.CountiesId)
  17569. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17570. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  17571. .Select(it => new { id = it.Id, name = it.Name_CN })
  17572. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17573. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17574. }
  17575. /// <summary>
  17576. /// 查看邀请方
  17577. /// 团组名称 Init
  17578. /// </summary>
  17579. /// <param name="dto"></param>
  17580. /// <returns></returns>
  17581. [HttpPost]
  17582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17583. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  17584. {
  17585. var watch = new Stopwatch();
  17586. watch.Start();
  17587. RefAsync<int> total = 0;
  17588. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  17589. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  17590. .Where((oa, di) => oa.IsDel == 0)
  17591. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  17592. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  17593. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  17594. .Distinct()
  17595. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17596. watch.Stop();
  17597. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  17598. }
  17599. /// <summary>
  17600. /// 查看邀请方
  17601. /// 团组 & 邀请方信息
  17602. /// </summary>
  17603. /// <param name="dto"></param>
  17604. /// <returns></returns>
  17605. [HttpPost]
  17606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17607. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  17608. {
  17609. var watch = new Stopwatch();
  17610. watch.Start();
  17611. RefAsync<int> total = 0;
  17612. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  17613. .AS("Grp_DelegationInfo")
  17614. .Includes(x => x.InvitingInfos)
  17615. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  17616. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  17617. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  17618. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  17619. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  17620. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  17621. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17622. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  17623. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  17624. infos.ForEach(x =>
  17625. {
  17626. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  17627. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  17628. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  17629. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  17630. });
  17631. watch.Stop();
  17632. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  17633. }
  17634. #endregion
  17635. #region 报批行程
  17636. /// <summary>
  17637. /// 报批行程初始化
  17638. /// </summary>
  17639. /// <param name="dto"></param>
  17640. /// <returns></returns>
  17641. [HttpPost]
  17642. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  17643. {
  17644. const int chiNumber = 5;
  17645. var jw = JsonView(false);
  17646. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  17647. var group = groupList.First();
  17648. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  17649. group = groupList.First(x => x.Id == diid);
  17650. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  17651. .Where(x => x.DiId == diid && x.IsDel == 0)
  17652. .ToArray();
  17653. var count = 1;
  17654. foreach (var item in blackCodeList)
  17655. {
  17656. if (string.IsNullOrWhiteSpace(item.Title))
  17657. {
  17658. item.Title = "未设置名称数据" + count;
  17659. }
  17660. count++;
  17661. };
  17662. if (group == null)
  17663. {
  17664. jw.Msg = "暂无团组!";
  17665. return Ok(jw);
  17666. }
  17667. var data = new
  17668. {
  17669. groupList = groupList.Select(x => new
  17670. {
  17671. x.TeamName,
  17672. x.Id
  17673. }),
  17674. content = new ArrayList(),
  17675. groupInfo = new
  17676. {
  17677. group.VisitDays,
  17678. group.TourCode,
  17679. group.VisitPNumber,
  17680. group.TeamName,
  17681. group.Id,
  17682. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  17683. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  17684. },
  17685. blackCodeList = blackCodeList.Select(x => new
  17686. {
  17687. x.Title,
  17688. x.Id
  17689. }),
  17690. FileTempList = new ArrayList()
  17691. {
  17692. new { Index = 1,FileName = "旧模板" },
  17693. new { Index = 2,FileName = "省外办" },
  17694. new { Index = 3,FileName = "市外办" },
  17695. }
  17696. };
  17697. var resultArr = new ArrayList();
  17698. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  17699. #region 默认不生成行程
  17700. //if (content.Count == 0)
  17701. //{
  17702. // var stay = "-";
  17703. // var cityPath = "-";
  17704. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  17705. // .Where(x => x.DiId == diid && x.IsDel == 0)
  17706. // .ToList();
  17707. // //添加城市路径以及住宿地
  17708. // //黑屏代码数据
  17709. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  17710. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17711. // {
  17712. // jw = JsonView(true, "黑屏代码有误!", data);
  17713. // return Ok(jw);
  17714. // }
  17715. // data = data with
  17716. // {
  17717. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  17718. // {
  17719. // x.Title,
  17720. // x.Id,
  17721. // }).ToArray())
  17722. // };
  17723. // foreach (DataRow row in dtBlack.Rows)
  17724. // {
  17725. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17726. // {
  17727. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  17728. // return Ok(jw);
  17729. // }
  17730. // }
  17731. // //黑屏代码获取时间区间
  17732. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  17733. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  17734. // _sqlSugar.BeginTran();
  17735. // for (int i = 0; i < timeArr.Count; i++)
  17736. // {
  17737. // stay = "-";
  17738. // cityPath = "-";
  17739. // DateTime NewData = DateTime.Parse(timeArr[i]);
  17740. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  17741. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  17742. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  17743. // if (tbSelect.Length > 0)
  17744. // {
  17745. // List<string> threeCodeStr = new List<string>();
  17746. // foreach (var item in tbSelect)
  17747. // {
  17748. // var threeCode = item["Three"].ToString() ?? "";
  17749. // if (threeCode.Length == 6)
  17750. // {
  17751. // var start = threeCode.Substring(0, 3);
  17752. // var end = threeCode.Substring(3, 3);
  17753. // if (threeCodeStr.Count == 0)
  17754. // {
  17755. // threeCodeStr.Add(start);
  17756. // threeCodeStr.Add(end);
  17757. // }
  17758. // else
  17759. // {
  17760. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  17761. // {
  17762. // threeCodeStr.Add(end);
  17763. // }
  17764. // else
  17765. // {
  17766. // threeCodeStr.Add(start);
  17767. // threeCodeStr.Add(end);
  17768. // }
  17769. // }
  17770. // }
  17771. // }
  17772. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  17773. // var last = threeCodeStr.Last();
  17774. // foreach (var item in threeCodeStr)
  17775. // {
  17776. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  17777. // if (item.Equals(last))
  17778. // {
  17779. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  17780. // }
  17781. // }
  17782. // cityPath = cityPath.Trim('-');
  17783. // }
  17784. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  17785. // appro.Diid = diid ?? -1;
  17786. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  17787. // appro.Id = thisId;
  17788. // appro.CreateUserId = dto.UserId;
  17789. // appro.CreateTime = DateTime.Now;
  17790. // content.Add(appro);
  17791. // }
  17792. // _sqlSugar.CommitTran();
  17793. //}
  17794. #endregion
  17795. foreach (var x in content)
  17796. {
  17797. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  17798. if (chiList.Count < chiNumber)
  17799. {
  17800. for (int i = chiList.Count; i < chiNumber; i++)
  17801. {
  17802. chiList.Add(new Grp_ApprovalTravelDetails());
  17803. }
  17804. }
  17805. resultArr.Add(new
  17806. {
  17807. x.Id,
  17808. x.Date,
  17809. x.Diid,
  17810. chiList = chiList.Select(x1 => new
  17811. {
  17812. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  17813. x1.Details,
  17814. x1.ParentId,
  17815. x1.Id
  17816. })
  17817. });
  17818. }
  17819. data = data with
  17820. {
  17821. content = resultArr,
  17822. };
  17823. jw = JsonView(true, "获取成功!", data);
  17824. return Ok(jw);
  17825. }
  17826. /// <summary>
  17827. /// 报批行程删除
  17828. /// </summary>
  17829. /// <param name="dto"></param>
  17830. /// <returns></returns>
  17831. [HttpPost]
  17832. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  17833. {
  17834. var jw = JsonView(false);
  17835. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17836. if (group == null)
  17837. {
  17838. jw.Msg = "团组参数有误!";
  17839. return Ok(jw);
  17840. }
  17841. try
  17842. {
  17843. _sqlSugar.BeginTran();
  17844. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  17845. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  17846. {
  17847. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17848. DeleteUserId = dto.uesrId,
  17849. IsDel = 1
  17850. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  17851. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  17852. {
  17853. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17854. DeleteUserId = dto.uesrId,
  17855. IsDel = 1
  17856. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  17857. _sqlSugar.CommitTran();
  17858. jw = JsonView(true, "删除成功");
  17859. }
  17860. catch (Exception ex)
  17861. {
  17862. jw = JsonView(false, ex.Message);
  17863. }
  17864. return Ok(jw);
  17865. }
  17866. /// <summary>
  17867. /// 报批行程保存
  17868. /// </summary>
  17869. /// <param name="dto"></param>
  17870. /// <returns></returns>
  17871. [HttpPost]
  17872. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  17873. {
  17874. var jw = JsonView(false);
  17875. var Find = dto.Arr.Find(x => x.id == 0);
  17876. if (Find != null)
  17877. {
  17878. jw.Msg = "生成的ID为0!";
  17879. return Ok(jw);
  17880. }
  17881. foreach (var item in dto.Arr)
  17882. {
  17883. foreach (var chi in item.chiList)
  17884. {
  17885. if (chi.parentId == 0)
  17886. {
  17887. chi.parentId = item.id;
  17888. }
  17889. }
  17890. }
  17891. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  17892. _sqlSugar.BeginTran();
  17893. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  17894. {
  17895. var parentIds = dto.Arr.Select(x => x.id).ToList();
  17896. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  17897. {
  17898. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17899. DeleteUserId = dto.UserId,
  17900. IsDel = 1
  17901. }).ExecuteCommand();
  17902. }
  17903. try
  17904. {
  17905. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  17906. {
  17907. CreateTime = DateTime.Now,
  17908. CreateUserId = dto.UserId,
  17909. Details = x.details,
  17910. ParentId = x.parentId,
  17911. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17912. Remark = "",
  17913. IsDel = 0
  17914. }).ToList()).ExecuteCommand();
  17915. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  17916. {
  17917. Id = x.id,
  17918. Details = x.details,
  17919. ParentId = x.parentId,
  17920. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17921. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  17922. {
  17923. Details = x.Details,
  17924. ParentId = x.ParentId,
  17925. Time = x.Time
  17926. }).ExecuteCommand();
  17927. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  17928. {
  17929. Id = x.id,
  17930. Date = x.date,
  17931. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  17932. {
  17933. Date = x.Date
  17934. }).ExecuteCommand();
  17935. _sqlSugar.CommitTran();
  17936. jw = JsonView(true, "保存成功!");
  17937. }
  17938. catch (Exception ex)
  17939. {
  17940. _sqlSugar.RollbackTran();
  17941. jw = JsonView(false, "保存失败!" + ex.Message);
  17942. }
  17943. return Ok(jw);
  17944. }
  17945. /// <summary>
  17946. /// 报批行程生成
  17947. /// </summary>
  17948. /// <param name="dto"></param>
  17949. /// <returns></returns>
  17950. [HttpPost]
  17951. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  17952. {
  17953. var jw = JsonView(false);
  17954. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17955. if (group == null)
  17956. {
  17957. jw.Msg = "暂无该团组!";
  17958. return Ok(jw);
  17959. }
  17960. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  17961. //黑屏代码数据
  17962. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  17963. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17964. {
  17965. jw.Msg = "黑屏代码有误!";
  17966. return Ok(jw);
  17967. }
  17968. foreach (DataRow row in dtBlack.Rows)
  17969. {
  17970. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17971. {
  17972. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  17973. return Ok(jw);
  17974. }
  17975. }
  17976. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  17977. var resultArr = new ArrayList();
  17978. //if (officialActivitiesArr.Count == 0)
  17979. //{
  17980. // jw.Msg = "暂无公务出访信息!";
  17981. // return Ok(jw);
  17982. //}
  17983. try
  17984. {
  17985. _sqlSugar.BeginTran();
  17986. DeleteApprovalJourney(new
  17987. Domain.Dtos.Groups.DeleteApprovalJourney
  17988. {
  17989. Diid = dto.Diid,
  17990. uesrId = dto.Userid
  17991. });
  17992. var stay = "-";
  17993. var cityPath = "-";
  17994. //添加城市路径以及住宿地
  17995. //黑屏代码获取时间区间
  17996. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  17997. var empty = "【未收入该三字码!请机票同事录入】";
  17998. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  17999. for (int i = 0; i < timeArr.Count; i++)
  18000. {
  18001. stay = "-";
  18002. cityPath = "-";
  18003. var chiarr = new List<Grp_ApprovalTravelDetails>();
  18004. DateTime NewData = DateTime.Parse(timeArr[i]);
  18005. //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();
  18006. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18007. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  18008. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  18009. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  18010. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  18011. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  18012. if (tbSelect.Length > 0)
  18013. {
  18014. List<string> threeCodeStr = new List<string>();
  18015. bool isTrade = false;
  18016. string trip = string.Empty;
  18017. var rowLast = tbSelect.Last();
  18018. var rowFirst = tbSelect.First();
  18019. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  18020. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  18021. var takeOffTime = DateTime.Parse(timeArr[i]);
  18022. var fallToTime = DateTime.Parse(timeArr[i]);
  18023. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  18024. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  18025. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  18026. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  18027. foreach (var item in tbSelect)
  18028. {
  18029. var start = string.Empty;
  18030. var end = string.Empty;
  18031. var threeCode = item["Three"].ToString() ?? "";
  18032. if (threeCode.Length == 6)
  18033. {
  18034. start = threeCode.Substring(0, 3);
  18035. end = threeCode.Substring(3, 3);
  18036. if (threeCodeStr.Count == 0)
  18037. {
  18038. threeCodeStr.Add(start);
  18039. threeCodeStr.Add(end);
  18040. }
  18041. else
  18042. {
  18043. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18044. {
  18045. threeCodeStr.Add(end);
  18046. }
  18047. else
  18048. {
  18049. threeCodeStr.Add(start);
  18050. threeCodeStr.Add(end);
  18051. }
  18052. }
  18053. }
  18054. //处理机票信息
  18055. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  18056. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  18057. if (start_Object == null)
  18058. {
  18059. start_Object = new Res_ThreeCode()
  18060. {
  18061. AirPort = empty,
  18062. AirPort_En = empty,
  18063. City = empty,
  18064. Country = empty,
  18065. Four = empty,
  18066. Three = empty,
  18067. };
  18068. }
  18069. if (end_Object == null)
  18070. {
  18071. end_Object = new Res_ThreeCode()
  18072. {
  18073. AirPort = empty,
  18074. AirPort_En = empty,
  18075. City = empty,
  18076. Country = empty,
  18077. Four = empty,
  18078. Three = empty,
  18079. };
  18080. }
  18081. //机型判断
  18082. string airModel = item["AirModel"].ToString();
  18083. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  18084. string flightTime = item["FlightTime"].ToString();
  18085. if (flightTime!.Contains(":"))
  18086. {
  18087. flightTime = flightTime.Replace(":", "小时");
  18088. flightTime += "分钟";
  18089. }
  18090. if (flightTime.Contains("H"))
  18091. {
  18092. flightTime = flightTime.Replace("H", "小时");
  18093. }
  18094. if (flightTime.Contains("M"))
  18095. {
  18096. flightTime = flightTime.Replace("M", "分钟");
  18097. }
  18098. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  18099. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  18100. {
  18101. flightTime = flightDataTime.Hour > 0
  18102. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  18103. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  18104. ? flightDataTime.Minute.ToString() + "分钟" : "";
  18105. }
  18106. //航班号
  18107. string flightcode = item["Fliagtcode"].ToString();
  18108. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  18109. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  18110. if (aircompany == null)
  18111. {
  18112. aircompany = new Res_AirCompany
  18113. {
  18114. CnName = hsEmpty,
  18115. EnName = hsEmpty,
  18116. ShortCode = hsEmpty,
  18117. };
  18118. }
  18119. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  18120. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  18121. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  18122. if (isTrade)
  18123. {
  18124. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  18125. }
  18126. else
  18127. {
  18128. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  18129. }
  18130. }
  18131. chiarr.Add(new Grp_ApprovalTravelDetails
  18132. {
  18133. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  18134. CreateTime = DateTime.Now,
  18135. CreateUserId = dto.Userid,
  18136. ParentId = 0,
  18137. Details = trip
  18138. });
  18139. //添加乘车语句
  18140. chiarr.Add(new Grp_ApprovalTravelDetails
  18141. {
  18142. Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  18143. CreateTime = DateTime.Now,
  18144. CreateUserId = dto.Userid,
  18145. ParentId = 0,
  18146. Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  18147. });
  18148. if (i != timeArr.Count - 1)
  18149. {
  18150. fallToTime = fallToTime.AddHours(2.5);
  18151. foreach (var item in Times)
  18152. {
  18153. //排列公务时间
  18154. if (fallToTime.Hour < item.Item1)
  18155. {
  18156. chiarr.Add(new Grp_ApprovalTravelDetails
  18157. {
  18158. Time = $"{item.Item2} - {item.Item3}",
  18159. CreateTime = DateTime.Now,
  18160. CreateUserId = dto.Userid,
  18161. ParentId = 0,
  18162. Details = "公务活动"
  18163. });
  18164. }
  18165. }
  18166. }
  18167. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18168. var last = threeCodeStr.Last();
  18169. foreach (var item in threeCodeStr)
  18170. {
  18171. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18172. if (item.Equals(last))
  18173. {
  18174. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18175. }
  18176. }
  18177. cityPath = cityPath.Trim('-');
  18178. }
  18179. else
  18180. {
  18181. foreach (var item in Times)
  18182. {
  18183. chiarr.Add(new Grp_ApprovalTravelDetails
  18184. {
  18185. Time = $"{item.Item2} - {item.Item3}",
  18186. CreateTime = DateTime.Now,
  18187. CreateUserId = dto.Userid,
  18188. ParentId = 0,
  18189. Details = "公务活动"
  18190. });
  18191. }
  18192. }
  18193. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18194. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18195. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")"+ "第" + intToString(i + 1) + "天 ";
  18196. appro.Diid = dto.Diid;
  18197. appro.CreateUserId = dto.Userid;
  18198. appro.CreateTime = DateTime.Now;
  18199. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18200. appro.Id = thisId;
  18201. //foreach (var item in gwinfo)
  18202. //{
  18203. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  18204. // chi.Details = "拜访" + item.Client;
  18205. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  18206. // {
  18207. // chi.Details += "," + item.ReqSample;
  18208. // }
  18209. // chi.ParentId = thisId;
  18210. // chi.Time = item.Time;
  18211. // chiarr.Add(chi);
  18212. //}
  18213. if (chiarr.Count < 6)
  18214. {
  18215. for (int j = chiarr.Count; j < 6; j++)
  18216. {
  18217. chiarr.Add(new
  18218. Grp_ApprovalTravelDetails());
  18219. }
  18220. }
  18221. resultArr.Add(new
  18222. {
  18223. appro.Id,
  18224. appro.Date,
  18225. appro.Diid,
  18226. chiList = chiarr.Select(x1 => new
  18227. {
  18228. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18229. x1.Details,
  18230. x1.ParentId,
  18231. x1.Id
  18232. })
  18233. });
  18234. }
  18235. _sqlSugar.CommitTran();
  18236. jw = JsonView(true, "生成成功!", resultArr);
  18237. }
  18238. catch (Exception ex)
  18239. {
  18240. jw.Code = 400;
  18241. jw.Msg = "生成失败!" + ex.Message;
  18242. }
  18243. return Ok(jw);
  18244. }
  18245. /// <summary>
  18246. /// 报批行程word导出
  18247. /// </summary>
  18248. /// <param name="dto"></param>
  18249. /// <returns></returns>
  18250. [HttpPost]
  18251. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  18252. {
  18253. var jw = JsonView(false);
  18254. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18255. if (group == null)
  18256. {
  18257. jw.Msg = "暂无该团组!";
  18258. return Ok(jw);
  18259. }
  18260. //模板路径
  18261. string tempPath = AppSettingsHelper.Get("WordBasePath")+ "Template/";
  18262. var fileName = string.Empty;
  18263. string titleFont = string.Empty,timeFont = string.Empty, contentFont = string.Empty;
  18264. bool bold = false;
  18265. if (dto.FileIndex == 1)
  18266. {
  18267. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  18268. }
  18269. else if (dto.FileIndex == 2)
  18270. {
  18271. fileName = "省外办-报批.docx";
  18272. bold = false;
  18273. titleFont = "方正黑体简体";
  18274. timeFont = "Times New Roman";
  18275. contentFont = "方正仿宋_GBK";
  18276. }
  18277. else if (dto.FileIndex == 3)
  18278. {
  18279. fileName = "市外办-报批.docx";
  18280. titleFont = "方正黑体简体";
  18281. timeFont = "Times New Roman";
  18282. contentFont = "方正仿宋简体";
  18283. }
  18284. tempPath = tempPath + fileName;
  18285. //载入模板
  18286. Document doc = new Document(tempPath);
  18287. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18288. //获取所填表格的序数
  18289. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18290. Aspose.Words.Tables.Row titleRowClone = null;
  18291. Aspose.Words.Tables.Row CenterRowClone = null;
  18292. int index = 0;
  18293. int indexChi = 0;
  18294. int SetIndex = 0;
  18295. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  18296. //获取数据,放到datatable
  18297. foreach (var item in ApprovalTravelArr)
  18298. {
  18299. if (index > 0)
  18300. {
  18301. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  18302. tableOne.AppendChild(titleRowClone);
  18303. }
  18304. var textTime = item.Date;
  18305. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  18306. SetCells(tableOne, doc, SetIndex, 0, textTime,titleFont,bold);
  18307. SetIndex++;
  18308. if (ChiRep.Count > 0)
  18309. {
  18310. foreach (var itemChi in ChiRep)
  18311. {
  18312. var txtTime = itemChi.Time;
  18313. var txtDetail = itemChi.Details;
  18314. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  18315. {
  18316. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  18317. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  18318. //indexChi++;
  18319. //SetIndex++;
  18320. break;
  18321. }
  18322. if (indexChi > 0)
  18323. {
  18324. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18325. tableOne.AppendChild(CenterRowClone);
  18326. }
  18327. SetCells(tableOne, doc, SetIndex, 0, txtTime,timeFont,bold);
  18328. SetCells(tableOne, doc, SetIndex, 1, txtDetail,contentFont, bold);
  18329. indexChi++;
  18330. SetIndex++;
  18331. }
  18332. }
  18333. //else
  18334. //{
  18335. // if (indexChi > 0)
  18336. // {
  18337. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18338. // tableOne.AppendChild(CenterRowClone);
  18339. // }
  18340. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  18341. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  18342. // indexChi++;
  18343. // SetIndex++;
  18344. //}
  18345. index++;
  18346. }
  18347. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  18348. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName,Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18349. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18350. jw.Code = 200;
  18351. jw.Msg = "";
  18352. return Ok(jw);
  18353. }
  18354. private string intToString(int numberVal)
  18355. {
  18356. string numberval = numberVal.ToString();
  18357. Dictionary<char, string> Number = new Dictionary<char, string>();
  18358. Number.Add('1', "一");
  18359. Number.Add('2', "二");
  18360. Number.Add('3', "三");
  18361. Number.Add('4', "四");
  18362. Number.Add('5', "五");
  18363. Number.Add('6', "六");
  18364. Number.Add('7', "七");
  18365. Number.Add('8', "八");
  18366. Number.Add('9', "九");
  18367. string stringNumberVal = string.Empty;
  18368. for (int i = 0; i < numberval.Length; i++)
  18369. {
  18370. if (i == 0)
  18371. {
  18372. stringNumberVal += Number[numberval[i]];
  18373. }
  18374. else if (i >= 1)
  18375. {
  18376. if (numberval[i] == '0')
  18377. {
  18378. stringNumberVal = "十";
  18379. }
  18380. else
  18381. {
  18382. stringNumberVal += "十" + Number[numberval[i]];
  18383. }
  18384. }
  18385. }
  18386. return stringNumberVal;
  18387. }
  18388. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val,string font ,bool bold)
  18389. {
  18390. //获取table中的某个单元格,从0开始
  18391. Cell lshCell = table.Rows[rows].Cells[cells];
  18392. //将单元格中段落移除
  18393. foreach (Paragraph item in lshCell.Paragraphs)
  18394. {
  18395. lshCell.Paragraphs.Remove(item);
  18396. }
  18397. if (val.Contains("\r\n"))
  18398. {
  18399. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  18400. foreach (var item in spArr)
  18401. {
  18402. //新建一个段落
  18403. Paragraph p = new Paragraph(doc);
  18404. var r = new Run(doc, item);
  18405. //设置字体
  18406. if (!string.IsNullOrEmpty(font))
  18407. {
  18408. r.Font.Name = font;
  18409. }
  18410. r.Font.Bold = bold;
  18411. //把设置的值赋给之前新建的段落
  18412. p.AppendChild(r);
  18413. //将此段落加到单元格内
  18414. lshCell.AppendChild(p);
  18415. }
  18416. }
  18417. else
  18418. {
  18419. //新建一个段落
  18420. Paragraph p = new Paragraph(doc);
  18421. var r = new Run(doc, val);
  18422. //设置字体
  18423. if (!string.IsNullOrEmpty(font))
  18424. {
  18425. r.Font.Name = font;
  18426. }
  18427. r.Font.Bold = bold;
  18428. //把设置的值赋给之前新建的段落
  18429. p.AppendChild(r);
  18430. //将此段落加到单元格内
  18431. lshCell.AppendChild(p);
  18432. }
  18433. }
  18434. [HttpPost]
  18435. public async Task<IActionResult> ServerHttp(string paramStr)
  18436. {
  18437. paramStr = paramStr.TrimEnd('\'');
  18438. paramStr = paramStr.TrimStart('\'');
  18439. JsonView jw = JsonView(false);
  18440. JObject param = JObject.Parse(paramStr);
  18441. if (!param.ContainsKey("url"))
  18442. {
  18443. jw.Msg = "url null";
  18444. return Ok(jw);
  18445. }
  18446. string url = param["url"]!.ToString();
  18447. var methon = "get";
  18448. Dictionary<string, string> headValues = null;
  18449. string bodyStr = string.Empty;
  18450. if (param.ContainsKey("methon"))
  18451. {
  18452. methon = param["methon"]!.ToString().ToLower();
  18453. }
  18454. if (param.ContainsKey("header"))
  18455. {
  18456. var header = param["header"]!.ToString();
  18457. JObject headerJobject = JObject.Parse(header);
  18458. headValues = new Dictionary<string, string>();
  18459. foreach (JProperty item in headerJobject.Properties())
  18460. {
  18461. var value = item.Value.ToString();
  18462. var head = item.Path;
  18463. headValues.Add(head, value);
  18464. }
  18465. }
  18466. HttpClient client = new HttpClient();
  18467. string responseString = string.Empty;
  18468. StringContent content = null;
  18469. if (headValues != null)
  18470. {
  18471. foreach (var item in headValues.Keys)
  18472. {
  18473. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  18474. {
  18475. if (param.ContainsKey("body"))
  18476. {
  18477. bodyStr = param["body"]!.ToString();
  18478. }
  18479. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  18480. }
  18481. else
  18482. {
  18483. client.DefaultRequestHeaders.Add(item, headValues[item]);
  18484. }
  18485. }
  18486. }
  18487. try
  18488. {
  18489. if (methon == "get")
  18490. {
  18491. responseString = await client.GetStringAsync(url);
  18492. }
  18493. else if (methon == "post")
  18494. {
  18495. var request = new HttpRequestMessage(HttpMethod.Post, url)
  18496. {
  18497. Content = content
  18498. };
  18499. var response = await client.SendAsync(request);
  18500. try
  18501. {
  18502. Stream responseStream = await response.Content.ReadAsStreamAsync();
  18503. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  18504. {
  18505. using (StreamReader reader = new StreamReader(gzipStream))
  18506. {
  18507. responseString = await reader.ReadToEndAsync();
  18508. }
  18509. }
  18510. }
  18511. catch (Exception)
  18512. {
  18513. responseString = await response.Content.ReadAsStringAsync();
  18514. }
  18515. }
  18516. else
  18517. {
  18518. responseString = "methon error";
  18519. }
  18520. jw = JsonView(true, "success", responseString);
  18521. }
  18522. catch (Exception ex)
  18523. {
  18524. jw.Msg = "error " + ex.Message;
  18525. jw.Data = ex.StackTrace;
  18526. }
  18527. finally
  18528. {
  18529. client.Dispose();
  18530. }
  18531. return Ok(jw);
  18532. }
  18533. #endregion
  18534. #region 团组接待意见调查
  18535. /// <summary>
  18536. /// 团组接待意见调查 - 信息管理
  18537. /// 基础数据(团组)
  18538. /// </summary>
  18539. /// <returns></returns>
  18540. [HttpGet]
  18541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18542. public async Task<IActionResult> OpinionaireInit()
  18543. {
  18544. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  18545. .Select(x => new
  18546. {
  18547. x.Id,
  18548. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  18549. })
  18550. .OrderByDescending(x => x.Id)
  18551. .ToListAsync();
  18552. return Ok(JsonView(groupData, groupData.Count));
  18553. }
  18554. /// <summary>
  18555. /// 团组接待意见调查 - 信息管理
  18556. /// 列表
  18557. /// </summary>
  18558. /// <param name="groupId"></param>
  18559. /// <returns></returns>
  18560. [HttpGet("{groupId}")]
  18561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18562. public async Task<IActionResult> OpinionaireManageList(int groupId)
  18563. {
  18564. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18565. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  18566. .Select(x => new
  18567. {
  18568. x.Id,
  18569. x.TourGuideName,
  18570. x.CityName,
  18571. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  18572. x.CreateTime
  18573. })
  18574. .OrderBy(x => x.Id)
  18575. .ToListAsync();
  18576. return Ok(JsonView(data));
  18577. }
  18578. /// <summary>
  18579. /// 团组接待意见调查 - 信息管理
  18580. /// 保存
  18581. /// </summary>
  18582. /// <param name="dto"></param>
  18583. /// <returns></returns>
  18584. [HttpPost]
  18585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18586. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  18587. {
  18588. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18589. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18590. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18591. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  18592. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  18593. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  18594. _opinionaireRep.BeginTran();
  18595. if (addData != null && addData.Count > 0)
  18596. {
  18597. foreach (var item in addData)
  18598. {
  18599. item.CreateUserId = currUserInfo.UserId;
  18600. item.DiId = dto.DiId;
  18601. }
  18602. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  18603. }
  18604. if (updData != null && updData.Count > 0)
  18605. {
  18606. var upd = await _opinionaireRep._sqlSugar
  18607. .Updateable(updData)
  18608. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  18609. .WhereColumns(x => new { x.Id })
  18610. .ExecuteCommandAsync();
  18611. }
  18612. _opinionaireRep.CommitTran();
  18613. return Ok(JsonView("操作成功!"));
  18614. }
  18615. /// <summary>
  18616. /// 团组接待意见调查 - 信息管理
  18617. /// 删除
  18618. /// </summary>
  18619. /// <param name="id"></param>
  18620. /// <returns></returns>
  18621. [HttpDelete("{id}")]
  18622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18623. public async Task<IActionResult> OpinionaireManageDel(int id)
  18624. {
  18625. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18626. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18627. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  18628. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  18629. if (!del) return Ok(JsonView("操作失败!"));
  18630. return Ok(JsonView("操作成功!"));
  18631. }
  18632. /// <summary>
  18633. /// 团组接待意见调查 - 用户
  18634. /// 列表
  18635. /// </summary>
  18636. /// <param name="diId"></param>
  18637. /// <returns></returns>
  18638. [HttpGet("{diId}")]
  18639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18640. public async Task<IActionResult> OpinionaireUserList(int diId)
  18641. {
  18642. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18643. var sql = string.Format(@"
  18644. SELECT
  18645. o.Id,
  18646. o.DiId,
  18647. di.TeamName AS 'GroupName',
  18648. di.VisitPNumber AS 'PeopleNumber',
  18649. di.ClientName AS 'LeadGroup',
  18650. di.VisitCountry AS 'Travel',
  18651. di.VisitDays AS 'Days',
  18652. o.CityName,
  18653. o.TourGuideName,
  18654. o.Catering,
  18655. o.CateringReason,
  18656. o.Stay,
  18657. o.StayReason,
  18658. o.[Route],
  18659. o.RouteReason,
  18660. o.OfficialActivity,
  18661. o.OfficialActivityReason,
  18662. o.TourGuide,
  18663. o.TourGuideReason,
  18664. o.[Translate],
  18665. o.TranslateReason,
  18666. o.Trip,
  18667. o.TripReason,
  18668. o.ESFileName,
  18669. o.SignatureDate,
  18670. o.Remark
  18671. FROM
  18672. Grp_Opinionaire o
  18673. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  18674. WHERE
  18675. o.IsDel = 0
  18676. AND o.DiId = {0}
  18677. ORDER BY
  18678. o.Id ASC", diId);
  18679. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  18680. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  18681. return Ok(JsonView(data));
  18682. }
  18683. /// <summary>
  18684. /// 团组接待意见调查 - 用户
  18685. /// 保存
  18686. /// </summary>
  18687. /// <param name="dto"></param>
  18688. /// <returns></returns>
  18689. [HttpPost]
  18690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18691. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  18692. {
  18693. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  18694. foreach (var item in dto)
  18695. {
  18696. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  18697. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  18698. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  18699. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  18700. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  18701. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  18702. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  18703. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  18704. }
  18705. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  18706. if (!Directory.Exists(filePathBase))
  18707. {
  18708. Directory.CreateDirectory(filePathBase);
  18709. }
  18710. #region 上传文件
  18711. var filePaths = new List<string>();
  18712. foreach (var item in dto)
  18713. {
  18714. var file = item.File;
  18715. // 将文件保存到指定位置
  18716. var filePath = Path.Combine(filePathBase, file.FileName);
  18717. using (var stream = new FileStream(filePath, FileMode.Create))
  18718. {
  18719. await file.CopyToAsync(stream);
  18720. }
  18721. //验证文件是否上传成功
  18722. if (!System.IO.File.Exists(filePath))
  18723. {
  18724. foreach (var filePathStr in filePaths)
  18725. {
  18726. System.IO.File.Delete(filePathStr);
  18727. }
  18728. return Ok(JsonView(false, "文件上传失败!"));
  18729. }
  18730. item.ESFileName = file.FileName;
  18731. }
  18732. #endregion
  18733. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  18734. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  18735. .UpdateColumns(x => new
  18736. {
  18737. x.Catering,
  18738. x.CateringReason,
  18739. x.Stay,
  18740. x.StayReason,
  18741. x.Route,
  18742. x.RouteReason,
  18743. x.OfficialActivity,
  18744. x.OfficialActivityReason,
  18745. x.TourGuide,
  18746. x.TourGuideReason,
  18747. x.Translate,
  18748. x.TranslateReason,
  18749. x.Trip,
  18750. x.TripReason,
  18751. x.ESFileName,
  18752. x.SignatureDate,
  18753. x.Remark
  18754. })
  18755. .WhereColumns(x => new { x.Id })
  18756. .ExecuteCommandAsync();
  18757. if (upd < 1)
  18758. {
  18759. foreach (var filePathStr in filePaths)
  18760. {
  18761. System.IO.File.Delete(filePathStr);
  18762. }
  18763. return Ok(JsonView(false));
  18764. }
  18765. return Ok(JsonView(true));
  18766. }
  18767. #endregion
  18768. #region 团组餐厅相关信息
  18769. /// <summary>
  18770. /// 团组相关餐厅信息
  18771. /// 基础数据(团组)
  18772. /// </summary>
  18773. /// <returns></returns>
  18774. [HttpGet]
  18775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18776. public async Task<IActionResult> RestaurantInit()
  18777. {
  18778. return Ok(await _restaurantRep.InitAsync());
  18779. }
  18780. /// <summary>
  18781. /// 团组相关餐厅信息
  18782. /// Item
  18783. /// </summary>
  18784. /// <param name="dto"></param>
  18785. /// <returns></returns>
  18786. [HttpPost]
  18787. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18788. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  18789. {
  18790. int portType = dto.PortType,
  18791. groupId = dto.GroupId;
  18792. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18793. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18794. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  18795. }
  18796. /// <summary>
  18797. /// 团组相关餐厅信息
  18798. /// List
  18799. /// </summary>
  18800. /// <param name="dto"></param>
  18801. /// <returns></returns>
  18802. [HttpPost]
  18803. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18804. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  18805. {
  18806. int portType = dto.PortType,
  18807. groupId = dto.GroupId;
  18808. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18809. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18810. var sql = string.Format(@" SELECT
  18811. ri.Id,
  18812. ri.GroupId,
  18813. ri.Date,
  18814. ri.StartTime,
  18815. ri.EndTime,
  18816. CASE WHEN ri.Type = 1 THEN '早餐'
  18817. WHEN ri.Type = 2 THEN '午餐'
  18818. WHEN ri.Type = 3 THEN '晚餐'
  18819. ELSE '其他'
  18820. END AS 'Type',
  18821. ri.Name,
  18822. ri.Address,
  18823. ri.Tel,
  18824. ri.Remark,
  18825. ri.CreateTime,
  18826. u.CnName AS CreateUserName
  18827. FROM
  18828. Grp_RestaurantInfo ri
  18829. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  18830. WHERE
  18831. ri.IsDel = 0
  18832. AND ri.GroupId = {0}
  18833. ORDER BY
  18834. ri.Date ASC
  18835. ", groupId);
  18836. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  18837. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  18838. return Ok(JsonView(infos));
  18839. }
  18840. /// <summary>
  18841. /// 团组相关餐厅信息
  18842. /// Info
  18843. /// </summary>
  18844. /// <param name="dto"></param>
  18845. /// <returns></returns>
  18846. [HttpPost]
  18847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18848. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  18849. {
  18850. int portType = dto.PortType,
  18851. id = dto.Id;
  18852. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18853. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18854. return Ok(await _restaurantRep.InfoAsync(portType, id));
  18855. }
  18856. /// <summary>
  18857. /// 团组相关餐厅信息
  18858. /// Op
  18859. /// </summary>
  18860. /// <param name="dto"></param>
  18861. /// <returns></returns>
  18862. [HttpPost]
  18863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18864. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  18865. {
  18866. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18867. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18868. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  18869. return Ok(await _restaurantRep.OpAsync(dto));
  18870. }
  18871. /// <summary>
  18872. /// 团组相关餐厅信息
  18873. /// Del
  18874. /// </summary>
  18875. /// <param name="dto"></param>
  18876. /// <returns></returns>
  18877. [HttpPost]
  18878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18879. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  18880. {
  18881. int userId = dto.DeleteUserId;
  18882. var id = dto.Id;
  18883. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18884. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18885. return Ok(await _restaurantRep.DelAsync(dto));
  18886. }
  18887. #endregion
  18888. // /// <summary>
  18889. // ///
  18890. // /// </summary>
  18891. // /// <param name="_dto"></param>
  18892. // /// <returns></returns>
  18893. // [HttpPost]
  18894. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18895. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18896. // {
  18897. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18898. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  18899. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  18900. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18901. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  18902. // dic_psg.Add("客人", 974);
  18903. // dic_psg.Add("司机", 975);
  18904. // dic_psg.Add("导游", 976);
  18905. // dic_psg.Add("公司内部人员", 977);
  18906. // dic_psg.Add("司机/导游/公司内部人员", 978);
  18907. // foreach (var item in list_visa)
  18908. // {
  18909. // Grp_VisaInfo temp = new Grp_VisaInfo();
  18910. // temp.Id = item.Id;
  18911. // temp.DIId = item.DIId;
  18912. // temp.VisaClient = item.VisaClient;
  18913. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  18914. // temp.VisaCurrency = item.VisaCurrency;
  18915. // temp.IsThird = item.IsThird;
  18916. // if (dic_psg.ContainsKey(item.PassengerType))
  18917. // {
  18918. // temp.PassengerType = dic_psg[item.PassengerType];
  18919. // }
  18920. // else {
  18921. // temp.PassengerType = -1;
  18922. // }
  18923. // temp.VisaNumber = item.VisaNumber;
  18924. // temp.VisaFreeNumber = item.VisaFreeNumber;
  18925. // temp.CreateUserId = item.Operators;
  18926. // DateTime dt_ct;
  18927. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  18928. // if (b_ct)
  18929. // {
  18930. // temp.CreateTime = dt_ct;
  18931. // }
  18932. // else
  18933. // {
  18934. // temp.CreateTime = DateTime.Now;
  18935. // }
  18936. // temp.DeleteTime = "";
  18937. // temp.DeleteUserId = 0;
  18938. // temp.Remark = item.Remark;
  18939. // if (string.IsNullOrEmpty(temp.Remark)) {
  18940. // temp.Remark = "";
  18941. // }
  18942. // temp.IsDel = item.IsDel;
  18943. // temp.VisaDescription = item.VisaAttachment;
  18944. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  18945. //([Id]
  18946. // ,[DIId]
  18947. // ,[VisaClient]
  18948. // ,[VisaPrice]
  18949. // ,[VisaCurrency]
  18950. // ,[IsThird]
  18951. // ,[PassengerType]
  18952. // ,[VisaNumber]
  18953. // ,[VisaFreeNumber]
  18954. // ,[CreateUserId]
  18955. // ,[CreateTime]
  18956. // ,[DeleteTime]
  18957. // ,[DeleteUserId]
  18958. // ,[Remark]
  18959. // ,[IsDel]
  18960. // ,[visaDescription])
  18961. // VALUES
  18962. // ({0},{1},'{2}',{3},{4}
  18963. //,{5},{6},{7},{8},{9}
  18964. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  18965. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  18966. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  18967. //);
  18968. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  18969. // }
  18970. // return Ok(JsonView(true, "操作成功!"));
  18971. // }
  18972. /// <summary>
  18973. /// 123132123
  18974. /// </summary>
  18975. /// <param name="_dto"></param>
  18976. /// <returns></returns>
  18977. [HttpPost]
  18978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18979. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18980. {
  18981. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18982. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  18983. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  18984. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18985. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  18986. dicDetail.Add(789, 1034);
  18987. dicDetail.Add(790, 1035);
  18988. dicDetail.Add(791, 1036);
  18989. dicDetail.Add(792, 1037);
  18990. dicDetail.Add(793, 1038);
  18991. dicDetail.Add(794, 1039);
  18992. dicDetail.Add(795, 1040);
  18993. dicDetail.Add(796, 1041);
  18994. dicDetail.Add(797, 1042);
  18995. dicDetail.Add(798, 1043);
  18996. dicDetail.Add(801, 1044);
  18997. dicDetail.Add(802, 1045);
  18998. dicDetail.Add(803, 1046);
  18999. Dictionary<int, int> dic = new Dictionary<int, int>();
  19000. dic.Add(806, 1027);
  19001. dic.Add(807, 1028);
  19002. dic.Add(808, 1029);
  19003. dic.Add(809, 1030);
  19004. dic.Add(810, 1031);
  19005. dic.Add(811, 1032);
  19006. dic.Add(812, 1033);
  19007. foreach (var item in list_visa)
  19008. {
  19009. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  19010. temp.Coefficient = item.coefficient;
  19011. DateTime dtCrt;
  19012. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  19013. if (b1)
  19014. {
  19015. temp.CreateTime = dtCrt;
  19016. }
  19017. else
  19018. {
  19019. temp.CreateTime = DateTime.Now;
  19020. }
  19021. temp.CreateUserId = item.Operators;
  19022. temp.DeleteTime = "";
  19023. temp.DeleteUserId = 0;
  19024. temp.DiId = int.Parse(item.DIID);
  19025. temp.FilePath = item.FilePath;
  19026. temp.IsDel = item.IsDel;
  19027. temp.Price = item.Price;
  19028. temp.PriceCount = 1;
  19029. temp.PriceCurrency = item.Currency;
  19030. int detailId = 0;
  19031. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  19032. {
  19033. detailId = dicDetail[item.PriceTypeDetail];
  19034. }
  19035. temp.PriceDetailType = detailId;
  19036. temp.PriceDt = DateTime.Now;
  19037. temp.PriceName = item.PriceName;
  19038. temp.PriceSum = item.Price;
  19039. int tid = 0;
  19040. if (dic.ContainsKey(item.PriceType))
  19041. {
  19042. tid = dic[item.PriceType];
  19043. }
  19044. temp.PriceType = tid;
  19045. temp.Remark = item.Remark;
  19046. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  19047. }
  19048. return Ok(JsonView(true, "操作成功!"));
  19049. }
  19050. [HttpPost]
  19051. public IActionResult TimeTest()
  19052. {
  19053. var jw = JsonView(false, "error");
  19054. _sqlSugar.BeginTran();
  19055. try
  19056. {
  19057. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  19058. .Select(x => new Crm_NewClientData
  19059. {
  19060. Id = x.Id,
  19061. Client = x.Client,
  19062. Contact = x.Contact,
  19063. Location = x.Location,
  19064. })
  19065. .ToList();
  19066. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  19067. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  19068. Stopwatch stopwatch = new Stopwatch();
  19069. // 开始计时
  19070. stopwatch.Start();
  19071. foreach (var item in clientList)
  19072. {
  19073. EncryptionProcessor.DecryptProperties(item);
  19074. }
  19075. stopwatch.Stop();
  19076. jw.Code = 200;
  19077. jw.Data = stopwatch.ElapsedMilliseconds;
  19078. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  19079. }
  19080. catch (Exception ex)
  19081. {
  19082. jw.Code = 400;
  19083. jw.Msg = ex.Message;
  19084. }
  19085. return Ok(jw);
  19086. }
  19087. }
  19088. }