GroupsController.cs 1020 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046
  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 Quartz.Util;
  36. using SqlSugar.Extensions;
  37. using System.Collections;
  38. using System.Data;
  39. using System.Diagnostics;
  40. using System.Globalization;
  41. using System.IO.Compression;
  42. using TencentCloud.Ocr.V20181119.Models;
  43. using static OASystem.API.OAMethodLib.JWTHelper;
  44. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  45. using Bookmark = Aspose.Words.Bookmark;
  46. using Cell = Aspose.Words.Tables.Cell;
  47. using Table = Aspose.Words.Tables.Table;
  48. namespace OASystem.API.Controllers
  49. {
  50. /// <summary>
  51. /// 团组相关
  52. /// </summary>
  53. //[Authorize]
  54. [Route("api/[controller]/[action]")]
  55. public class GroupsController : ControllerBase
  56. {
  57. private readonly ILogger<GroupsController> _logger;
  58. private readonly GrpScheduleRepository _grpScheduleRep;
  59. private readonly IMapper _mapper;
  60. private readonly DelegationInfoRepository _groupRepository;
  61. private readonly TaskAssignmentRepository _taskAssignmentRep;
  62. private readonly AirTicketResRepository _airTicketResRep;
  63. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  64. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  65. private readonly DelegationEnDataRepository _delegationEnDataRep;
  66. private readonly DelegationVisaRepository _delegationVisaRep;
  67. private readonly VisaPriceRepository _visaPriceRep;
  68. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  69. private readonly HotelPriceRepository _hotelPriceRep;
  70. private readonly CustomersRepository _customersRep;
  71. private readonly MessageRepository _message;
  72. private readonly SqlSugarClient _sqlSugar;
  73. private readonly TourClientListRepository _tourClientListRep;
  74. private readonly TeamRateRepository _teamRateRep;
  75. #region 成本相关
  76. private readonly CheckBoxsRepository _checkBoxs;
  77. private readonly GroupCostRepository _GroupCostRepository;
  78. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  79. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  80. #endregion
  81. private readonly SetDataRepository _setDataRep;
  82. private string url;
  83. private string path;
  84. private readonly EnterExitCostRepository _enterExitCostRep;
  85. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  86. private readonly UsersRepository _usersRep;
  87. private readonly IJuHeApiService _juHeApi;
  88. private readonly InvertedListRepository _invertedListRep;
  89. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  90. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  91. private readonly ThreeCodeRepository _threeCodeRepository;
  92. private readonly HotelInquiryRepository _hotelInquiryRep;
  93. private readonly FeeAuditRepository _feeAuditRep;
  94. private readonly VisaCommissionRepository _visaCommissionRep;
  95. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  96. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  97. private readonly List<CurrencyInfo> _currencyInit;
  98. private readonly List<int> _portTypeData;
  99. private readonly TableOperationRecordRepository _tableorRep;
  100. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  101. private readonly RestaurantRepository _restaurantRep;
  102. /// <summary>
  103. /// 构造函数
  104. /// </summary>
  105. /// <param name="logger"></param>
  106. /// <param name="mapper"></param>
  107. /// <param name="hubContext"></param>
  108. /// <param name="sqlSugar"></param>
  109. /// <param name="grpScheduleRep"></param>
  110. /// <param name="groupRepository"></param>
  111. /// <param name="taskAssignmentRep"></param>
  112. /// <param name="airTicketResRep"></param>
  113. /// <param name="decreasePaymentsRep"></param>
  114. /// <param name="InvitationOfficialActivitiesRep"></param>
  115. /// <param name="delegationEnDataRep"></param>
  116. /// <param name="enterExitCostRep"></param>
  117. /// <param name="delegationVisaRep"></param>
  118. /// <param name="message"></param>
  119. /// <param name="visaPriceRep"></param>
  120. /// <param name="carTouristGuideGroundRep"></param>
  121. /// <param name="checkBoxs"></param>
  122. /// <param name="GroupCostRepository"></param>
  123. /// <param name="CostTypeHotelNumberRepository"></param>
  124. /// <param name="GroupCostParameterRepository"></param>
  125. /// <param name="hotelPriceRep"></param>
  126. /// <param name="customersRep"></param>
  127. /// <param name="setDataRep"></param>
  128. /// <param name="tourClientListRep"></param>
  129. /// <param name="teamRateRep"></param>
  130. /// <param name="usersRep"></param>
  131. /// <param name="juHeApi"></param>
  132. /// <param name="invertedListRep"></param>
  133. /// <param name="visaFeeInfoRep"></param>
  134. /// <param name="ticketBlackCodeRep"></param>
  135. /// <param name="hotelInquiryRep"></param>
  136. /// <param name="threeCodeRepository"></param>
  137. /// <param name="feeAuditRep"></param>
  138. /// <param name="visaCommissionRep"></param>
  139. /// <param name="ffrRep"></param>
  140. /// <param name="opinionaireRep"></param>
  141. /// <param name="tableorRep"></param>
  142. /// <param name="enterExitCostDraftRep"></param>
  143. /// <param name="restaurantRep"></param>
  144. public GroupsController(
  145. ILogger<GroupsController> logger,
  146. IMapper mapper,
  147. IHubContext<ChatHub, IChatClient> hubContext,
  148. SqlSugarClient sqlSugar,
  149. GrpScheduleRepository grpScheduleRep,
  150. DelegationInfoRepository groupRepository,
  151. TaskAssignmentRepository taskAssignmentRep,
  152. AirTicketResRepository airTicketResRep,
  153. DecreasePaymentsRepository decreasePaymentsRep,
  154. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  155. DelegationEnDataRepository delegationEnDataRep,
  156. EnterExitCostRepository enterExitCostRep,
  157. DelegationVisaRepository delegationVisaRep,
  158. MessageRepository message,
  159. VisaPriceRepository visaPriceRep,
  160. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  161. CheckBoxsRepository checkBoxs,
  162. GroupCostRepository GroupCostRepository,
  163. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  164. GroupCostParameterRepository GroupCostParameterRepository,
  165. HotelPriceRepository hotelPriceRep,
  166. CustomersRepository customersRep,
  167. SetDataRepository setDataRep,
  168. TourClientListRepository tourClientListRep,
  169. TeamRateRepository teamRateRep,
  170. UsersRepository usersRep, IJuHeApiService juHeApi,
  171. InvertedListRepository invertedListRep,
  172. VisaFeeInfoRepository visaFeeInfoRep,
  173. TicketBlackCodeRepository ticketBlackCodeRep,
  174. HotelInquiryRepository hotelInquiryRep,
  175. ThreeCodeRepository threeCodeRepository,
  176. FeeAuditRepository feeAuditRep,
  177. VisaCommissionRepository visaCommissionRep,
  178. ForeignReceivablesRepository ffrRep,
  179. OpinionaireRepository opinionaireRep,
  180. TableOperationRecordRepository tableorRep,
  181. EnterExitCostDraftRepository enterExitCostDraftRep,
  182. RestaurantRepository restaurantRep
  183. )
  184. {
  185. _logger = logger;
  186. _mapper = mapper;
  187. _grpScheduleRep = grpScheduleRep;
  188. _groupRepository = groupRepository;
  189. _taskAssignmentRep = taskAssignmentRep;
  190. _airTicketResRep = airTicketResRep;
  191. _sqlSugar = sqlSugar;
  192. url = AppSettingsHelper.Get("ExcelBaseUrl");
  193. path = AppSettingsHelper.Get("ExcelBasePath");
  194. if (!System.IO.Directory.Exists(path))
  195. {
  196. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  197. }
  198. _decreasePaymentsRep = decreasePaymentsRep;
  199. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  200. _delegationEnDataRep = delegationEnDataRep;
  201. _enterExitCostRep = enterExitCostRep;
  202. _delegationVisaRep = delegationVisaRep;
  203. _message = message;
  204. _visaPriceRep = visaPriceRep;
  205. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  206. _checkBoxs = checkBoxs;
  207. _GroupCostRepository = GroupCostRepository;
  208. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  209. _GroupCostParameterRepository = GroupCostParameterRepository;
  210. _hotelPriceRep = hotelPriceRep;
  211. _customersRep = customersRep;
  212. _setDataRep = setDataRep;
  213. _tourClientListRep = tourClientListRep;
  214. _teamRateRep = teamRateRep;
  215. _hubContext = hubContext;
  216. _usersRep = usersRep;
  217. _juHeApi = juHeApi;
  218. _invertedListRep = invertedListRep;
  219. _visaFeeInfoRep = visaFeeInfoRep;
  220. _ticketBlackCodeRep = ticketBlackCodeRep;
  221. _hotelInquiryRep = hotelInquiryRep;
  222. _threeCodeRepository = threeCodeRepository;
  223. _feeAuditRep = feeAuditRep;
  224. _visaCommissionRep = visaCommissionRep;
  225. _ffrRep = ffrRep;
  226. _opinionaireRep = opinionaireRep;
  227. _currencyInit = new List<CurrencyInfo>()
  228. {
  229. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  230. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  231. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  232. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  233. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  234. };
  235. _portTypeData = new List<int>() { 2, 3 };
  236. _tableorRep = tableorRep;
  237. _enterExitCostDraftRep = enterExitCostDraftRep;
  238. _restaurantRep = restaurantRep;
  239. }
  240. #region 流程管控
  241. /// <summary>
  242. /// 获取团组流程管控信息
  243. /// </summary>
  244. /// <param name="_jsonDto"></param>
  245. /// <returns></returns>
  246. [HttpPost]
  247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  248. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  249. {
  250. if (string.IsNullOrEmpty(_jsonDto.Paras))
  251. {
  252. return Ok(JsonView(false, "参数为空"));
  253. }
  254. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  255. if (_ScheduleDto != null)
  256. {
  257. if (_ScheduleDto.SearchType == 2)//获取列表
  258. {
  259. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  260. return Ok(JsonView(_grpScheduleViewList));
  261. }
  262. else//获取对象
  263. {
  264. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  265. if (_grpScheduleView != null)
  266. {
  267. return Ok(JsonView(_grpScheduleView));
  268. }
  269. }
  270. }
  271. else
  272. {
  273. return Ok(JsonView(false, "参数反序列化失败"));
  274. }
  275. return Ok(JsonView(false, "暂无数据!"));
  276. }
  277. /// <summary>
  278. /// 修改团组流程管控详细表数据
  279. /// </summary>
  280. /// <param name="dto"></param>
  281. /// <returns></returns>
  282. [HttpPost]
  283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  284. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  285. {
  286. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  287. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  288. .SetColumns(it => it.Duty == _detail.Duty)
  289. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  290. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  291. .SetColumns(it => it.JobContent == _detail.JobContent)
  292. .SetColumns(it => it.Remark == _detail.Remark)
  293. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  294. .Where(s => s.Id == dto.Id)
  295. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  296. .ExecuteCommandAsync();
  297. if (result > 0)
  298. {
  299. return Ok(JsonView(true, "保存成功!"));
  300. }
  301. return Ok(JsonView(false, "保存失败!"));
  302. }
  303. /// <summary>
  304. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  305. /// </summary>
  306. /// <param name="dto"></param>
  307. /// <returns></returns>
  308. [HttpPost]
  309. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  310. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  311. {
  312. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  313. _detail.IsDel = 1;
  314. _detail.DeleteUserId = dto.Duty;
  315. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  316. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  317. .SetColumns(it => it.IsDel == _detail.IsDel)
  318. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  319. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  320. .Where(it => it.Id == dto.Id)
  321. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  322. //.WhereColumns(s => s.Id == dto.Id)
  323. .ExecuteCommandAsync();
  324. if (result > 0)
  325. {
  326. return Ok(JsonView(true, "删除成功!"));
  327. }
  328. return Ok(JsonView(false, "删除失败!"));
  329. }
  330. /// <summary>
  331. /// 增加团组流程管控详细表数据
  332. /// </summary>
  333. /// <param name="dto"></param>
  334. /// <returns></returns>
  335. [HttpPost]
  336. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  337. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  338. {
  339. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  340. if (DateTime.Now < _detail.ExpectBeginDt)
  341. {
  342. _detail.StepStatus = 0;
  343. }
  344. else
  345. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  346. _detail.StepStatus = 1;
  347. }
  348. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  349. if (result > 0)
  350. {
  351. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  352. return Ok(JsonView(true, "添加成功!", _result));
  353. }
  354. return Ok(JsonView(false, "添加失败!"));
  355. }
  356. #endregion
  357. #region 团组基本信息
  358. /// <summary>
  359. /// 接团信息列表
  360. /// </summary>
  361. /// <param name="dto">团组列表请求dto</param>
  362. /// <returns></returns>
  363. [HttpPost]
  364. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  365. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  366. {
  367. var groupData = await _groupRepository.GetGroupList(dto);
  368. if (groupData.Code != 0)
  369. {
  370. return Ok(JsonView(false, groupData.Msg));
  371. }
  372. return Ok(JsonView(groupData.Data));
  373. }
  374. /// <summary>
  375. /// 分页查询团组列表
  376. /// </summary>
  377. /// <param name="dto"></param>
  378. /// <returns></returns>
  379. [HttpPost]
  380. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  381. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  382. {
  383. var watch = new Stopwatch();
  384. watch.Start();
  385. RefAsync<int> total = 0;
  386. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  387. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  388. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  389. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  390. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  391. .Distinct()
  392. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  393. watch.Stop();
  394. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  395. }
  396. /// <summary>
  397. /// 接团信息列表 Page Init
  398. /// </summary>
  399. /// <returns></returns>
  400. [HttpPost]
  401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  402. public async Task<IActionResult> PostGroupPageListInit()
  403. {
  404. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  405. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  406. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  407. var _view = new
  408. {
  409. depData = depDatas,
  410. rankData = rankDatas
  411. };
  412. return Ok(JsonView(true, "查询成功!", _view));
  413. }
  414. /// <summary>
  415. /// 接团信息列表 Page
  416. /// </summary>
  417. /// <param name="dto">团组列表请求dto</param>
  418. /// <returns></returns>
  419. [HttpPost]
  420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  421. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  422. {
  423. #region 参数验证
  424. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  425. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  426. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  427. #region 页面操作权限验证
  428. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  429. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  430. #endregion
  431. #endregion
  432. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  433. {
  434. string sqlWhere = string.Empty;
  435. if (dto.IsSure == 0) //未完成
  436. {
  437. sqlWhere += string.Format(@" And IsSure = 0");
  438. }
  439. else if (dto.IsSure == 1) //已完成
  440. {
  441. sqlWhere += string.Format(@" And IsSure = 1");
  442. }
  443. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  444. {
  445. string tj = dto.SearchCriteria;
  446. 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}%')",
  447. tj, tj, tj, tj, tj);
  448. }
  449. if (int.TryParse(dto.Rank, out int rankId))
  450. {
  451. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  452. }
  453. string sqlWhere1 = string.Empty;
  454. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  455. {
  456. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  457. }
  458. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  459. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  460. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  461. JietuanOperator,IsSure,CreateTime,IsBid
  462. From (
  463. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  464. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  465. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  466. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  467. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  468. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  469. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  470. From Grp_DelegationInfo gdi
  471. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  472. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  473. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  474. Where gdi.IsDel = 0 {0}
  475. ) temp {1}", sqlWhere, sqlWhere1);
  476. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  477. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  478. var _view = new
  479. {
  480. PageFuncAuth = pageFunAuthView,
  481. Data = _DelegationList
  482. };
  483. return Ok(JsonView(true, "查询成功!", _view, total));
  484. }
  485. else
  486. {
  487. return Ok(JsonView(false, "查询失败"));
  488. }
  489. }
  490. /// <summary>
  491. /// 团组列表
  492. /// </summary>
  493. /// <returns></returns>
  494. [HttpPost]
  495. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  496. {
  497. #region 参数验证
  498. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  499. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  500. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  501. #region 页面操作权限验证
  502. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  503. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  504. #endregion
  505. #endregion
  506. if (dto.PortType != 1 && dto.PortType != 2)
  507. {
  508. return Ok(JsonView(false, "查询失败!"));
  509. }
  510. string orderbyStr = "order by gdi.CreateTime Desc";
  511. string sqlWhere = string.Empty;
  512. if (dto.IsSure == 0) //未完成
  513. {
  514. sqlWhere += string.Format(@" And IsSure = 0");
  515. }
  516. else if (dto.IsSure == 1) //已完成
  517. {
  518. sqlWhere += string.Format(@" And IsSure = 1");
  519. }
  520. //团组类型
  521. if (dto.TeamDid > 0)
  522. {
  523. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  524. }
  525. //团组名称
  526. if (!string.IsNullOrEmpty(dto.TeamName))
  527. {
  528. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  529. }
  530. //客户名称
  531. if (!string.IsNullOrEmpty(dto.ClientName))
  532. {
  533. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  534. }
  535. //客户单位
  536. if (!string.IsNullOrEmpty(dto.ClientUnit))
  537. {
  538. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  539. }
  540. //出访时间
  541. if (!string.IsNullOrEmpty(dto.visitDataTime))
  542. {
  543. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  544. orderbyStr = "order by gdi.VisitDate";
  545. }
  546. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  547. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  548. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  549. JietuanOperator,IsSure,CreateTime
  550. From (
  551. Select row_number() over({0}) as Row_Number,
  552. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  553. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  554. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  555. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  556. From Grp_DelegationInfo gdi
  557. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  558. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  559. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  560. Where gdi.IsDel = 0 {1}
  561. ) temp ", orderbyStr, sqlWhere);
  562. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  563. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  564. #region 处理所属部门
  565. /*
  566. * 1.sq 和 gyy 等显示 市场部
  567. * 2.王鸽和主管及张总还有管理员号统一国交部
  568. * 2-1. 4 管理员 ,21 张海麟
  569. */
  570. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  571. List<int> userIds1 = new List<int>() { 4, 21 };
  572. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  573. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  574. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  575. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  576. .ToList();
  577. foreach (var item in _DelegationList)
  578. {
  579. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  580. }
  581. #endregion
  582. var _view = new
  583. {
  584. PageFuncAuth = pageFunAuthView,
  585. Data = _DelegationList
  586. };
  587. return Ok(JsonView(true, "查询成功!", _view, total));
  588. }
  589. /// <summary>
  590. /// 接团信息详情
  591. /// </summary>
  592. /// <param name="dto">团组info请求dto</param>
  593. /// <returns></returns>
  594. [HttpPost]
  595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  596. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  597. {
  598. var groupData = await _groupRepository.GetGroupInfo(dto);
  599. if (groupData.Code != 0)
  600. {
  601. return Ok(JsonView(false, groupData.Msg));
  602. }
  603. return Ok(JsonView(groupData.Data));
  604. }
  605. /// <summary>
  606. /// 接团信息 编辑添加
  607. /// 基础信息数据源
  608. /// </summary>
  609. /// <param name="dto"></param>
  610. /// <returns></returns>
  611. [HttpPost]
  612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  613. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  614. {
  615. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  616. if (groupData.Code != 0)
  617. {
  618. return Ok(JsonView(false, groupData.Msg));
  619. }
  620. return Ok(JsonView(groupData.Data));
  621. }
  622. /// <summary>
  623. /// 接团信息 操作(增改)
  624. /// </summary>
  625. /// <param name="dto"></param>
  626. /// <returns></returns>
  627. [HttpPost]
  628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  629. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  630. {
  631. // 创建 Stopwatch 实例
  632. Stopwatch stopwatch = Stopwatch.StartNew();
  633. decimal ffrPrice = 0.00M;
  634. DateTime? visitDt = null;
  635. if (dto.Status == 2)
  636. {
  637. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  638. if (groupInfo != null)
  639. {
  640. ffrPrice = groupInfo.PaymentMoney;
  641. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  642. }
  643. }
  644. var groupData = await _groupRepository.GroupOperation(dto);
  645. if (groupData.Code != 0)
  646. {
  647. return Ok(JsonView(false, groupData.Msg));
  648. }
  649. int diId = 0;
  650. try
  651. {
  652. //添加时 默认加入团组汇率
  653. if (dto.Status == 1) //添加
  654. {
  655. diId = groupData.Data;
  656. //添加默认币种
  657. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  658. //默认分配权限
  659. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  660. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  661. var _managerIds = new List<int>() { 22, 32, 21 };
  662. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  663. if (userIds.Count > 0)
  664. {
  665. userIds.Add(208);
  666. //创建团组管控
  667. GroupStepForDelegation.CreateWorkStep(diId);
  668. //发送消息
  669. string groupName = dto.TeamName;
  670. string createGroupUser = string.Empty;
  671. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  672. if (userInfo != null) createGroupUser = userInfo.CnName;
  673. string title = $"系统通知";
  674. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  675. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  676. }
  677. //默认创建倒推表
  678. await _invertedListRep._Create(dto.UserId, diId);
  679. }
  680. else if (dto.Status == 2)
  681. {
  682. diId = dto.Id;
  683. }
  684. #region 签证人员团组时间通知
  685. #region 计算出访起止时间
  686. var startTime = new DateTime();
  687. var endTime = new DateTime();
  688. if (DateTime.TryParse(dto.VisitDate, out startTime))
  689. {
  690. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  691. }
  692. #endregion
  693. #endregion
  694. #region 团组操作默认添加/修改收款账单
  695. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  696. {
  697. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  698. .Where(x => x.IsDel == 0 &&
  699. x.Diid == diId &&
  700. x.Remark.Equals("预付款")
  701. )
  702. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  703. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  704. .FirstAsync();
  705. ffrInfo = new Fin_ForeignReceivables()
  706. {
  707. Diid = diId,
  708. PriceName = dto.ClientUnit,
  709. Price = dto.PaymentMoney,
  710. Count = 1,
  711. Unit = $"元",
  712. ItemSumPrice = dto.PaymentMoney,
  713. Rate = 1.0000M,
  714. Currency = 836,
  715. AddingWay = 0,
  716. CreateUserId = dto.UserId,
  717. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  718. Remark = $"预付款"
  719. };
  720. if (ffrInfo == null) //Add
  721. {
  722. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  723. }
  724. else //修改
  725. {
  726. await _sqlSugar.Updateable(ffrInfo)
  727. .UpdateColumns(x => new
  728. {
  729. x.PriceName,
  730. x.Price,
  731. x.ItemSumPrice,
  732. x.CreateTime,
  733. x.CreateUserId
  734. })
  735. .WhereColumns(x => x.Id)
  736. .ExecuteCommandAsync();
  737. }
  738. }
  739. #endregion
  740. if (diId > 0)
  741. {
  742. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  743. }
  744. // 停止计时
  745. stopwatch.Stop();
  746. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  747. }
  748. catch (Exception ex)
  749. {
  750. // 停止计时
  751. stopwatch.Stop();
  752. Logs("[response]" + JsonConvert.SerializeObject(dto));
  753. Logs(ex.Message);
  754. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  755. }
  756. // 停止计时
  757. stopwatch.Stop();
  758. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  759. }
  760. /// <summary>
  761. /// 接团流程操作(增改)
  762. /// 安卓端使用 建团时添加客户名单
  763. /// </summary>
  764. /// <param name="dto"></param>
  765. /// <returns></returns>
  766. [HttpPost]
  767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  768. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  769. {
  770. #region 参数验证
  771. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  772. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  773. #region 页面操作权限验证
  774. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  775. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  776. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  777. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  778. #endregion
  779. #endregion
  780. try
  781. {
  782. //_sqlSugar.BeginTran();
  783. decimal ffrPrice = 0.00M;
  784. DateTime? visitDt = null;
  785. if (dto.Status == 2)
  786. {
  787. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  788. if (groupInfo != null)
  789. {
  790. ffrPrice = groupInfo.PaymentMoney;
  791. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  792. }
  793. }
  794. var _dto = new GroupOperationDto();
  795. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  796. var groupData = await _groupRepository.GroupOperation(_dto);
  797. if (groupData.Code != 0)
  798. {
  799. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  800. }
  801. int diId = 0;
  802. //添加时 默认加入团组汇率
  803. if (dto.Status == 1) //添加
  804. {
  805. diId = groupData.Data;
  806. //添加默认币种
  807. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  808. //默认分配权限
  809. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  810. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  811. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  812. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  813. if (userIds.Count > 0)
  814. {
  815. userIds.Add(208);
  816. //创建团组管控
  817. GroupStepForDelegation.CreateWorkStep(diId);
  818. //发送消息
  819. string groupName = dto.TeamName;
  820. string createGroupUser = string.Empty;
  821. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  822. if (userInfo != null) createGroupUser = userInfo.CnName;
  823. string title = $"系统通知";
  824. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  825. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  826. }
  827. #region 应用推送
  828. try
  829. {
  830. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  831. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  832. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  833. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  834. {
  835. List<string> userList = new List<string>() { users.QiyeChatUserId };
  836. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  837. }
  838. }
  839. catch (Exception ex)
  840. {
  841. }
  842. #endregion
  843. //默认创建倒推表
  844. await _invertedListRep._Create(dto.UserId, diId);
  845. }
  846. if (dto.Status == 2)
  847. {
  848. diId = dto.Id;
  849. if (diId == 0)
  850. {
  851. //_sqlSugar.RollbackTran();
  852. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  853. }
  854. }
  855. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  856. if (viewData.Code != 0)
  857. {
  858. //_sqlSugar.RollbackTran();
  859. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  860. }
  861. #region 团组操作默认添加/修改收款账单
  862. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  863. {
  864. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  865. .Where(x => x.IsDel == 0 &&
  866. x.Diid == diId &&
  867. x.Remark.Equals("预付款")
  868. )
  869. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  870. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  871. .FirstAsync();
  872. ffrInfo = new Fin_ForeignReceivables()
  873. {
  874. Diid = diId,
  875. PriceName = dto.ClientUnit,
  876. Price = dto.PaymentMoney,
  877. Count = 1,
  878. Unit = $"元",
  879. ItemSumPrice = dto.PaymentMoney,
  880. Rate = 1.0000M,
  881. Currency = 836,
  882. AddingWay = 0,
  883. CreateUserId = dto.UserId,
  884. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  885. Remark = $"预付款"
  886. };
  887. if (ffrInfo == null) //Add
  888. {
  889. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  890. }
  891. else //修改
  892. {
  893. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  894. .UpdateColumns(x => new
  895. {
  896. x.PriceName,
  897. x.Price,
  898. x.ItemSumPrice,
  899. x.CreateTime,
  900. x.CreateUserId
  901. })
  902. .WhereColumns(x => x.Id)
  903. .ExecuteCommandAsync();
  904. }
  905. }
  906. #endregion
  907. #region 签证人员团组时间通知
  908. #region 计算出访起止时间
  909. var startTime = new DateTime();
  910. var endTime = new DateTime();
  911. if (DateTime.TryParse(dto.VisitDate, out startTime))
  912. {
  913. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  914. }
  915. #endregion
  916. if (diId > 0)
  917. {
  918. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  919. }
  920. #endregion
  921. //_sqlSugar.CommitTran();
  922. return Ok(JsonView(true, "添加成功"));
  923. }
  924. catch (Exception ex)
  925. {
  926. _sqlSugar.RollbackTran();
  927. return Ok(JsonView(false, ex.Message));
  928. }
  929. }
  930. /// <summary>
  931. /// 接团流程操作(增改)
  932. /// 安卓端使用 建团时添加客户名单
  933. /// </summary>
  934. /// <param name="dto"></param>
  935. /// <returns></returns>
  936. [HttpPost]
  937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  938. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  939. {
  940. #region 参数验证
  941. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  942. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  943. #region 页面操作权限验证
  944. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  945. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  946. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  947. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  948. #endregion
  949. #endregion
  950. _sqlSugar.BeginTran();
  951. decimal ffrPrice = 0.00M;
  952. DateTime? visitDt = null;
  953. if (dto.Status == 2)
  954. {
  955. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  956. if (groupInfo != null)
  957. {
  958. ffrPrice = groupInfo.PaymentMoney;
  959. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  960. }
  961. }
  962. var _dto = new GroupOperationDto();
  963. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  964. var groupData = await _groupRepository.GroupOperation(_dto);
  965. if (groupData.Code != 0)
  966. {
  967. _sqlSugar.RollbackTran();
  968. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  969. }
  970. try
  971. {
  972. int diId = 0;
  973. //添加时 默认加入团组汇率
  974. if (dto.Status == 1) //添加
  975. {
  976. diId = groupData.Data;
  977. //添加默认币种
  978. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  979. //默认分配权限
  980. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  981. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  982. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  983. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  984. if (userIds.Count > 0)
  985. {
  986. userIds.Add(208);
  987. //创建团组管控
  988. GroupStepForDelegation.CreateWorkStep(diId);
  989. //发送消息
  990. string groupName = dto.TeamName;
  991. string createGroupUser = string.Empty;
  992. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  993. if (userInfo != null) createGroupUser = userInfo.CnName;
  994. string title = $"系统通知";
  995. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  996. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  997. }
  998. #region 应用推送
  999. try
  1000. {
  1001. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1002. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1003. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1004. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1005. {
  1006. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1007. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1008. }
  1009. }
  1010. catch (Exception ex)
  1011. {
  1012. _sqlSugar.CommitTran();
  1013. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1014. }
  1015. #endregion
  1016. //默认创建倒推表
  1017. await _invertedListRep._Create(dto.UserId, diId);
  1018. }
  1019. else if (dto.Status == 2)
  1020. {
  1021. diId = dto.Id;
  1022. if (diId == 0)
  1023. {
  1024. _sqlSugar.RollbackTran();
  1025. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1026. }
  1027. }
  1028. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1029. if (viewData.Code != 0)
  1030. {
  1031. _sqlSugar.RollbackTran();
  1032. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1033. }
  1034. #region 团组操作默认添加/修改收款账单
  1035. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1036. {
  1037. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1038. .Where(x => x.IsDel == 0 &&
  1039. x.Diid == diId &&
  1040. x.Remark.Equals("预付款")
  1041. )
  1042. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1043. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1044. .FirstAsync();
  1045. ffrInfo = new Fin_ForeignReceivables()
  1046. {
  1047. Diid = diId,
  1048. PriceName = dto.ClientUnit,
  1049. Price = dto.PaymentMoney,
  1050. Count = 1,
  1051. Unit = $"元",
  1052. ItemSumPrice = dto.PaymentMoney,
  1053. Rate = 1.0000M,
  1054. Currency = 836,
  1055. AddingWay = 0,
  1056. CreateUserId = dto.UserId,
  1057. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1058. Remark = $"预付款"
  1059. };
  1060. if (ffrInfo == null) //Add
  1061. {
  1062. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1063. }
  1064. else //修改
  1065. {
  1066. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1067. .UpdateColumns(x => new
  1068. {
  1069. x.PriceName,
  1070. x.Price,
  1071. x.ItemSumPrice,
  1072. x.CreateTime,
  1073. x.CreateUserId
  1074. })
  1075. .WhereColumns(x => x.Id)
  1076. .ExecuteCommandAsync();
  1077. }
  1078. }
  1079. #endregion
  1080. #region 签证人员团组时间通知
  1081. #region 计算出访起止时间
  1082. var startTime = new DateTime();
  1083. var endTime = new DateTime();
  1084. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1085. {
  1086. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1087. }
  1088. #endregion
  1089. if (diId > 0)
  1090. {
  1091. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1092. }
  1093. #endregion
  1094. _sqlSugar.CommitTran();
  1095. return Ok(JsonView(true));
  1096. }
  1097. catch (Exception ex)
  1098. {
  1099. _sqlSugar.RollbackTran();
  1100. return Ok(JsonView(false, ex.Message));
  1101. }
  1102. }
  1103. /// <summary>
  1104. /// 接团信息 操作(删除)
  1105. /// </summary>
  1106. /// <param name="dto"></param>
  1107. /// <returns></returns>
  1108. [HttpPost]
  1109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1110. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1111. {
  1112. var diId = dto.Id;
  1113. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1114. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1115. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1116. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1117. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1118. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1119. #endregion
  1120. var groupData = await _groupRepository.GroupDel(dto);
  1121. if (groupData.Code != 0)
  1122. {
  1123. return Ok(JsonView(false, groupData.Msg));
  1124. }
  1125. return Ok(JsonView(true));
  1126. }
  1127. /// <summary>
  1128. /// 获取团组销售报价号
  1129. /// 团组添加时 使用
  1130. /// </summary>
  1131. /// <returns></returns>
  1132. [HttpPost]
  1133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1134. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1135. {
  1136. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1137. if (groupData.Code != 0)
  1138. {
  1139. return Ok(JsonView(false, groupData.Msg));
  1140. }
  1141. object salesQuoteNo = new
  1142. {
  1143. SalesQuoteNo = groupData.Data
  1144. };
  1145. return Ok(JsonView(salesQuoteNo));
  1146. }
  1147. /// <summary>
  1148. /// 设置确认出团
  1149. /// </summary>
  1150. /// <param name="dto"></param>
  1151. /// <returns></returns>
  1152. [HttpPost]
  1153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1154. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1155. {
  1156. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1157. if (groupData.Code != 0)
  1158. {
  1159. return Ok(JsonView(false, groupData.Msg));
  1160. }
  1161. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1162. #region OA消息推送
  1163. try
  1164. {
  1165. string groupName = groupInfo.TeamName;
  1166. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1167. string title = $"系统通知";
  1168. string content = $"团组[{groupName}]已确认出团!";
  1169. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1170. }
  1171. catch (Exception ex)
  1172. {
  1173. }
  1174. #endregion
  1175. #region 应用推送
  1176. try
  1177. {
  1178. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1179. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1180. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1181. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1182. {
  1183. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1184. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1185. }
  1186. }
  1187. catch (Exception ex)
  1188. {
  1189. }
  1190. #endregion
  1191. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1192. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1193. }
  1194. /// <summary>
  1195. /// 获取团组名称data And 签证国别Data
  1196. /// </summary>
  1197. /// <param name="dto"></param>
  1198. /// <returns></returns>
  1199. [HttpPost]
  1200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1201. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1202. {
  1203. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1204. if (groupData.Code != 0)
  1205. {
  1206. return Ok(JsonView(false, groupData.Msg));
  1207. }
  1208. return Ok(JsonView(groupData.Data));
  1209. }
  1210. /// <summary>
  1211. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1212. /// </summary>
  1213. /// <returns></returns>
  1214. [HttpPost]
  1215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1216. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1217. {
  1218. try
  1219. {
  1220. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1221. if (groupData.Code != 0)
  1222. {
  1223. return Ok(JsonView(false, groupData.Msg));
  1224. }
  1225. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1226. }
  1227. catch (Exception ex)
  1228. {
  1229. return Ok(JsonView(false, "程序错误!"));
  1230. throw;
  1231. }
  1232. }
  1233. /// <summary>
  1234. /// 团组清单 Excel
  1235. /// </summary>
  1236. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1237. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1238. /// <returns></returns>
  1239. [HttpGet]
  1240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1241. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1242. {
  1243. DateTime _beginDt, _endDt;
  1244. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1245. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1246. if (!beginBool && !endBool)
  1247. {
  1248. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1249. }
  1250. string sql = string.Format(@"
  1251. SELECT
  1252. ROW_NUMBER,
  1253. Id,
  1254. SalesQuoteNo,
  1255. TourCode,
  1256. TeamTypeId,
  1257. TeamType,
  1258. TeamLevId,
  1259. TeamLev,
  1260. TeamName,
  1261. ClientName,
  1262. ClientUnit,
  1263. VisitDate,
  1264. VisitDays,
  1265. VisitPNumber,
  1266. JietuanOperatorId,
  1267. JietuanOperator,
  1268. IsSure,
  1269. CreateUserName,
  1270. IsBid
  1271. FROM
  1272. (
  1273. SELECT
  1274. ROW_NUMBER() OVER(
  1275. ORDER BY
  1276. gdi.CreateTime Desc
  1277. ) AS ROW_NUMBER,
  1278. gdi.Id,
  1279. SalesQuoteNo,
  1280. TourCode,
  1281. ssd.Id TeamTypeId,
  1282. ssd.Name TeamType,
  1283. ssd1.Id TeamLevId,
  1284. ssd1.Name TeamLev,
  1285. TeamName,
  1286. ClientName,
  1287. ClientUnit,
  1288. VisitDate,
  1289. VisitDays,
  1290. VisitPNumber,
  1291. JietuanOperator JietuanOperatorId,
  1292. su.CnName JietuanOperator,
  1293. IsSure,
  1294. gdi.CreateTime,
  1295. su1.CnName As CreateUserName,
  1296. gdi.IsBid
  1297. FROM
  1298. Grp_DelegationInfo gdi
  1299. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1300. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1301. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1302. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1303. WHERE
  1304. gdi.IsDel = 0
  1305. AND gdi.IsBid = 0
  1306. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1307. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1308. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1309. #region 处理所属部门
  1310. /*
  1311. * 1.sq 和 gyy 等显示 市场部
  1312. * 2.王鸽和主管及张总还有管理员号统一国交部
  1313. * 2-1. 4 管理员 ,21 张海麟
  1314. */
  1315. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1316. List<int> userIds1 = new List<int>() { 4, 21 };
  1317. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1318. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1319. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1320. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1321. .ToListAsync();
  1322. var droupIds = groupList.Select(it => it.Id).ToList();
  1323. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1324. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1325. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1326. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1327. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1328. {
  1329. DiId = tcl.DiId,
  1330. LastName = dc.LastName,
  1331. FirstName = dc.FirstName,
  1332. Sex = dc.Sex,
  1333. Birthday = dc.BirthDay,
  1334. Company = cc.CompanyFullName,
  1335. Job = dc.Job,
  1336. CreateTime = tcl.CreateTime,
  1337. })
  1338. .ToList();
  1339. foreach (var item in groupList)
  1340. {
  1341. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1342. string groupFirstName = "";
  1343. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1344. if (currDatas.Any())
  1345. {
  1346. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1347. }
  1348. item.GroupFirst = groupFirstName;
  1349. }
  1350. #endregion
  1351. #region Excel
  1352. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1353. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1354. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1355. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1356. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1357. //载入模板
  1358. WorkbookDesigner designer = new WorkbookDesigner();
  1359. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1360. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1361. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1362. dt.TableName = "GroupList";
  1363. designer.SetDataSource(dt);
  1364. designer.Process();
  1365. if (!Directory.Exists(savePath))
  1366. {
  1367. Directory.CreateDirectory(savePath);
  1368. }
  1369. string serverPath = $"{savePath}{fileName}";
  1370. designer.Workbook.Save(serverPath);
  1371. string rst = $"{servicePath}{ftpPath}{fileName}";
  1372. #endregion
  1373. return Ok(JsonView(true, "操作成功!", rst));
  1374. }
  1375. #endregion
  1376. #region 团组&签证
  1377. /// <summary>
  1378. /// 根据团组Id获取签证客户信息List
  1379. /// </summary>
  1380. /// <param name="dto">请求dto</param>
  1381. /// <returns></returns>
  1382. [HttpPost]
  1383. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1384. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1385. {
  1386. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1387. if (groupData.Code != 0)
  1388. {
  1389. return Ok(JsonView(false, groupData.Msg));
  1390. }
  1391. return Ok(JsonView(groupData.Data));
  1392. }
  1393. /// <summary>
  1394. /// IOS获取团组签证拍照上传进度01(团组列表)
  1395. /// </summary>
  1396. /// <param name="dto">请求dto</param>
  1397. /// <returns></returns>
  1398. [HttpPost]
  1399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1400. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1401. {
  1402. if (dto == null)
  1403. {
  1404. return Ok(JsonView(false, "参数为空"));
  1405. }
  1406. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1407. return Ok(JsonView(visaList));
  1408. }
  1409. /// <summary>
  1410. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1411. /// </summary>
  1412. /// <returns></returns>
  1413. [HttpPost]
  1414. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1415. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1416. {
  1417. if (dto == null)
  1418. {
  1419. return Ok(JsonView(false, "请求错误:"));
  1420. }
  1421. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1422. return Ok(JsonView(list));
  1423. }
  1424. /// <summary>
  1425. /// IOS获取团组签证拍照上传进度03(相册)
  1426. /// </summary>
  1427. /// <returns></returns>
  1428. [HttpPost]
  1429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1430. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1431. {
  1432. if (dto == null)
  1433. {
  1434. return Ok(JsonView(false, "请求错误:"));
  1435. }
  1436. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1437. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1438. list.ForEach(s => s.url = url);
  1439. return Ok(JsonView(list));
  1440. }
  1441. /// <summary>
  1442. /// IOS获取团组签证拍照上传进度04(图片上传)
  1443. /// </summary>
  1444. /// <param name="dto"></param>
  1445. /// <returns></returns>
  1446. [HttpPost]
  1447. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1448. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1449. {
  1450. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1451. //if (!string.IsNullOrEmpty(result))
  1452. //{
  1453. //}
  1454. //else {
  1455. // return Ok(JsonView(false, "上传失败"));
  1456. //}
  1457. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1458. int sucNum = 0;
  1459. try
  1460. {
  1461. foreach (var item in dto.base64DataList)
  1462. {
  1463. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1464. string result = DecodeBase64ToImage(item, imageName);
  1465. if (!string.IsNullOrEmpty(result))
  1466. {
  1467. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1468. pic.CreateUserId = dto.CreateUserId;
  1469. pic.PicName = imageName;
  1470. pic.PicPath = result;
  1471. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1472. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1473. if (insertResult > 0)
  1474. {
  1475. sucNum++;
  1476. }
  1477. }
  1478. }
  1479. }
  1480. catch (Exception ex)
  1481. {
  1482. return Ok(JsonView(false, ex.Message));
  1483. }
  1484. string msg = string.Format(@"成功上传{0}张", sucNum);
  1485. return Ok(JsonView(true, msg));
  1486. }
  1487. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  1488. {
  1489. string filename = "";//声明一个string类型的相对路径
  1490. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1491. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1492. try//会有异常抛出,try,catch一下
  1493. {
  1494. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1495. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1496. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1497. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1498. //文件名称
  1499. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1500. //上传的文件的路径
  1501. string filePath = "";
  1502. if (!Directory.Exists(fileDir))
  1503. {
  1504. Directory.CreateDirectory(fileDir);
  1505. }
  1506. //上传的文件的路径
  1507. filePath = fileDir + filename;
  1508. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1509. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1510. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1511. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1512. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1513. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1514. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1515. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1516. bitmap.Dispose();
  1517. }
  1518. catch (Exception e)
  1519. {
  1520. string massage = e.Message;
  1521. Logs("IOS图片上传Error:" + massage);
  1522. //filename = e.Message;
  1523. }
  1524. return filename;//返回相对路径
  1525. }
  1526. /// <summary>
  1527. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1528. /// </summary>
  1529. /// <param name="dto"></param>
  1530. /// <returns></returns>
  1531. [HttpPost]
  1532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1533. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1534. {
  1535. if (dto == null)
  1536. {
  1537. return Ok(JsonView(false, "请求错误:"));
  1538. }
  1539. string msg = "参数错误";
  1540. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1541. {
  1542. try
  1543. {
  1544. //_delegationVisaRep.BeginTran();
  1545. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1546. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1547. .Where(s => s.Id == dto.visaProgressCustomerId)
  1548. .ExecuteCommandAsync();
  1549. if (updCount > 0 && dto.publishCode == 1)
  1550. {
  1551. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1552. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1553. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1554. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1555. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1556. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1557. if (groupData == null)
  1558. {
  1559. _delegationVisaRep.RollbackTran();
  1560. }
  1561. string title = string.Format(@"[签证进度更新]");
  1562. string content = string.Format(@"测试文本");
  1563. bool rst = await _message.AddMsg(new MessageDto()
  1564. {
  1565. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1566. IssuerId = dto.publisher,
  1567. Title = title,
  1568. Content = content,
  1569. ReleaseTime = DateTime.Now,
  1570. UIdList = new List<int> {
  1571. 234
  1572. }
  1573. });
  1574. if (rst)
  1575. {
  1576. return Ok(JsonView(true, "发送通知成功"));
  1577. }
  1578. }
  1579. //_delegationVisaRep.CommitTran();
  1580. }
  1581. catch (Exception)
  1582. {
  1583. //_delegationVisaRep.RollbackTran();
  1584. }
  1585. }
  1586. return Ok(JsonView(true, msg));
  1587. }
  1588. #endregion
  1589. #region 团组任务分配
  1590. /// <summary>
  1591. /// 团组任务分配初始化
  1592. /// </summary>
  1593. /// <returns></returns>
  1594. [HttpPost]
  1595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1596. public async Task<IActionResult> GetTaskAssignmen()
  1597. {
  1598. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1599. if (groupData.Code != 0)
  1600. {
  1601. return Ok(JsonView(false, groupData.Msg));
  1602. }
  1603. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1604. }
  1605. /// <summary>
  1606. /// 团组任务分配查询
  1607. /// </summary>
  1608. /// <param name="dto"></param>
  1609. /// <returns></returns>
  1610. [HttpPost]
  1611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1612. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1613. {
  1614. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1615. if (groupData.Code != 0)
  1616. {
  1617. return Ok(JsonView(false, groupData.Msg));
  1618. }
  1619. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1620. }
  1621. /// <summary>
  1622. /// 团组任务分配操作
  1623. /// </summary>
  1624. /// <param name="dto"></param>
  1625. /// <returns></returns>
  1626. [HttpPost]
  1627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1628. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1629. {
  1630. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1631. if (groupData.Code != 0)
  1632. {
  1633. return Ok(JsonView(false, groupData.Msg));
  1634. }
  1635. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1636. }
  1637. /// <summary>
  1638. /// 团组任务分配
  1639. /// 批量分配
  1640. /// 查询团组
  1641. /// </summary>
  1642. /// <param name="dto"></param>
  1643. /// <returns></returns>
  1644. [HttpPost]
  1645. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1646. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1647. {
  1648. //参数验证
  1649. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1650. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1651. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1652. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1653. }
  1654. /// <summary>
  1655. /// 团组任务分配
  1656. /// 批量分配
  1657. /// </summary>
  1658. /// <param name="dto"></param>
  1659. /// <returns></returns>
  1660. [HttpPost]
  1661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1662. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1663. {
  1664. //参数验证
  1665. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1666. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1667. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1668. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1669. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1670. }
  1671. #endregion
  1672. #region 团组费用审核
  1673. /// <summary>
  1674. /// 费用审核
  1675. /// 团组列表 Page
  1676. /// </summary>
  1677. /// <param name="_dto">团组列表请求dto</param>
  1678. /// <returns></returns>
  1679. [HttpPost]
  1680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1681. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1682. {
  1683. #region 参数验证
  1684. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1685. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1686. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1687. #region 页面操作权限验证
  1688. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1689. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1690. #endregion
  1691. #endregion
  1692. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1693. {
  1694. string sqlWhere = string.Empty;
  1695. if (_dto.IsSure == 0) //未完成
  1696. {
  1697. sqlWhere += string.Format(@" And IsSure = 0");
  1698. }
  1699. else if (_dto.IsSure == 1) //已完成
  1700. {
  1701. sqlWhere += string.Format(@" And IsSure = 1");
  1702. }
  1703. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1704. {
  1705. string tj = _dto.SearchCriteria;
  1706. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  1707. tj, tj, tj, tj, tj);
  1708. }
  1709. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1710. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1711. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1712. From (
  1713. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1714. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1715. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1716. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1717. From Grp_DelegationInfo gdi
  1718. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1719. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1720. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1721. Where gdi.IsDel = 0 {0}
  1722. ) temp ", sqlWhere);
  1723. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1724. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1725. var _view = new
  1726. {
  1727. PageFuncAuth = pageFunAuthView,
  1728. Data = _DelegationList
  1729. };
  1730. return Ok(JsonView(true, "查询成功!", _view, total));
  1731. }
  1732. else
  1733. {
  1734. return Ok(JsonView(false, "查询失败"));
  1735. }
  1736. }
  1737. /// <summary>
  1738. /// 获取团组费用审核
  1739. /// </summary>
  1740. /// <param name="_dto"></param>
  1741. /// <returns></returns>
  1742. [HttpPost]
  1743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1744. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1745. {
  1746. try
  1747. {
  1748. #region 参数验证
  1749. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1750. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1751. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1752. #region 页面操作权限验证
  1753. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1754. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1755. #endregion
  1756. #endregion
  1757. var _view = new Grp_CreditCardPaymentView();
  1758. var clientNameList = getSimplClientList(_dto.DiId);
  1759. #region 费用清单
  1760. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1761. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1762. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1763. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1764. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1765. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1766. /*
  1767. * 76://酒店预订
  1768. */
  1769. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1770. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1771. /*
  1772. * 79://车/导游地接
  1773. */
  1774. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1775. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1776. /*
  1777. * 80: //签证
  1778. */
  1779. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1780. /*
  1781. *81: //邀请/公务活动
  1782. */
  1783. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1784. /*
  1785. * 82: //团组客户保险
  1786. */
  1787. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1788. /*
  1789. * Lable = 85 机票预订
  1790. */
  1791. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1792. /*
  1793. * 85 机票预定
  1794. */
  1795. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1796. /*
  1797. * 98 其他款项
  1798. */
  1799. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1800. /*
  1801. * 285:收款退还
  1802. */
  1803. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1804. /*
  1805. * 1015: //超支费用
  1806. */
  1807. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1808. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1809. /*
  1810. * 币种信息
  1811. */
  1812. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  1813. /*
  1814. * 车/导游地接 费用类型
  1815. */
  1816. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  1817. /*
  1818. * 车/导游地接 费用类型
  1819. */
  1820. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  1821. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1822. /*
  1823. * 用户信息
  1824. */
  1825. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  1826. /*
  1827. * 费用模块
  1828. */
  1829. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  1830. string priceModule = string.Empty;
  1831. if (sdPriceName != null)
  1832. {
  1833. priceModule = sdPriceName.Name;
  1834. }
  1835. /*
  1836. * 成本信息
  1837. */
  1838. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1839. decimal _groupRate = 0.0000M;
  1840. string _groupCurrencyCode = "-";
  1841. if (groupCost != null)
  1842. {
  1843. _groupRate = groupCost.Rate;
  1844. if (int.TryParse(groupCost.Currency, out int _currency))
  1845. {
  1846. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1847. }
  1848. else _groupCurrencyCode = groupCost.Currency;
  1849. }
  1850. string costContentSql = $"Select * From Grp_GroupCost";
  1851. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1852. //处理日期为空的天数
  1853. for (int i = 0; i < groupCostDetails.Count; i++)
  1854. if (i != 0)
  1855. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1856. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1857. /*
  1858. * 处理详情数据
  1859. */
  1860. foreach (var entity in entityList)
  1861. {
  1862. var _detail = new Grp_CreditCardPaymentDetailView();
  1863. _detail.Id = entity.Id;
  1864. _detail.PriceName = priceModule;
  1865. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1866. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1867. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1868. //处理金额
  1869. if (entity.CTable == 1015)
  1870. {
  1871. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1872. if (czInfo != null)
  1873. {
  1874. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1875. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1876. }
  1877. }
  1878. /*
  1879. * 应付款金额
  1880. */
  1881. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1882. string PaymentCurrency_WaitPay = "Unknown";
  1883. string hotelCurrncyCode = "Unknown";
  1884. string hotelCurrncyName = "Unknown";
  1885. if (sdPaymentCurrency_WaitPay != null)
  1886. {
  1887. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1888. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1889. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1890. if (hotelCurrncyCode.Equals("CNY"))
  1891. {
  1892. entity.DayRate = 1.0000M;
  1893. }
  1894. }
  1895. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1896. /*
  1897. * 此次付款金额
  1898. */
  1899. decimal CurrPayStr = 0.00M,
  1900. OriginalCurrPay = 0.00M;
  1901. if (entity.PayPercentage == 0)
  1902. {
  1903. if (entity.PayThenMoney != 0)
  1904. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1905. }
  1906. else
  1907. {
  1908. if (entity.PayMoney != 0)
  1909. {
  1910. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1911. }
  1912. }
  1913. //if (_dto.Label == 79)
  1914. //{
  1915. // string original = string.Empty;
  1916. // if (hotelCurrncyCode.Equals("CNY"))
  1917. // {
  1918. // OriginalCurrPay = CurrPayStr;
  1919. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1920. // }
  1921. // else
  1922. // {
  1923. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1924. // //760 EUR(7600.00 CNY)
  1925. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1926. // }
  1927. //}
  1928. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1929. string original = string.Empty;
  1930. if (hotelCurrncyCode.Equals("CNY"))
  1931. {
  1932. OriginalCurrPay = CurrPayStr;
  1933. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1934. }
  1935. else
  1936. {
  1937. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1938. //760 EUR(7600.00 CNY)
  1939. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1940. }
  1941. /*
  1942. * 剩余尾款
  1943. */
  1944. decimal BalanceStr = 0;
  1945. if (CurrPayStr != 0)
  1946. {
  1947. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1948. BalanceStr = 0;
  1949. else
  1950. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1951. }
  1952. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1953. /*
  1954. * Bus名称
  1955. */
  1956. _detail.BusName = "待增加";
  1957. /*
  1958. *费用所属
  1959. */
  1960. switch (entity.CTable)
  1961. {
  1962. case 76://酒店预订
  1963. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1964. if (hotelReservations != null)
  1965. {
  1966. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1967. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1968. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1969. string roomFeeStr = "", roomFeestr1 = "";
  1970. //是否比较房型价格
  1971. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1972. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1973. roomFeeStr += $"<br/>";
  1974. var roomTotal = 0.00M;
  1975. if (hotelReservations.SingleRoomPrice > 0)
  1976. {
  1977. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  1978. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1979. //__isSingle = true;
  1980. roomTotal += fee;
  1981. }
  1982. if (hotelReservations.DoubleRoomPrice > 0)
  1983. {
  1984. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  1985. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1986. // __isDouble = true;
  1987. roomTotal += fee;
  1988. }
  1989. if (hotelReservations.SuiteRoomPrice > 0)
  1990. {
  1991. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  1992. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1993. //__isSuite = true;
  1994. roomTotal += fee;
  1995. }
  1996. if (hotelReservations.OtherRoomPrice > 0)
  1997. {
  1998. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  1999. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2000. //__isOther = true;
  2001. roomTotal += fee;
  2002. }
  2003. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2004. else roomFeeStr += " 0.00 * 0";
  2005. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2006. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2007. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2008. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2009. /*
  2010. * 费用类型
  2011. * 1:房费
  2012. * 2:早餐
  2013. * 3:地税
  2014. * 4:城市税
  2015. * </summary>
  2016. */
  2017. //地税
  2018. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2019. if (governmentRentData != null)
  2020. {
  2021. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2022. governmentRentFee = governmentRentData.Price;
  2023. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2024. if (governmentRentCurrData != null)
  2025. {
  2026. governmentRentCode = governmentRentCurrData.Name;
  2027. governmentRentName = $"({governmentRentCurrData.Remark})";
  2028. }
  2029. }
  2030. //城市税
  2031. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2032. if (cityTaxData != null)
  2033. {
  2034. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2035. cityTaxFee = cityTaxData.Price;
  2036. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2037. if (cityTaxCurrData != null)
  2038. {
  2039. cityTaxCode = cityTaxCurrData.Name;
  2040. cityTaxName = $"({cityTaxCurrData.Remark})";
  2041. }
  2042. }
  2043. //酒店早餐
  2044. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2045. if (breakfastData != null)
  2046. {
  2047. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2048. breakfastFee = breakfastData.Price;
  2049. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2050. if (breakfastCurrData != null)
  2051. {
  2052. breakfastCode = breakfastCurrData.Name;
  2053. breakfastName = $"({breakfastCurrData.Remark})";
  2054. }
  2055. }
  2056. //房间费用
  2057. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2058. if (roomData != null)
  2059. {
  2060. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2061. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2062. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2063. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2064. roomFee = roomData.Price;
  2065. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2066. if (roomCurrData != null)
  2067. {
  2068. roomCode = roomCurrData.Name;
  2069. roomName = $"({roomCurrData.Remark})";
  2070. }
  2071. }
  2072. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2073. string hotelCostStr = "";
  2074. decimal hotelCsotTotal = 0.00M;
  2075. if (groupCost != null)
  2076. {
  2077. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2078. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2079. }
  2080. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2081. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2082. string hotelCost_day = "";
  2083. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2084. foreach (var item in hotelCostDetails1)
  2085. {
  2086. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2087. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2088. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2089. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2090. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2091. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2092. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2093. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2094. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2095. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2096. hotelCost_day += @$"<br/>";
  2097. }
  2098. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2099. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2100. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2101. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2102. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2103. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2104. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2105. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2106. $"房间说明: {hotelReservations.Remark} <br/>" +
  2107. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2108. $"{hotelBreakfastStr}" +
  2109. $"{hotelGovernmentRentStr}" +
  2110. $"{hotelCityTaxStr}";
  2111. _detail.PriceNameContent = hotelReservations.HotelName;
  2112. }
  2113. break;
  2114. case 79://车/导游地接
  2115. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2116. if (touristGuideGroundReservations != null)
  2117. {
  2118. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2119. {
  2120. _detail.BusName = touristGuideGroundReservations.BusName;
  2121. }
  2122. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2123. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2124. //if (isInt)
  2125. //{
  2126. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2127. // if (cityInfo != null)
  2128. // {
  2129. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2130. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2131. // if (carFeeItem != null)
  2132. // {
  2133. // nameContent += $@"({carFeeItem.Name})";
  2134. // }
  2135. // _detail.PriceNameContent = nameContent;
  2136. // }
  2137. //}
  2138. //else
  2139. //{
  2140. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2141. //}
  2142. var touristGuideGroundReservationsContents =
  2143. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2144. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2145. foreach (var item in touristGuideGroundReservationsContents)
  2146. {
  2147. string typeName = "Unknown";
  2148. string carCurrencyCode = "Unknown";
  2149. string carCurrencyName = "Unknown";
  2150. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2151. if (carTypeData != null) typeName = carTypeData.Name;
  2152. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2153. if (currencyData != null)
  2154. {
  2155. carCurrencyCode = currencyData.Name;
  2156. carCurrencyName = currencyData.Remark;
  2157. }
  2158. //op、成本 币种是否一致
  2159. bool IsCurrencyAgreement = false;
  2160. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2161. string opCostStr = string.Empty;
  2162. decimal opCostTypePrice = 0.00M;
  2163. #region 处理成本各项费用
  2164. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2165. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2166. if (opCost.Count > 0)
  2167. {
  2168. switch (item.SId)
  2169. {
  2170. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2171. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2172. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2173. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2174. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2175. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2176. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2177. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2178. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2179. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2180. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2181. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2182. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2183. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2184. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2185. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2186. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2187. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2188. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2189. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2190. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2191. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2192. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2193. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2194. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2195. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2196. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2197. }
  2198. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2199. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2200. }
  2201. #endregion
  2202. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2203. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2204. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2205. $"{opTypeStr} {opCostStr}<br/>" +
  2206. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2207. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2208. }
  2209. _detail.PriceMsgContent = priceMsg;
  2210. }
  2211. break;
  2212. case 80: //签证
  2213. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2214. if (visaInfo != null)
  2215. {
  2216. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2217. _detail.PriceNameContent = visaInfo.VisaDescription;
  2218. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2219. }
  2220. break;
  2221. case 81: //邀请/公务活动
  2222. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2223. if (_ioa != null)
  2224. {
  2225. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2226. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2227. sendCurrName = "Unknown", //快递费用币种 Name
  2228. sendCurrCode = "Unknown", //快递费用币种 Code
  2229. eventsCurrName = "Unknown", //公务活动费币种 Name
  2230. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2231. translateCurrName = "Unknown", //公务翻译费 Name
  2232. translateCurrCode = "Unknown"; //公务翻译费 Code
  2233. #region 处理费用币种
  2234. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2235. if (inviteCurrData != null)
  2236. {
  2237. inviteCurrName = inviteCurrData.Remark;
  2238. inviteCurrCode = inviteCurrData.Name;
  2239. }
  2240. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2241. if (sendCurrData != null)
  2242. {
  2243. sendCurrName = sendCurrData.Remark;
  2244. sendCurrCode = sendCurrData.Name;
  2245. }
  2246. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2247. if (eventsCurrData != null)
  2248. {
  2249. eventsCurrName = eventsCurrData.Remark;
  2250. eventsCurrCode = eventsCurrData.Name;
  2251. }
  2252. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2253. if (translateCurrData != null)
  2254. {
  2255. translateCurrName = translateCurrData.Remark;
  2256. translateCurrCode = translateCurrData.Name;
  2257. }
  2258. #endregion
  2259. _detail.PriceNameContent = _ioa.InviterArea;
  2260. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2261. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2262. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2263. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2264. $@"备注:" + _ioa.Remark + "<br/>";
  2265. }
  2266. break;
  2267. case 82: //团组客户保险
  2268. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2269. if (customers != null)
  2270. {
  2271. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2272. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2273. }
  2274. break;
  2275. case 85: //机票预订
  2276. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2277. if (jpRes != null)
  2278. {
  2279. string FlightsDescription = jpRes.FlightsDescription;
  2280. string PriceDescription = jpRes.PriceDescription;
  2281. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2282. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2283. }
  2284. break;
  2285. case 98://其他款项
  2286. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2287. if (gdpRes != null)
  2288. {
  2289. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2290. _detail.PriceNameContent = gdpRes.PriceName;
  2291. }
  2292. break;
  2293. case 285://收款退还
  2294. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2295. if (refundAndOtherMoney != null)
  2296. {
  2297. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2298. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2299. }
  2300. break;
  2301. case 751://酒店早餐
  2302. break;
  2303. case 1015://超支费用
  2304. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2305. if (groupExtraCost != null)
  2306. {
  2307. _detail.PriceNameContent = groupExtraCost.PriceName;
  2308. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2309. }
  2310. break;
  2311. default:
  2312. break;
  2313. }
  2314. /*
  2315. * 申请人
  2316. */
  2317. string operatorName = " - ";
  2318. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2319. if (_opUser != null)
  2320. {
  2321. operatorName = _opUser.CnName;
  2322. }
  2323. _detail.OperatorName = operatorName;
  2324. /*
  2325. * 审核人
  2326. */
  2327. string auditOperatorName = "Unknown";
  2328. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2329. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2330. else
  2331. {
  2332. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2333. if (_adUser != null)
  2334. {
  2335. auditOperatorName = _adUser.CnName;
  2336. }
  2337. }
  2338. _detail.AuditOperatorName = auditOperatorName;
  2339. /*
  2340. * 超预算比例
  2341. */
  2342. string overBudgetStr = "";
  2343. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2344. else if (entity.ExceedBudget == 0)
  2345. {
  2346. if (entity.CTable == 76 || entity.CTable == 79)
  2347. {
  2348. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2349. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2350. }
  2351. else
  2352. {
  2353. overBudgetStr = "未超预算";
  2354. }
  2355. }
  2356. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2357. _detail.OverBudget = overBudgetStr;
  2358. decimal auditFee = 0.00M; //已审核金额 人名币
  2359. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2360. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2361. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2362. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2363. {
  2364. auditedFeeOriginal = entity.PayMoney;
  2365. auditFee = CurrPayStr;
  2366. }
  2367. else if (entity.IsAuditGM == 0)
  2368. {
  2369. unAuditFeeCNY = CurrPayStr;
  2370. unAuditFeeOriginal = OriginalCurrPay;
  2371. OriginalCurrPay = 0.00M;
  2372. }
  2373. /*
  2374. * 费用总计
  2375. */
  2376. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2377. {
  2378. CurrencyId = entity.PaymentCurrency,
  2379. CurrencyName = PaymentCurrency_WaitPay,
  2380. AmountPayable = entity.PayMoney,
  2381. ThisPayment = OriginalCurrPay,
  2382. BalancePayment = BalanceStr,
  2383. AuditedFunds = auditFee,
  2384. AuditedFundsOriginal = auditedFeeOriginal,
  2385. UnAuditFundsCNY = unAuditFeeCNY,
  2386. UnAuditFundsOriginal = unAuditFeeOriginal
  2387. });
  2388. _detail.IsAuditGM = entity.IsAuditGM;
  2389. detailList.Add(_detail);
  2390. }
  2391. #endregion
  2392. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2393. /*
  2394. * 下方描述处理
  2395. */
  2396. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2397. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2398. if (ccpCurrencyPrice != null)
  2399. {
  2400. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2401. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2402. }
  2403. else
  2404. {
  2405. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2406. }
  2407. string amountPayableStr = string.Format(@"应付款总金额: ");
  2408. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2409. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2410. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2411. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2412. foreach (var item in nonDuplicat)
  2413. {
  2414. var currencyName = item.CurrencyName;
  2415. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2416. if (strs.Count > 0)
  2417. {
  2418. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2419. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2420. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2421. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2422. //单独处理此次付款金额
  2423. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2424. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2425. //单独处理已审核费用
  2426. //if (item.CurrencyId == 836) //人民币
  2427. //{
  2428. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2429. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2430. //}
  2431. //else
  2432. //{
  2433. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2434. //}
  2435. if (currencyName.Equals("CNY"))
  2436. {
  2437. //已审核费用
  2438. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2439. //未审核费用
  2440. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2441. }
  2442. else
  2443. {
  2444. //已审核费用
  2445. auditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName, strs.Sum(x => x.AuditedFunds).ToString("#0.00"));
  2446. //未审核费用
  2447. unAuditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName, strs.Sum(x => x.UnAuditFundsCNY).ToString("#0.00"));
  2448. }
  2449. }
  2450. }
  2451. _view.TotalStr1 = amountPayableStr[..^1];
  2452. _view.TotalStr2 = thisPaymentStr[..^1];
  2453. _view.TotalStr3 = balancePaymentStr[..^1];
  2454. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  2455. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2456. var _view1 = new
  2457. {
  2458. PageFuncAuth = pageFunAuthView,
  2459. Data = _view
  2460. };
  2461. return Ok(JsonView(_view1));
  2462. }
  2463. catch (Exception ex)
  2464. {
  2465. return Ok(JsonView(false, ex.Message));
  2466. }
  2467. }
  2468. /// <summary>
  2469. /// 费用审核
  2470. /// 修改团组费用审核状态
  2471. /// </summary>
  2472. /// <param name="_dto">参数Json字符串</param>
  2473. /// <returns></returns>
  2474. [HttpPost]
  2475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2476. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2477. {
  2478. #region 参数验证
  2479. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2480. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2481. #endregion
  2482. #region 页面操作权限验证
  2483. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2484. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2485. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2486. #endregion
  2487. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2488. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2489. DateTime dtNow = DateTime.Now;
  2490. _groupRepository.BeginTran();
  2491. int rst = 0;
  2492. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2493. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2494. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2495. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2496. List<dynamic> msgDatas = new List<dynamic>();
  2497. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2498. foreach (var item in idList)
  2499. {
  2500. int CreditId = int.Parse(item);
  2501. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2502. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2503. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2504. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2505. .Where(s => s.Id == CreditId)
  2506. .ExecuteCommandAsync();
  2507. if (result < 1)
  2508. {
  2509. rst = -1;
  2510. _groupRepository.RollbackTran();
  2511. return Ok(JsonView(false, "操作失败并回滚!"));
  2512. }
  2513. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2514. if (creditData != null)
  2515. {
  2516. #region 应用通知配置
  2517. try
  2518. {
  2519. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2520. }
  2521. catch (Exception ex)
  2522. {
  2523. }
  2524. #endregion
  2525. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2526. string groupNameStr = string.Empty;
  2527. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2528. if (groupData != null) groupNameStr = groupData.TeamName;
  2529. string creditTypeStr = string.Empty;
  2530. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2531. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2532. string creditCurrency = string.Empty;
  2533. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2534. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2535. if (creditCurrency.Equals("CNY"))
  2536. {
  2537. creditData.DayRate = 1.0000M;
  2538. }
  2539. if (creditData.PayPercentage == 0.00M)
  2540. {
  2541. creditData.PayPercentage = 100M;
  2542. }
  2543. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2544. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2545. string msgContent = "";
  2546. if (creditCurrency.Equals("CNY"))
  2547. {
  2548. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2549. }
  2550. else
  2551. {
  2552. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2553. }
  2554. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2555. }
  2556. }
  2557. if (rst == 0)
  2558. {
  2559. _groupRepository.CommitTran();
  2560. foreach (var item in msgDatas)
  2561. {
  2562. //发送消息
  2563. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2564. }
  2565. #region 应用推送
  2566. try
  2567. {
  2568. foreach (var ccpId in dic_ccp_user.Keys)
  2569. {
  2570. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2571. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2572. }
  2573. }
  2574. catch (Exception)
  2575. {
  2576. }
  2577. #endregion
  2578. return Ok(JsonView(true, "操作成功!"));
  2579. }
  2580. return Ok(JsonView(false, "操作失败!"));
  2581. }
  2582. #endregion
  2583. #region 机票费用录入
  2584. /// <summary>
  2585. /// 机票录入当前登录人可操作团组
  2586. /// </summary>
  2587. /// <param name="dto"></param>
  2588. /// <returns></returns>
  2589. [HttpPost]
  2590. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2591. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2592. {
  2593. try
  2594. {
  2595. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2596. if (groupData.Code != 0)
  2597. {
  2598. return Ok(JsonView(false, groupData.Msg));
  2599. }
  2600. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2601. }
  2602. catch (Exception ex)
  2603. {
  2604. return Ok(JsonView(false, "程序错误!"));
  2605. throw;
  2606. }
  2607. }
  2608. /// <summary>
  2609. /// 机票费用录入列表
  2610. /// </summary>
  2611. /// <param name="dto"></param>
  2612. /// <returns></returns>
  2613. [HttpPost]
  2614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2615. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2616. {
  2617. try
  2618. {
  2619. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2620. if (groupData.Code != 0)
  2621. {
  2622. return Ok(JsonView(false, groupData.Msg));
  2623. }
  2624. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2625. }
  2626. catch (Exception ex)
  2627. {
  2628. return Ok(JsonView(false, ex.Message));
  2629. throw;
  2630. }
  2631. }
  2632. /// <summary>
  2633. /// 根据id查询费用录入信息
  2634. /// </summary>
  2635. /// <param name="dto"></param>
  2636. /// <returns></returns>
  2637. [HttpPost]
  2638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2639. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2640. {
  2641. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2642. if (groupData.Code != 0)
  2643. {
  2644. return Ok(JsonView(false, groupData.Msg));
  2645. }
  2646. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2647. }
  2648. /// <summary>
  2649. /// 机票费用录入操作(Status:1.新增,2.修改)
  2650. /// </summary>
  2651. /// <param name="dto"></param>
  2652. /// <returns></returns>
  2653. [HttpPost]
  2654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2655. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2656. {
  2657. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2658. if (groupData.Code != 0)
  2659. {
  2660. return Ok(JsonView(false, groupData.Msg));
  2661. }
  2662. #region 应用推送
  2663. try
  2664. {
  2665. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2666. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2667. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2668. //2024-10-21 新增LZ UID
  2669. var userIds = new List<int>() { 21 };
  2670. string title = $"系统通知";
  2671. string content = "";
  2672. var diId = dto.AirTicketResOpData.DiId;
  2673. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2674. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2675. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2676. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2677. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2678. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2679. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2680. }
  2681. catch (Exception ex)
  2682. {
  2683. }
  2684. #endregion
  2685. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2686. }
  2687. /// <summary>
  2688. /// 根据舱位类型查询接团客户名单信息
  2689. /// </summary>
  2690. /// <param name="dto"></param>
  2691. /// <returns></returns>
  2692. [HttpPost]
  2693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2694. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2695. {
  2696. try
  2697. {
  2698. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2699. if (crm_Groups.Count != 0)
  2700. {
  2701. List<dynamic> Customer = new List<dynamic>();
  2702. foreach (var item in crm_Groups)
  2703. {
  2704. var data = new
  2705. {
  2706. Id = item.Id,
  2707. Pinyin = item.Pinyin,
  2708. Name = item.LastName + item.FirstName
  2709. };
  2710. Customer.Add(data);
  2711. }
  2712. return Ok(JsonView(true, "查询成功!", Customer));
  2713. }
  2714. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2715. }
  2716. catch (Exception ex)
  2717. {
  2718. return Ok(JsonView(false, "程序错误!"));
  2719. throw;
  2720. }
  2721. }
  2722. /// <summary>
  2723. /// 根据团号获取客户信息
  2724. /// </summary>
  2725. /// <param name="dto"></param>
  2726. /// <returns></returns>
  2727. [HttpPost]
  2728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2729. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2730. {
  2731. var jw = JsonView(false);
  2732. if (dto.DIID < 1)
  2733. {
  2734. jw.Msg += "请输入正确的diid";
  2735. return Ok(jw);
  2736. }
  2737. var arr = getSimplClientList(dto.DIID);
  2738. jw = JsonView(true, "获取成功!", arr);
  2739. return Ok(jw);
  2740. }
  2741. private List<SimplClientInfo> getSimplClientList(int diId)
  2742. {
  2743. string sql = string.Format("select b.Id,b.Pinyin,b.lastName,b.firstName,b.phone from Grp_TourClientList a, Crm_DeleClient b where a.clientid = b.id and a.isdel = 0 and a.diid = {0}", diId);
  2744. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2745. foreach (var item in arr)
  2746. {
  2747. EncryptionProcessor.DecryptProperties(item);
  2748. }
  2749. return arr;
  2750. }
  2751. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2752. {
  2753. string result = origin;
  2754. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2755. {
  2756. string[] temparr = origin.Split(',');
  2757. string fistrStr = temparr[0];
  2758. int count = temparr.Count();
  2759. int tempId;
  2760. bool success = int.TryParse(fistrStr, out tempId);
  2761. if (success)
  2762. {
  2763. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2764. if (tempInfo != null)
  2765. {
  2766. if (count > 1)
  2767. {
  2768. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2769. }
  2770. else
  2771. {
  2772. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2773. }
  2774. }
  2775. }
  2776. }
  2777. return result;
  2778. }
  2779. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2780. {
  2781. string result = origin;
  2782. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2783. {
  2784. string[] temparr = origin.Split(',');
  2785. result = "";
  2786. foreach (var item in temparr)
  2787. {
  2788. int tempId;
  2789. bool success = int.TryParse(item, out tempId);
  2790. if (success)
  2791. {
  2792. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2793. if (tempInfo != null)
  2794. {
  2795. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2796. }
  2797. }
  2798. }
  2799. }
  2800. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2801. return result;
  2802. }
  2803. /// <summary>
  2804. /// 机票费用录入,删除
  2805. /// </summary>
  2806. /// <param name="dto"></param>
  2807. /// <returns></returns>
  2808. [HttpPost]
  2809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2810. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2811. {
  2812. try
  2813. {
  2814. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2815. if (res)
  2816. {
  2817. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2818. {
  2819. IsDel = 1,
  2820. DeleteUserId = dto.DeleteUserId,
  2821. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2822. }).ExecuteCommandAsync();
  2823. return Ok(JsonView(true, "删除成功!"));
  2824. }
  2825. return Ok(JsonView(false, "删除失败!"));
  2826. }
  2827. catch (Exception ex)
  2828. {
  2829. return Ok(JsonView(false, "程序错误!"));
  2830. throw;
  2831. }
  2832. }
  2833. /// <summary>
  2834. /// 导出机票录入报表
  2835. /// </summary>
  2836. /// <param name="dto"></param>
  2837. /// <returns></returns>
  2838. [HttpPost]
  2839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2840. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2841. {
  2842. try
  2843. {
  2844. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2845. if (groupData.Code != 0)
  2846. {
  2847. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2848. }
  2849. else
  2850. {
  2851. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2852. if (AirTicketReservations.Count != 0)
  2853. {
  2854. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2855. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2856. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2857. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2858. WorkbookDesigner designer = new WorkbookDesigner();
  2859. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2860. decimal countCost = 0;
  2861. foreach (var item in AirTicketReservations)
  2862. {
  2863. #region 处理客人姓名
  2864. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2865. item.ClientName = clientNames;
  2866. #endregion
  2867. if (item.BankType == "其他")
  2868. {
  2869. item.BankNo = "--";
  2870. }
  2871. else
  2872. {
  2873. if (!string.IsNullOrEmpty(item.BankType))
  2874. {
  2875. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2876. }
  2877. }
  2878. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2879. item.Price = System.Decimal.Round(item.Price, 2);
  2880. countCost += Convert.ToDecimal(item.Price);
  2881. }
  2882. designer.SetDataSource("Export", AirTicketReservations);
  2883. designer.SetDataSource("ExportDiCode", diCode);
  2884. designer.SetDataSource("ExportDiName", diName);
  2885. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2886. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2887. designer.Process();
  2888. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2889. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2890. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2891. return Ok(JsonView(true, "成功", url = rst));
  2892. }
  2893. else
  2894. {
  2895. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2896. }
  2897. }
  2898. }
  2899. catch (Exception ex)
  2900. {
  2901. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2902. throw;
  2903. }
  2904. }
  2905. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2906. /// <summary>
  2907. /// 行程单导出
  2908. /// </summary>
  2909. /// <param name="dto"></param>
  2910. /// <returns></returns>
  2911. [HttpPost]
  2912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2913. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2914. {
  2915. try
  2916. {
  2917. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2918. if (groupData.Code != 0)
  2919. {
  2920. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2921. }
  2922. else
  2923. {
  2924. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2925. if (dto.Language == "CN")
  2926. {
  2927. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2928. DocumentBuilder builder = new DocumentBuilder(doc);
  2929. int tableIndex = 0;//表格索引
  2930. //得到文档中的第一个表格
  2931. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2932. foreach (var item in _AirTicketReservations)
  2933. {
  2934. #region 处理固定数据
  2935. string[] FlightsCode = item.FlightsCode.Split('/');
  2936. if (FlightsCode.Length != 0)
  2937. {
  2938. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2939. if (_AirCompany != null)
  2940. {
  2941. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2942. }
  2943. else
  2944. {
  2945. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2946. }
  2947. }
  2948. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2949. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2950. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2951. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2952. string name = "";
  2953. foreach (string clientName in nameArray)
  2954. {
  2955. if (!name.Contains(clientName))
  2956. {
  2957. name += clientName + ",";
  2958. }
  2959. }
  2960. if (!string.IsNullOrWhiteSpace(name))
  2961. {
  2962. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2963. }
  2964. else
  2965. {
  2966. table.Range.Bookmarks["ClientName"].Text = "--";
  2967. }
  2968. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2969. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2970. table.Range.Bookmarks["JointTicket"].Text = "--";
  2971. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2972. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2973. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2974. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2975. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2976. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2977. #endregion
  2978. #region 循环数据处理
  2979. List<AirInfo> airs = new List<AirInfo>();
  2980. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2981. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2982. for (int i = 0; i < FlightsCode.Length; i++)
  2983. {
  2984. AirInfo air = new AirInfo();
  2985. string[] tempstr = DayArray[i]
  2986. .Replace("\r\n", string.Empty)
  2987. .Replace("\\r\\n", string.Empty)
  2988. .TrimStart().TrimEnd()
  2989. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2990. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2991. string starCity = "";
  2992. if (star_Three != null)
  2993. {
  2994. starCity = star_Three.AirPort;
  2995. }
  2996. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2997. string EndCity = "";
  2998. if (End_Three != null)
  2999. {
  3000. EndCity = End_Three.AirPort;
  3001. }
  3002. air.Destination = starCity + "/" + EndCity;
  3003. air.Flight = FlightsCode[i];
  3004. air.SeatingClass = item.CTypeName;
  3005. string dateTime = tempstr[2];
  3006. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3007. air.FlightDate = DateTemp;
  3008. air.DepartureTime = tempstr[5];
  3009. air.LandingTime = tempstr[6];
  3010. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3011. air.TicketStatus = "--";
  3012. air.Luggage = "--";
  3013. air.DepartureTerminal = "--";
  3014. air.LandingTerminal = "--";
  3015. airs.Add(air);
  3016. }
  3017. int row = 13;
  3018. for (int i = 0; i < airs.Count; i++)
  3019. {
  3020. if (airs.Count > 2)
  3021. {
  3022. for (int j = 0; j < airs.Count - 2; j++)
  3023. {
  3024. var CopyRow = table.Rows[12].Clone(true);
  3025. table.Rows.Add(CopyRow);
  3026. }
  3027. }
  3028. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3029. int index = 0;
  3030. foreach (PropertyInfo property in properties)
  3031. {
  3032. string value = property.GetValue(airs[i]).ToString();
  3033. Cell ishcel0 = table.Rows[row].Cells[index];
  3034. Paragraph p = new Paragraph(doc);
  3035. string s = value;
  3036. p.AppendChild(new Run(doc, s));
  3037. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3038. ishcel0.AppendChild(p);
  3039. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3040. index++;
  3041. }
  3042. row++;
  3043. }
  3044. #endregion
  3045. Paragraph lastParagraph = new Paragraph(doc);
  3046. //第一个表格末尾加段落
  3047. table.ParentNode.InsertAfter(lastParagraph, table);
  3048. //复制第一个表格
  3049. Table cloneTable = (Table)table.Clone(true);
  3050. //在文档末尾段落后面加入复制的表格
  3051. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3052. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3053. {
  3054. int rownewsIndex = 13;
  3055. for (int i = 0; i < 2; i++)
  3056. {
  3057. var CopyRow = table.Rows[12].Clone(true);
  3058. table.Rows.RemoveAt(13);
  3059. table.Rows.Add(CopyRow);
  3060. rownewsIndex++;
  3061. }
  3062. }
  3063. else
  3064. {
  3065. table.Rows.RemoveAt(12);
  3066. }
  3067. cloneTable.Rows.RemoveAt(12);
  3068. }
  3069. if (_AirTicketReservations.Count != 0)
  3070. {
  3071. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3072. if (FlightsCode.Length != 0)
  3073. {
  3074. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3075. if (_AirCompany != null)
  3076. {
  3077. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3078. }
  3079. else
  3080. {
  3081. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3082. }
  3083. }
  3084. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3085. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3086. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3087. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3088. string name = "";
  3089. foreach (string clientName in nameArray)
  3090. {
  3091. if (!name.Contains(clientName))
  3092. {
  3093. name += clientName + ",";
  3094. }
  3095. }
  3096. if (!string.IsNullOrWhiteSpace(name))
  3097. {
  3098. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3099. }
  3100. else
  3101. {
  3102. table.Range.Bookmarks["ClientName"].Text = "--";
  3103. }
  3104. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3105. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3106. table.Range.Bookmarks["JointTicket"].Text = "--";
  3107. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3108. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3109. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3110. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3111. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3112. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3113. }
  3114. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3115. //保存合并后的文档
  3116. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3117. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3118. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3119. return Ok(JsonView(true, "成功!", rst));
  3120. }
  3121. else
  3122. {
  3123. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3124. DocumentBuilder builder = new DocumentBuilder(doc);
  3125. int tableIndex = 0;//表格索引
  3126. //得到文档中的第一个表格
  3127. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3128. List<string> texts = new List<string>();
  3129. foreach (var item in _AirTicketReservations)
  3130. {
  3131. string[] FlightsCode = item.FlightsCode.Split('/');
  3132. if (FlightsCode.Length != 0)
  3133. {
  3134. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3135. if (_AirCompany != null)
  3136. {
  3137. if (!transDic.ContainsKey(_AirCompany.CnName))
  3138. {
  3139. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3140. }
  3141. }
  3142. else
  3143. {
  3144. if (!transDic.ContainsKey("--"))
  3145. {
  3146. transDic.Add("--", "--");
  3147. }
  3148. }
  3149. }
  3150. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3151. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3152. string name = "";
  3153. foreach (string clientName in nameArray)
  3154. {
  3155. name += clientName + ",";
  3156. }
  3157. if (!texts.Contains(name))
  3158. {
  3159. texts.Add(name);
  3160. }
  3161. List<AirInfo> airs = new List<AirInfo>();
  3162. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3163. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3164. for (int i = 0; i < FlightsCode.Length; i++)
  3165. {
  3166. AirInfo air = new AirInfo();
  3167. string[] tempstr = DayArray[i]
  3168. .Replace("\r\n", string.Empty)
  3169. .Replace("\\r\\n", string.Empty)
  3170. .TrimStart().TrimEnd()
  3171. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3172. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3173. if (star_Three != null)
  3174. {
  3175. if (!transDic.ContainsKey(star_Three.AirPort))
  3176. {
  3177. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3178. }
  3179. }
  3180. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3181. if (End_Three != null)
  3182. {
  3183. if (!transDic.ContainsKey(End_Three.AirPort))
  3184. {
  3185. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3186. }
  3187. }
  3188. if (!texts.Contains(item.CTypeName))
  3189. {
  3190. texts.Add(item.CTypeName);
  3191. }
  3192. }
  3193. }
  3194. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  3195. if (transData.Count > 0)
  3196. {
  3197. foreach (TranslateResult item in transData)
  3198. {
  3199. if (!transDic.ContainsKey(item.Query))
  3200. {
  3201. transDic.Add(item.Query, item.Translation);
  3202. }
  3203. }
  3204. }
  3205. foreach (var item in _AirTicketReservations)
  3206. {
  3207. #region 处理固定数据
  3208. string[] FlightsCode = item.FlightsCode.Split('/');
  3209. if (FlightsCode.Length != 0)
  3210. {
  3211. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3212. if (_AirCompany != null)
  3213. {
  3214. string str = "--";
  3215. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3216. if (!string.IsNullOrEmpty(translateResult))
  3217. {
  3218. str = translateResult;
  3219. str = _airTicketResRep.Processing(str);
  3220. }
  3221. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3222. }
  3223. else
  3224. {
  3225. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3226. }
  3227. }
  3228. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3229. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3230. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3231. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3232. string names = "";
  3233. foreach (string clientName in nameArray)
  3234. {
  3235. names += clientName + ",";
  3236. }
  3237. if (!string.IsNullOrWhiteSpace(names))
  3238. {
  3239. string str = "--";
  3240. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3241. if (!string.IsNullOrEmpty(translateResult))
  3242. {
  3243. str = translateResult;
  3244. str = _airTicketResRep.Processing(str);
  3245. }
  3246. table.Range.Bookmarks["ClientName"].Text = str;
  3247. }
  3248. else
  3249. {
  3250. table.Range.Bookmarks["ClientName"].Text = "--";
  3251. }
  3252. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3253. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3254. table.Range.Bookmarks["JointTicket"].Text = "--";
  3255. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3256. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3257. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3258. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3259. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3260. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3261. #endregion
  3262. #region 循环数据处理
  3263. List<AirInfo> airs = new List<AirInfo>();
  3264. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3265. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3266. for (int i = 0; i < FlightsCode.Length; i++)
  3267. {
  3268. AirInfo air = new AirInfo();
  3269. string[] tempstr = DayArray[i]
  3270. .Replace("\r\n", string.Empty)
  3271. .Replace("\\r\\n", string.Empty)
  3272. .TrimStart().TrimEnd()
  3273. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3274. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3275. string starCity = "";
  3276. if (star_Three != null)
  3277. {
  3278. string str2 = "--";
  3279. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3280. if (!string.IsNullOrEmpty(translateResult2))
  3281. {
  3282. str2 = translateResult2;
  3283. str2 = _airTicketResRep.Processing(str2);
  3284. }
  3285. starCity = str2;
  3286. }
  3287. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3288. string EndCity = "";
  3289. if (End_Three != null)
  3290. {
  3291. string str1 = "--";
  3292. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3293. if (!string.IsNullOrEmpty(translateResult1))
  3294. {
  3295. str1 = translateResult1;
  3296. str1 = _airTicketResRep.Processing(str1);
  3297. }
  3298. EndCity = str1;
  3299. }
  3300. air.Destination = starCity + "/" + EndCity;
  3301. air.Flight = FlightsCode[i];
  3302. string str = "--";
  3303. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3304. if (!string.IsNullOrEmpty(translateResult))
  3305. {
  3306. str = translateResult;
  3307. str = _airTicketResRep.Processing(str);
  3308. }
  3309. air.SeatingClass = str;
  3310. string dateTime = tempstr[2];
  3311. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3312. air.FlightDate = DateTemp;
  3313. air.DepartureTime = tempstr[5];
  3314. air.LandingTime = tempstr[6];
  3315. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3316. air.TicketStatus = "--";
  3317. air.Luggage = "--";
  3318. air.DepartureTerminal = "--";
  3319. air.LandingTerminal = "--";
  3320. airs.Add(air);
  3321. }
  3322. int row = 13;
  3323. for (int i = 0; i < airs.Count; i++)
  3324. {
  3325. if (airs.Count > 2)
  3326. {
  3327. for (int j = 0; j < airs.Count - 2; j++)
  3328. {
  3329. var CopyRow = table.Rows[12].Clone(true);
  3330. table.Rows.Add(CopyRow);
  3331. }
  3332. }
  3333. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3334. int index = 0;
  3335. foreach (PropertyInfo property in properties)
  3336. {
  3337. string value = property.GetValue(airs[i]).ToString();
  3338. Cell ishcel0 = table.Rows[row].Cells[index];
  3339. Paragraph p = new Paragraph(doc);
  3340. string s = value;
  3341. p.AppendChild(new Run(doc, s));
  3342. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3343. ishcel0.AppendChild(p);
  3344. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3345. //ishcel0.CellFormat.VerticalAlignment=
  3346. index++;
  3347. }
  3348. row++;
  3349. }
  3350. #endregion
  3351. Paragraph lastParagraph = new Paragraph(doc);
  3352. //第一个表格末尾加段落
  3353. table.ParentNode.InsertAfter(lastParagraph, table);
  3354. //复制第一个表格
  3355. Table cloneTable = (Table)table.Clone(true);
  3356. //在文档末尾段落后面加入复制的表格
  3357. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3358. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3359. {
  3360. int rownewsIndex = 13;
  3361. for (int i = 0; i < 2; i++)
  3362. {
  3363. var CopyRow = table.Rows[12].Clone(true);
  3364. table.Rows.RemoveAt(13);
  3365. table.Rows.Add(CopyRow);
  3366. rownewsIndex++;
  3367. }
  3368. }
  3369. else
  3370. {
  3371. table.Rows.RemoveAt(12);
  3372. }
  3373. cloneTable.Rows.RemoveAt(12);
  3374. }
  3375. if (_AirTicketReservations.Count != 0)
  3376. {
  3377. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3378. if (FlightsCode.Length != 0)
  3379. {
  3380. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3381. if (_AirCompany != null)
  3382. {
  3383. string str = "--";
  3384. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3385. if (!string.IsNullOrEmpty(translateResult))
  3386. {
  3387. str = translateResult;
  3388. str = _airTicketResRep.Processing(str);
  3389. }
  3390. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3391. }
  3392. else
  3393. {
  3394. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3395. }
  3396. }
  3397. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3398. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3399. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3400. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3401. string names = "";
  3402. foreach (string clientName in nameArray)
  3403. {
  3404. names += clientName + ",";
  3405. }
  3406. if (!string.IsNullOrWhiteSpace(names))
  3407. {
  3408. string str = "--";
  3409. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3410. if (!string.IsNullOrEmpty(translateResult))
  3411. {
  3412. str = translateResult;
  3413. str = _airTicketResRep.Processing(str);
  3414. }
  3415. table.Range.Bookmarks["ClientName"].Text = str;
  3416. }
  3417. else
  3418. {
  3419. table.Range.Bookmarks["ClientName"].Text = "--";
  3420. }
  3421. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3422. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3423. table.Range.Bookmarks["JointTicket"].Text = "--";
  3424. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3425. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3426. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3427. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3428. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3429. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3430. }
  3431. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3432. //保存合并后的文档
  3433. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3434. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3435. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3436. return Ok(JsonView(true, "成功!", rst));
  3437. }
  3438. }
  3439. }
  3440. catch (Exception ex)
  3441. {
  3442. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3443. throw;
  3444. }
  3445. }
  3446. #endregion
  3447. #region 团组增减款项 --> 其他款项
  3448. /// <summary>
  3449. /// 团组增减款项下拉框绑定
  3450. /// </summary>
  3451. /// <param name="dto"></param>
  3452. /// <returns></returns>
  3453. [HttpPost]
  3454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3455. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3456. {
  3457. #region 参数验证
  3458. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3459. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3460. #endregion
  3461. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3462. }
  3463. /// <summary>
  3464. /// 根据团组Id查询团组增减款项
  3465. /// </summary>
  3466. /// <param name="dto"></param>
  3467. /// <returns></returns>
  3468. [HttpPost]
  3469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3470. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3471. {
  3472. #region 参数验证
  3473. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3474. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3475. #endregion
  3476. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3477. }
  3478. /// <summary>
  3479. /// 团组增减款项操作(Status:1.新增,2.修改)
  3480. /// </summary>
  3481. /// <param name="dto"></param>
  3482. /// <returns></returns>
  3483. [HttpPost]
  3484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3485. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3486. {
  3487. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3488. if (groupData.Code != 200)
  3489. {
  3490. return Ok(JsonView(false, groupData.Msg));
  3491. }
  3492. #region 应用推送
  3493. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3494. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3495. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3496. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  3497. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  3498. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  3499. //自动审核
  3500. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3501. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3502. //2024-10-21 新增LZ UID
  3503. var userIds = new List<int>() { 21 };
  3504. string title = $"系统通知";
  3505. string content = "";
  3506. var diId = dto.DiId;
  3507. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3508. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3509. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3510. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3511. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3512. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3513. #endregion
  3514. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3515. }
  3516. /// <summary>
  3517. /// 团组增减款项操作 删除
  3518. /// </summary>
  3519. /// <param name="dto"></param>
  3520. /// <returns></returns>
  3521. [HttpPost]
  3522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3523. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3524. {
  3525. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3526. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3527. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3528. if (res.Code == 0)
  3529. {
  3530. return Ok(JsonView(true, "删除成功!"));
  3531. }
  3532. return Ok(JsonView(false, "删除失败!"));
  3533. }
  3534. /// <summary>
  3535. /// 根据团组增减款项Id查询
  3536. /// </summary>
  3537. /// <param name="dto"></param>
  3538. /// <returns></returns>
  3539. [HttpPost]
  3540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3541. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3542. {
  3543. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3544. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3545. }
  3546. /// <summary>
  3547. /// 查询供应商名称
  3548. /// </summary>
  3549. /// <param name="dto"></param>
  3550. /// <returns></returns>
  3551. [HttpPost]
  3552. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3553. {
  3554. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3555. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3556. ?? new List<Grp_DecreasePayments>();
  3557. dbResult = dbResult.Distinct(new
  3558. ProductComparer()).ToList();
  3559. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3560. {
  3561. x.Id,
  3562. x.SupplierAddress,
  3563. x.SupplierArea,
  3564. x.SupplierContact,
  3565. x.SupplierContactNumber,
  3566. x.SupplierEmail,
  3567. x.SupplierName,
  3568. x.SupplierSocialAccount,
  3569. x.SupplierTypeId,
  3570. }).ToList());
  3571. return Ok(jw);
  3572. }
  3573. /// <summary>
  3574. /// 团组增减款项 OTA匹配
  3575. /// </summary>
  3576. /// <param name="file"></param>
  3577. /// <returns></returns>
  3578. [HttpPost]
  3579. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3580. {
  3581. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3582. string fileName = file.FileName;
  3583. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3584. {
  3585. return Ok(JsonView(false, "请上传Excel文件!"));
  3586. }
  3587. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3588. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3589. if (!Directory.Exists(path))
  3590. {
  3591. Directory.CreateDirectory(path);
  3592. }
  3593. var filePath = @$"{path}/{fileName}";
  3594. //保存文件
  3595. using (FileStream fs = System.IO.File.Create(filePath))
  3596. {
  3597. file.CopyTo(fs);
  3598. fs.Flush();
  3599. }
  3600. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3601. //读取ExcelFile
  3602. DataTable dt = ConvertExcelToDataTable(filePath);
  3603. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3604. dt.TableName = "TB";
  3605. //修改table列名
  3606. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3607. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3608. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3609. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3610. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3611. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3612. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3613. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3614. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3615. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3616. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3617. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3618. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3619. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3620. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3621. var otaOrderNos = new List<string>();
  3622. foreach (DataRow item in dt.Rows)
  3623. {
  3624. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3625. }
  3626. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3627. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3628. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3629. .Select((dp, di) => new
  3630. {
  3631. dp.PriceName,
  3632. dp.OTAOrderNo,
  3633. dp.FeeTotal,
  3634. di.TeamName,
  3635. })
  3636. .ToListAsync();
  3637. foreach (DataRow item in dt.Rows)
  3638. {
  3639. var otaOrderNo = item["OTAOrderNo"].ToString();
  3640. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3641. if (oaData == null) continue;
  3642. item["GroupName"] = oaData.TeamName;
  3643. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3644. }
  3645. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3646. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3647. List<DataTable> datas = new List<DataTable>();
  3648. datas.Add(dt);
  3649. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3650. return Ok(JsonView(true, "操作成功", new { url = url }));
  3651. }
  3652. #region
  3653. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3654. {
  3655. // 创建Workbook对象
  3656. Workbook workbook = new Workbook(excelFilePath);
  3657. // 获取第一个工作表
  3658. Worksheet worksheet = workbook.Worksheets[0];
  3659. // 将工作表转换为DataTable
  3660. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3661. return dataTable;
  3662. }
  3663. #endregion
  3664. #endregion
  3665. #region 文件上传、删除
  3666. /// <summary>
  3667. /// region 文件上传 可以带参数
  3668. /// </summary>
  3669. /// <param name="file"></param>
  3670. /// <returns></returns>
  3671. [HttpPost]
  3672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3673. public async Task<IActionResult> UploadProject(IFormFile file)
  3674. {
  3675. //var TypeName = Request.Headers["TypeName"].ToString();
  3676. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3677. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3678. ////文件名称
  3679. //string projectFileName = file.FileName;
  3680. ////上传的文件的路径
  3681. //string filePath = $"{fileDir}/{projectFileName}";
  3682. //if (TypeName == "A")//A代表团组增减款项
  3683. //{
  3684. // filePath = fileDir + $@"\团组增减款项相关文件";
  3685. // if (!Directory.Exists(filePath))
  3686. // {
  3687. // Directory.CreateDirectory(filePath);
  3688. // }
  3689. // //上传的文件的路径
  3690. // filePath += $@"\{projectFileName}";
  3691. //}
  3692. //else if (TypeName == "B")//B代表商邀相关文件
  3693. //{
  3694. // //上传的文件的路径
  3695. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3696. // if (!Directory.Exists(filePath))
  3697. // {
  3698. // Directory.CreateDirectory(filePath);
  3699. // }
  3700. // //上传的文件的路径
  3701. // filePath = $@"\{projectFileName}";
  3702. //}
  3703. //try
  3704. //{
  3705. // using (FileStream fs = System.IO.File.Create(filePath))
  3706. // {
  3707. // file.CopyTo(fs);
  3708. // fs.Flush();
  3709. // }
  3710. //}
  3711. //catch (Exception ex)
  3712. //{
  3713. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3714. //}
  3715. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3716. try
  3717. {
  3718. var TypeName = Request.Headers["TypeName"].ToString();
  3719. if (file != null)
  3720. {
  3721. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3722. //文件名称
  3723. string projectFileName = file.FileName;
  3724. //上传的文件的路径
  3725. string filePath = $"{fileDir}/{projectFileName}";
  3726. if (TypeName == "A")//A代表团组增减款项
  3727. {
  3728. if (!Directory.Exists(fileDir))
  3729. {
  3730. Directory.CreateDirectory(fileDir);
  3731. }
  3732. //上传的文件的路径
  3733. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3734. }
  3735. else if (TypeName == "B")//B代表商邀相关文件
  3736. {
  3737. if (!Directory.Exists(fileDir))
  3738. {
  3739. Directory.CreateDirectory(fileDir);
  3740. }
  3741. //上传的文件的路径
  3742. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3743. }
  3744. using (FileStream fs = System.IO.File.Create(filePath))
  3745. {
  3746. file.CopyTo(fs);
  3747. fs.Flush();
  3748. }
  3749. return Ok(JsonView(true, "上传成功!", projectFileName));
  3750. }
  3751. else
  3752. {
  3753. return Ok(JsonView(false, "上传失败!"));
  3754. }
  3755. }
  3756. catch (Exception ex)
  3757. {
  3758. return Ok(JsonView(false, "程序错误!"));
  3759. }
  3760. }
  3761. /// <summary>
  3762. /// 删除指定文件
  3763. /// </summary>
  3764. /// <param name="dto"></param>
  3765. /// <returns></returns>
  3766. [HttpPost]
  3767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3768. public async Task<IActionResult> DelFile(DelFileDto dto)
  3769. {
  3770. try
  3771. {
  3772. var TypeName = Request.Headers["TypeName"].ToString();
  3773. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3774. string filePath = "";
  3775. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3776. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3777. int id = 0;
  3778. if (TypeName == "A")
  3779. {
  3780. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3781. // 删除该文件
  3782. System.IO.File.Delete(filePath);
  3783. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3784. .Where(a => a.Id == dto.Id)
  3785. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3786. .ExecuteCommandAsync();
  3787. }
  3788. else if (TypeName == "B")
  3789. {
  3790. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3791. // 删除该文件
  3792. System.IO.File.Delete(filePath);
  3793. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3794. if (info != null)
  3795. {
  3796. string[] files = new string[] { };
  3797. if (!string.IsNullOrEmpty(info.Attachment))
  3798. {
  3799. try
  3800. {
  3801. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3802. }
  3803. catch (Exception)
  3804. {
  3805. files = new List<string>() { info.Attachment }.ToArray();
  3806. }
  3807. }
  3808. if (files.Length > 0)
  3809. {
  3810. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3811. string filePath2 = string.Empty;
  3812. if (files1.Length > 0)
  3813. {
  3814. filePath2 = JsonConvert.SerializeObject(files1);
  3815. }
  3816. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3817. .Where(a => a.Id == dto.Id)
  3818. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3819. .ExecuteCommandAsync();
  3820. }
  3821. }
  3822. }
  3823. if (id != 0)
  3824. {
  3825. return Ok(JsonView(true, "成功!"));
  3826. }
  3827. else
  3828. {
  3829. return Ok(JsonView(false, "失败!"));
  3830. }
  3831. }
  3832. catch (Exception ex)
  3833. {
  3834. return Ok(JsonView(false, "程序错误!"));
  3835. throw;
  3836. }
  3837. }
  3838. /// <summary>
  3839. /// 文件上传多个文件 可以带参数
  3840. /// </summary>
  3841. /// <param name="files"></param>
  3842. /// <returns></returns>
  3843. [HttpPost]
  3844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3845. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3846. {
  3847. try
  3848. {
  3849. var TypeName = Request.Headers["TypeName"].ToString();
  3850. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3851. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3852. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3853. var filePahts = new List<string>();
  3854. foreach (var file in files)
  3855. {
  3856. //文件名称
  3857. string projectFileName = file.FileName;
  3858. //上传的文件的路径
  3859. string filePath = $"{fileDir}/{projectFileName}";
  3860. if (TypeName == "A")//A代表团组增减款项
  3861. {
  3862. if (!Directory.Exists(fileDir))
  3863. {
  3864. Directory.CreateDirectory(fileDir);
  3865. }
  3866. //上传的文件的路径
  3867. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3868. }
  3869. else if (TypeName == "B")//B代表商邀相关文件
  3870. {
  3871. if (!Directory.Exists(fileDir))
  3872. {
  3873. Directory.CreateDirectory(fileDir);
  3874. }
  3875. //上传的文件的路径
  3876. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3877. }
  3878. using (FileStream fs = System.IO.File.Create(filePath))
  3879. {
  3880. file.CopyTo(fs);
  3881. fs.Flush();
  3882. }
  3883. filePahts.Add(projectFileName);
  3884. }
  3885. return Ok(JsonView(true, "上传成功!", filePahts));
  3886. }
  3887. catch (Exception ex)
  3888. {
  3889. return Ok(JsonView(false, "程序错误!"));
  3890. }
  3891. }
  3892. #endregion
  3893. #region 商邀费用录入
  3894. /// <summary>
  3895. /// 根据团组Id查询商邀费用列表
  3896. /// </summary>
  3897. /// <param name="dto"></param>
  3898. /// <returns></returns>
  3899. [HttpPost]
  3900. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3901. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3902. {
  3903. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3904. if (groupData.Code != 0)
  3905. {
  3906. return Ok(JsonView(false, groupData.Msg));
  3907. }
  3908. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3909. }
  3910. /// <summary>
  3911. /// 商邀费用列表
  3912. /// 下载文件
  3913. /// </summary>
  3914. /// <param name="id"></param>
  3915. /// <returns></returns>
  3916. [HttpGet("{id}")]
  3917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3918. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3919. {
  3920. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3921. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3922. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3923. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3924. var filePaths = new List<string>();
  3925. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3926. try
  3927. {
  3928. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3929. }
  3930. catch (Exception ex)
  3931. {
  3932. filePaths.Add(info.Attachment);
  3933. }
  3934. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3935. for (int i = 0; i < filePaths.Count; i++)
  3936. {
  3937. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3938. }
  3939. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3940. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3941. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3942. {
  3943. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3944. {
  3945. foreach (string filePath in filePaths)
  3946. {
  3947. if (System.IO.File.Exists(filePath))
  3948. {
  3949. // 获取文件名
  3950. string fileName = Path.GetFileName(filePath);
  3951. // 将文件添加到ZIP归档中
  3952. zipArchive.CreateEntryFromFile(filePath, fileName);
  3953. }
  3954. }
  3955. }
  3956. }
  3957. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3958. }
  3959. /// <summary>
  3960. /// 商邀费用 Info Page 基础数据源
  3961. /// </summary>
  3962. /// <returns></returns>
  3963. [HttpPost]
  3964. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3965. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3966. {
  3967. try
  3968. {
  3969. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3970. if (groupData.Code != 0)
  3971. {
  3972. return Ok(JsonView(false, groupData.Msg));
  3973. }
  3974. return Ok(JsonView(true, "操作成功", groupData.Data));
  3975. }
  3976. catch (Exception ex)
  3977. {
  3978. return Ok(JsonView(false, ex.Message));
  3979. throw;
  3980. }
  3981. }
  3982. /// <summary>
  3983. /// 根据商邀费用ID查询C表和商邀费用数据
  3984. /// </summary>
  3985. /// <param name="dto"></param>
  3986. /// <returns></returns>
  3987. [HttpPost]
  3988. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3989. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3990. {
  3991. try
  3992. {
  3993. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3994. if (groupData.Code != 0)
  3995. {
  3996. return Ok(JsonView(false, groupData.Msg));
  3997. }
  3998. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3999. }
  4000. catch (Exception ex)
  4001. {
  4002. return Ok(JsonView(false, ex.Message));
  4003. throw;
  4004. }
  4005. }
  4006. /// <summary>
  4007. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4008. /// </summary>
  4009. /// <param name="dto"></param>
  4010. /// <returns></returns>
  4011. [HttpPost]
  4012. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4013. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4014. {
  4015. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4016. if (groupData.Code != 0)
  4017. {
  4018. return Ok(JsonView(false, groupData.Msg));
  4019. }
  4020. #region 应用推送
  4021. try
  4022. {
  4023. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4024. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4025. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4026. //2024-10-21 新增LZ UID
  4027. var userIds = new List<int>() { 21 };
  4028. string title = $"系统通知";
  4029. string content = "";
  4030. var diId = dto.DiId;
  4031. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4032. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4033. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4034. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4035. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4036. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4037. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4038. }
  4039. catch (Exception ex)
  4040. {
  4041. }
  4042. #endregion
  4043. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4044. }
  4045. /// <summary>
  4046. /// 商邀删除
  4047. /// </summary>
  4048. /// <param name="dto"></param>
  4049. /// <returns></returns>
  4050. [HttpPost]
  4051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4052. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4053. {
  4054. try
  4055. {
  4056. _sqlSugar.BeginTran();
  4057. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4058. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4059. {
  4060. IsDel = 1,
  4061. DeleteUserId = dto.DeleteUserId,
  4062. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4063. })
  4064. .Where(it => it.Id == dto.Id)
  4065. .ExecuteCommand();
  4066. if (res1 > 0)
  4067. {
  4068. int _diId = 0;
  4069. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4070. if (_ioaInfo != null)
  4071. {
  4072. _diId = _ioaInfo.DiId;
  4073. }
  4074. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4075. .SetColumns(a => new Grp_CreditCardPayment()
  4076. {
  4077. IsDel = 1,
  4078. DeleteUserId = dto.DeleteUserId,
  4079. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4080. })
  4081. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4082. .ExecuteCommand();
  4083. if (res2 > 0)
  4084. {
  4085. _sqlSugar.CommitTran();
  4086. return Ok(JsonView(true, "删除成功!"));
  4087. }
  4088. }
  4089. _sqlSugar.RollbackTran();
  4090. return Ok(JsonView(false, "删除失败"));
  4091. }
  4092. catch (Exception ex)
  4093. {
  4094. _sqlSugar.RollbackTran();
  4095. return Ok(JsonView(false, ex.Message));
  4096. }
  4097. }
  4098. /// <summary>
  4099. /// 团组模块文件上传
  4100. /// </summary>
  4101. /// <param name="dto"></param>
  4102. /// <returns></returns>
  4103. [HttpPost]
  4104. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4105. {
  4106. var jw = JsonView(false);
  4107. long M = 1024 * 1024;
  4108. if (dto.Files == null || dto.Files.Count == 0)
  4109. {
  4110. jw.Msg = "无文件信息!";
  4111. return Ok(jw);
  4112. }
  4113. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4114. {
  4115. jw.Msg = "文件大小超过20M!";
  4116. return Ok(jw);
  4117. }
  4118. //var nameSp = dto.File.FileName.Split(".");
  4119. //if (nameSp.Length < 2)
  4120. //{
  4121. // jw.Msg = "拓展名称有误!";
  4122. // return Ok(jw);
  4123. //}
  4124. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4125. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4126. //{
  4127. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4128. // return Ok(jw);
  4129. //}
  4130. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4131. if (Ctable == null)
  4132. {
  4133. jw.Msg = "Ctable指向有误!";
  4134. return Ok(jw);
  4135. }
  4136. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4137. if (groupInfo == null)
  4138. {
  4139. jw.Msg = "团组信息不存在!";
  4140. return Ok(jw);
  4141. }
  4142. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4143. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4144. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4145. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4146. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4147. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4148. try
  4149. {
  4150. if (!Directory.Exists(fileBase))
  4151. {
  4152. Directory.CreateDirectory(fileBase);
  4153. }
  4154. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4155. foreach (var fileStream in dto.Files)
  4156. {
  4157. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4158. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4159. {
  4160. Cid = dto.Cid,
  4161. CreateTime = DateTime.Now,
  4162. CreateUserId = dto.Userid,
  4163. Ctable = dto.Ctable,
  4164. Diid = dto.Diid,
  4165. IsDel = 0,
  4166. FilePath = saveFilePath,
  4167. FileName = fileStream.FileName
  4168. };
  4169. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4170. {
  4171. fileStream.CopyTo(fs);
  4172. fs.Flush();
  4173. }
  4174. saveArr.Add(file);
  4175. }
  4176. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4177. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4178. jw = JsonView(true, "保存成功!", new
  4179. {
  4180. count = addResult,
  4181. filesName = saveArr.Select(x => x.FileName)
  4182. });
  4183. }
  4184. catch (Exception ex)
  4185. {
  4186. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4187. {
  4188. count = 0,
  4189. filesName = new string[0],
  4190. });
  4191. }
  4192. return Ok(jw);
  4193. }
  4194. /// <summary>
  4195. /// 查询各模块已保存文件
  4196. /// </summary>
  4197. /// <param name="dto"></param>
  4198. /// <returns></returns>
  4199. [HttpPost]
  4200. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4201. {
  4202. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4203. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4204. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4205. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4206. {
  4207. expression = Expressionable.Create<Grp_GroupModelFile>()
  4208. .And(x => visaIds.Contains(x.CreateUserId));
  4209. }
  4210. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4211. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4212. .Where(expression.ToExpression())
  4213. .ToList();
  4214. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4215. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4216. {
  4217. x.FileName,
  4218. x.Id,
  4219. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4220. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4221. })));
  4222. }
  4223. /// <summary>
  4224. /// 下载该团组下的所有文件
  4225. /// </summary>
  4226. /// <param name="dto"></param>
  4227. /// <returns></returns>
  4228. [HttpPost]
  4229. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4230. {
  4231. var jw = JsonView(false);
  4232. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4233. if (groupInfo == null)
  4234. {
  4235. jw.Msg = "团组信息不存在!";
  4236. return Ok(jw);
  4237. }
  4238. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4239. var isModule = Convert.ToBoolean(dto.isModule);
  4240. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4241. IOOperatorHelper io = new IOOperatorHelper();
  4242. if (isModule)
  4243. {
  4244. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4245. foreach (var moduleArr in moduleGroup)
  4246. {
  4247. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4248. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4249. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4250. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4251. foreach (var item in moduleArr)
  4252. {
  4253. if (System.IO.File.Exists(item.FilePath))
  4254. {
  4255. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4256. {
  4257. byte[] bytes = new byte[fileStream.Length];
  4258. fileStream.Read(bytes, 0, bytes.Length);
  4259. fileStream.Close();
  4260. Stream stream = new MemoryStream(bytes);
  4261. chiZips.Add(item.FileName, stream);
  4262. }
  4263. }
  4264. }
  4265. if (chiZips.Count > 0)
  4266. {
  4267. var byts = io.ConvertZipStream(chiZips);
  4268. Stream stream = new MemoryStream(byts);
  4269. Zips.Add(key.Name + "_.zip", stream);
  4270. }
  4271. }
  4272. }
  4273. else
  4274. {
  4275. foreach (var item in dbQuery)
  4276. {
  4277. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4278. {
  4279. byte[] bytes = new byte[fileStream.Length];
  4280. fileStream.Read(bytes, 0, bytes.Length);
  4281. fileStream.Close();
  4282. Stream stream = new MemoryStream(bytes);
  4283. while (Zips.Keys.Contains(item.FileName))
  4284. {
  4285. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4286. }
  4287. Zips.Add(item.FileName, stream);
  4288. }
  4289. }
  4290. }
  4291. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4292. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4293. if (Zips.Count > 0)
  4294. {
  4295. var byts = io.ConvertZipStream(Zips);
  4296. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4297. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4298. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4299. }
  4300. else
  4301. {
  4302. jw.Msg = "暂无生成文件!";
  4303. }
  4304. return Ok(jw);
  4305. }
  4306. /// <summary>
  4307. /// 下载该团组下此模块的所有文件
  4308. /// </summary>
  4309. /// <param name="dto"></param>
  4310. /// <returns></returns>
  4311. [HttpPost]
  4312. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4313. {
  4314. var jw = JsonView(false);
  4315. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4316. if (groupInfo == null)
  4317. {
  4318. jw.Msg = "团组信息不存在!";
  4319. return Ok(jw);
  4320. }
  4321. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4322. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4323. && x.IsDel == 0);
  4324. if (key == null)
  4325. {
  4326. jw.Msg = "Ctable指向错误!";
  4327. return Ok(jw);
  4328. }
  4329. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4330. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4331. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4332. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4333. IOOperatorHelper io = new IOOperatorHelper();
  4334. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4335. foreach (var item in dbQuery)
  4336. {
  4337. if (System.IO.File.Exists(item.FilePath))
  4338. {
  4339. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4340. {
  4341. byte[] bytes = new byte[fileStream.Length];
  4342. fileStream.Read(bytes, 0, bytes.Length);
  4343. fileStream.Close();
  4344. Stream stream = new MemoryStream(bytes);
  4345. while (Zips.Keys.Contains(item.FileName))
  4346. {
  4347. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4348. }
  4349. Zips.Add(item.FileName, stream);
  4350. }
  4351. }
  4352. }
  4353. if (Zips.Count > 0)
  4354. {
  4355. var byts = io.ConvertZipStream(Zips);
  4356. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4357. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4358. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4359. }
  4360. else
  4361. {
  4362. jw.Msg = "暂无生成文件!";
  4363. }
  4364. return Ok(jw);
  4365. }
  4366. /// <summary>
  4367. /// 删除该团组下的指定文件
  4368. /// </summary>
  4369. /// <param name="dto"></param>
  4370. /// <returns></returns>
  4371. [HttpPost]
  4372. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4373. {
  4374. var jw = JsonView(false);
  4375. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4376. if (sing == null)
  4377. {
  4378. jw.Msg = "暂无";
  4379. return Ok(jw);
  4380. }
  4381. if (System.IO.File.Exists(sing.FilePath))
  4382. {
  4383. try
  4384. {
  4385. System.IO.File.Delete(sing.FilePath);
  4386. }
  4387. catch (Exception ex)
  4388. {
  4389. jw.Msg = "删除失败!" + ex.Message;
  4390. return Ok(jw);
  4391. }
  4392. }
  4393. sing.IsDel = 1;
  4394. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4395. sing.DeleteUserId = dto.UserId;
  4396. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4397. jw = JsonView(true, "删除成功!");
  4398. return Ok(jw);
  4399. }
  4400. #endregion
  4401. #region 团组英文资料
  4402. /// <summary>
  4403. /// 查询团组英文所有资料
  4404. /// </summary>
  4405. /// <param name="dto"></param>
  4406. /// <returns></returns>
  4407. [HttpPost]
  4408. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4409. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4410. {
  4411. try
  4412. {
  4413. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4414. if (groupData.Code != 0)
  4415. {
  4416. return Ok(JsonView(false, groupData.Msg));
  4417. }
  4418. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4419. }
  4420. catch (Exception ex)
  4421. {
  4422. return Ok(JsonView(false, "程序错误!"));
  4423. throw;
  4424. }
  4425. }
  4426. /// <summary>
  4427. /// 团组英文资料操作(Status:1.新增,2.修改)
  4428. /// </summary>
  4429. /// <param name="dto"></param>
  4430. /// <returns></returns>
  4431. [HttpPost]
  4432. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4433. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4434. {
  4435. try
  4436. {
  4437. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4438. if (groupData.Code != 0)
  4439. {
  4440. return Ok(JsonView(false, groupData.Msg));
  4441. }
  4442. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4443. }
  4444. catch (Exception ex)
  4445. {
  4446. return Ok(JsonView(false, "程序错误!"));
  4447. throw;
  4448. }
  4449. }
  4450. /// <summary>
  4451. /// 团组英文资料Id查询数据
  4452. /// </summary>
  4453. /// <param name="dto"></param>
  4454. /// <returns></returns>
  4455. [HttpPost]
  4456. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4457. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4458. {
  4459. try
  4460. {
  4461. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4462. if (_DelegationEnData != null)
  4463. {
  4464. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4465. }
  4466. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4467. }
  4468. catch (Exception ex)
  4469. {
  4470. return Ok(JsonView(false, "程序错误!"));
  4471. throw;
  4472. }
  4473. }
  4474. /// <summary>
  4475. /// 团组英文资料删除
  4476. /// </summary>
  4477. /// <param name="dto"></param>
  4478. /// <returns></returns>
  4479. [HttpPost]
  4480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4481. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4482. {
  4483. try
  4484. {
  4485. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4486. if (!res)
  4487. {
  4488. return Ok(JsonView(false, "删除失败"));
  4489. }
  4490. return Ok(JsonView(true, "删除成功!"));
  4491. }
  4492. catch (Exception ex)
  4493. {
  4494. return Ok(JsonView(false, "程序错误!"));
  4495. throw;
  4496. }
  4497. }
  4498. #endregion
  4499. #region 导出邀请函
  4500. /// <summary>
  4501. /// 导出邀请函页面初始化
  4502. /// </summary>
  4503. /// <param name="dto"></param>
  4504. /// <returns></returns>
  4505. [HttpPost]
  4506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4507. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4508. {
  4509. try
  4510. {
  4511. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4512. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4513. if (dto.DiId == 0)
  4514. {
  4515. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4516. }
  4517. else
  4518. {
  4519. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4520. }
  4521. return Ok(JsonView(true, "查询成功!", new
  4522. {
  4523. deleClient = crm_Deles,
  4524. delegations = grp_Delegations
  4525. }));
  4526. }
  4527. catch (Exception ex)
  4528. {
  4529. return Ok(JsonView(false, "程序错误!"));
  4530. throw;
  4531. }
  4532. }
  4533. /// <summary>
  4534. /// 导出邀请函
  4535. /// </summary>
  4536. /// <param name="dto"></param>
  4537. /// <returns></returns>
  4538. [HttpPost]
  4539. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4540. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4541. {
  4542. #region 参数验证
  4543. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4544. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4545. #endregion
  4546. try
  4547. {
  4548. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4549. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4550. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4551. From Grp_TourClientList tcl
  4552. Left Join
  4553. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4554. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4555. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4556. From Crm_DeleClient dc
  4557. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4558. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4559. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4560. Where dc.IsDel = 0) temp
  4561. On temp.DcId =tcl.ClientId
  4562. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4563. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4564. List<string> texts = new List<string>();
  4565. if (datas.Count != 0)
  4566. {
  4567. foreach (TourClientListDetailsView item in datas)
  4568. {
  4569. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4570. {
  4571. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4572. }
  4573. else
  4574. {
  4575. string name = item.LastName + item.FirstName;
  4576. texts.Add(name);
  4577. }
  4578. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4579. {
  4580. if (!transDic.ContainsKey(item.Job))
  4581. {
  4582. texts.Add(item.Job);
  4583. }
  4584. }
  4585. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4586. {
  4587. texts.Add(item.CompanyFullName);
  4588. }
  4589. }
  4590. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4591. if (transData.Count > 0)
  4592. {
  4593. foreach (TranslateResult item in transData)
  4594. {
  4595. if (!transDic.ContainsKey(item.Query))
  4596. {
  4597. transDic.Add(item.Query, item.Translation);
  4598. }
  4599. }
  4600. }
  4601. List<GuestList> list = new List<GuestList>();
  4602. foreach (TourClientListDetailsView dele in datas)
  4603. {
  4604. GuestList guestList = new GuestList();
  4605. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4606. {
  4607. guestList.Name = dele.Pinyin;
  4608. }
  4609. else
  4610. {
  4611. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4612. guestList.Name = Name;
  4613. }
  4614. if (dele.Sex == 0)
  4615. {
  4616. guestList.Sex = "Male";
  4617. }
  4618. else if (dele.Sex == 1)
  4619. {
  4620. guestList.Sex = "Female";
  4621. }
  4622. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4623. if (!string.IsNullOrEmpty(dele.Job))
  4624. {
  4625. guestList.Job = dele.Job;
  4626. }
  4627. list.Add(guestList);
  4628. }
  4629. //载入模板
  4630. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4631. DocumentBuilder builder = new DocumentBuilder(doc);
  4632. //获取word里所有表格
  4633. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4634. //获取所填表格的序数
  4635. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4636. var rowStart = tableOne.Rows[0]; //获取第1行
  4637. //循环赋值
  4638. for (int i = 0; i < list.Count; i++)
  4639. {
  4640. builder.MoveToCell(0, i + 1, 0, 0);
  4641. builder.Write(list[i].Name.ToString());
  4642. builder.MoveToCell(0, i + 1, 1, 0);
  4643. builder.Write(list[i].Sex.ToString());
  4644. builder.MoveToCell(0, i + 1, 2, 0);
  4645. builder.Write(list[i].DOB.ToString());
  4646. builder.MoveToCell(0, i + 1, 3, 0);
  4647. builder.Write(list[i].Job.ToString());
  4648. }
  4649. //删除多余行
  4650. while (tableOne.Rows.Count > list.Count + 1)
  4651. {
  4652. tableOne.Rows.RemoveAt(list.Count + 1);
  4653. }
  4654. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4655. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4656. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4657. doc.Save(filePath);
  4658. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4659. return Ok(JsonView(true, "操作成功!", Url));
  4660. }
  4661. else
  4662. {
  4663. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4664. }
  4665. }
  4666. catch (Exception ex)
  4667. {
  4668. return Ok(JsonView(false, ex.Message));
  4669. throw;
  4670. }
  4671. }
  4672. #endregion
  4673. #region 团组经理模块 出入境费用
  4674. /// <summary>
  4675. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4676. /// </summary>
  4677. /// <returns></returns>
  4678. [HttpPost]
  4679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4680. public async Task<IActionResult> SetDayAndCostAreaChange()
  4681. {
  4682. try
  4683. {
  4684. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4685. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4686. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4687. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4688. foreach (var item in unite) //处理交集数据
  4689. {
  4690. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4691. }
  4692. foreach (var item in merge) //处理差集数据
  4693. {
  4694. int nationalTravelFeeId = 0;
  4695. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4696. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4697. else
  4698. {
  4699. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4700. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4701. }
  4702. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4703. }
  4704. //只更新dayAndCost 的 nationalTravelFeeId;
  4705. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4706. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4707. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4708. }
  4709. catch (Exception ex)
  4710. {
  4711. return Ok(JsonView(false, ex.Message));
  4712. throw;
  4713. }
  4714. }
  4715. /// <summary>
  4716. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4717. /// </summary>
  4718. /// <returns></returns>
  4719. [HttpPost]
  4720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4721. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4722. {
  4723. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4724. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4725. //SetDataInfoView
  4726. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4727. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4728. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4729. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4730. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4731. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4732. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4733. //默认币种显示
  4734. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4735. {
  4736. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4737. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4738. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4739. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4740. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4741. };
  4742. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  4743. if (_currencyRate.Count > 0)
  4744. {
  4745. foreach (var item in _currencyInfos)
  4746. {
  4747. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4748. if (rateInfo != null)
  4749. {
  4750. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4751. if (rateInfo.Name.Equals("日元")) rate1 *= 1.3700M;
  4752. else rate1 *= 1.035M;
  4753. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4754. }
  4755. }
  4756. }
  4757. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4758. return Ok(JsonView(true, "查询成功!", new
  4759. {
  4760. GroupNameData = groupNameData.Data,
  4761. CurrencyData = _CurrencyData,
  4762. WordTypeData = _WordTypeData,
  4763. ExcelTypeData = _ExcelTypeData,
  4764. CurrencyInit = _currencyInfos,
  4765. ViewPermissionData = viewPermissionData
  4766. }));
  4767. }
  4768. /// <summary>
  4769. /// 团组模块 - 出入境费用
  4770. /// 实时汇率 tips
  4771. /// 签证费用 tips
  4772. /// 机票费用 tips
  4773. /// </summary>
  4774. /// <returns></returns>
  4775. [HttpPost]
  4776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4777. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4778. {
  4779. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4780. //默认币种显示
  4781. var _currencyInfos = _currencyInit;
  4782. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  4783. List<dynamic> reteInfos = new List<dynamic>();
  4784. if (_currencyRate.Count > 0)
  4785. {
  4786. foreach (var item in _currencyInfos)
  4787. {
  4788. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4789. if (rateInfo != null)
  4790. {
  4791. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4792. decimal rate1 = item.Rate;
  4793. rate1 *= 1.03M;
  4794. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4795. reteInfos.Add(new
  4796. {
  4797. currCode = item.CurrencyCode,
  4798. currName = item.CurrencyName,
  4799. rate = rate2,
  4800. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4801. });
  4802. }
  4803. }
  4804. }
  4805. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4806. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4807. return Ok(JsonView(true, "查询成功!", new
  4808. {
  4809. //GroupNameData = groupNameData.Data,
  4810. visaData = visaData.Data,
  4811. airData = airData.Data,
  4812. reteInfos = reteInfos
  4813. }));
  4814. }
  4815. /// <summary>
  4816. /// 团组模块 - 出入境费用 - Info
  4817. /// </summary>
  4818. /// <returns></returns>
  4819. [HttpPost]
  4820. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  4821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4822. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4823. {
  4824. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4825. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4826. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4827. }
  4828. /// <summary>
  4829. /// 团组模块 - 出入境费用 - 设置view权限
  4830. /// </summary>
  4831. /// <returns></returns>
  4832. [HttpPost]
  4833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4834. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4835. {
  4836. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4837. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4838. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4839. var permissions = new List<Grp_EnterExitCostPermission>();
  4840. foreach (var userId in dto.UserIds)
  4841. {
  4842. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  4843. }
  4844. if (permissions.Any())
  4845. {
  4846. _sqlSugar.BeginTran();
  4847. try
  4848. {
  4849. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  4850. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  4851. if (result < 1)
  4852. {
  4853. _sqlSugar.RollbackTran();
  4854. return Ok(JsonView(false));
  4855. }
  4856. }
  4857. catch (Exception ex)
  4858. {
  4859. _sqlSugar.RollbackTran();
  4860. return Ok(JsonView(false, ex.Message));
  4861. }
  4862. _sqlSugar.CommitTran();
  4863. return Ok(JsonView(true));
  4864. }
  4865. return Ok(JsonView(false));
  4866. }
  4867. /// <summary>
  4868. /// 团组模块 - 出入境费用 - Add And Update
  4869. /// </summary>
  4870. /// <returns></returns>
  4871. [HttpPost]
  4872. [ApiLog("Grp_EnterExitCost",OperationEnum.Add)]
  4873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4874. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4875. {
  4876. try
  4877. {
  4878. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4879. if (dto.DayOtherPriceData.Any())
  4880. {
  4881. var inserList = dto.DayOtherPriceData
  4882. .Where(x => x.Id == 0)
  4883. .Select(x => new Grp_DayOtherPrice
  4884. {
  4885. Cost = x.Cost,
  4886. Id = x.Id,
  4887. CreateTime = DateTime.Now,
  4888. CreateUserId = dto.UserId,
  4889. Currency = x.Currency,
  4890. Diid = x.DiId,
  4891. Index = x.Index,
  4892. IsDel = 0,
  4893. SetDataId = x.SetDataId,
  4894. SubTotal = x.SubTotal,
  4895. Remark = x.Remark
  4896. })
  4897. .ToList();
  4898. var updateList = dto.DayOtherPriceData
  4899. .Where(x => x.Id != 0)
  4900. .Select(x => new Grp_DayOtherPrice
  4901. {
  4902. Cost = x.Cost,
  4903. Id = x.Id,
  4904. CreateTime = DateTime.Now,
  4905. CreateUserId = dto.UserId,
  4906. Currency = x.Currency,
  4907. Diid = x.DiId,
  4908. Index = x.Index,
  4909. IsDel = 0,
  4910. SetDataId = x.SetDataId,
  4911. SubTotal = x.SubTotal,
  4912. Remark = x.Remark
  4913. })
  4914. .ToList();
  4915. //添加
  4916. _sqlSugar.BeginTran();
  4917. if (inserList.Any())
  4918. {
  4919. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4920. }
  4921. if (updateList.Any())
  4922. {
  4923. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4924. }
  4925. _sqlSugar.CommitTran();
  4926. }
  4927. if (data.Code != 0)
  4928. {
  4929. return Ok(JsonView(false, data.Msg));
  4930. }
  4931. //生成默认文件pdf并且通知人员
  4932. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4933. {
  4934. DiId = dto.DiId,
  4935. ExportType = 1,
  4936. SubTypeId = 1005
  4937. }, "pdf");
  4938. //发送通知
  4939. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4940. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4941. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4942. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4943. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4944. //汇率信息记录
  4945. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4946. return Ok(JsonView(true, data.Msg, data.Data));
  4947. }
  4948. catch (Exception ex)
  4949. {
  4950. return Ok(JsonView(false, ex.Message));
  4951. }
  4952. }
  4953. /// <summary>
  4954. /// 团组模块 - 出入境费用 - Confirm 费用
  4955. /// </summary>
  4956. /// <returns></returns>
  4957. [HttpPost]
  4958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4959. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4960. {
  4961. //TODO:测试完毕需把对应的用户ID更改
  4962. //1、数据表添加字段
  4963. //2、更改字段接口()
  4964. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4965. //3、确认成功 给财务发送消息
  4966. if (_view.Code == 200)
  4967. {
  4968. if (dto.Type == 1)
  4969. {
  4970. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4971. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4972. }
  4973. }
  4974. return Ok(_view);
  4975. }
  4976. /// <summary>
  4977. /// 团组模块 - 出入境费用 - File download
  4978. /// </summary>
  4979. /// <param name="dto"></param>
  4980. /// <returns></returns>
  4981. [HttpPost]
  4982. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  4983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4984. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4985. {
  4986. try
  4987. {
  4988. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4989. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4990. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4991. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4992. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4993. 3 团组成员名单 1 团组成员名单", ""));
  4994. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  4995. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4996. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4997. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  4998. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  4999. //数据源
  5000. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  5001. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  5002. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  5003. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  5004. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  5005. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  5006. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  5007. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  5008. .Select((x, a, b) => new
  5009. {
  5010. x.Index,
  5011. itemName = a.Name,
  5012. CurrencyStr = b.Name,
  5013. x.Cost,
  5014. x.SubTotal,
  5015. x.Remark
  5016. })
  5017. .OrderBy((x) => x.Index)
  5018. .ToList(); //其他款项费用
  5019. var peiceItemCurrencys = new List<string>();
  5020. if (_DayAndCosts.Any())
  5021. {
  5022. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  5023. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  5024. }
  5025. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  5026. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  5027. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  5028. {
  5029. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  5030. }
  5031. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5032. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5033. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5034. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5035. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5036. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5037. .Select((tcl, dc, cc) => new ClientInfo
  5038. {
  5039. LastName = dc.LastName,
  5040. FirstName = dc.FirstName,
  5041. Sex = dc.Sex,
  5042. Birthday = dc.BirthDay,
  5043. Company = cc.CompanyFullName,
  5044. Job = dc.Job
  5045. })
  5046. .ToList();
  5047. foreach (var item in DeleClientList)
  5048. {
  5049. EncryptionProcessor.DecryptProperties(item);
  5050. }
  5051. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5052. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5053. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5054. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5055. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5056. if (dto.ExportType == 1) //明细表
  5057. {
  5058. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5059. {
  5060. //获取模板
  5061. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5062. //载入模板
  5063. Document doc = new Document(tempPath);
  5064. DocumentBuilder builder = new DocumentBuilder(doc);
  5065. //利用键值对存放数据
  5066. Dictionary<string, string> dic = new Dictionary<string, string>();
  5067. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5068. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5069. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5070. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5071. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5072. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5073. //境内费用(其他费用)
  5074. if (_EnterExitCosts.ChoiceOne == 1)
  5075. {
  5076. string row1_1 = "";
  5077. if (_EnterExitCosts.Visa > 0)
  5078. {
  5079. //insidePayTotal += _EnterExitCosts.Visa;
  5080. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5081. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5082. {
  5083. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5084. }
  5085. }
  5086. string row1_2 = "";
  5087. if (_EnterExitCosts.YiMiao > 0)
  5088. {
  5089. //insidePayTotal += _EnterExitCosts.YiMiao;
  5090. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5091. }
  5092. if (_EnterExitCosts.HeSuan > 0)
  5093. {
  5094. //insidePayTotal += _EnterExitCosts.HeSuan;
  5095. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5096. }
  5097. if (_EnterExitCosts.Service > 0)
  5098. {
  5099. //insidePayTotal += _EnterExitCosts.Service;
  5100. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5101. }
  5102. string row1_3 = "";
  5103. if (_EnterExitCosts.Safe > 0)
  5104. {
  5105. //insidePayTotal += _EnterExitCosts.Safe;
  5106. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5107. }
  5108. if (_EnterExitCosts.Ticket > 0)
  5109. {
  5110. //insidePayTotal += _EnterExitCosts.Ticket;
  5111. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5112. }
  5113. string row1 = "";
  5114. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5115. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5116. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5117. row1 += $"备注:{_EnterExitCosts.Remark}";
  5118. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5119. dic.Add("Row1Str", row1);
  5120. }
  5121. string airTotalStr = string.Empty,
  5122. airPriceStr = string.Empty;
  5123. //经济舱
  5124. if (_EnterExitCosts.SumJJC == 1)
  5125. {
  5126. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5127. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5128. }
  5129. //公务舱
  5130. if (_EnterExitCosts.SumGWC == 1)
  5131. {
  5132. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5133. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5134. }
  5135. //头等舱
  5136. if (_EnterExitCosts.SumTDC == 1)
  5137. {
  5138. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5139. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5140. }
  5141. //汇率描述
  5142. string rateStr = "";
  5143. if (peiceItemCurrencyInfos.Any())
  5144. {
  5145. rateStr = "\r\n汇率描述:";
  5146. foreach (var item in peiceItemCurrencyInfos)
  5147. {
  5148. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  5149. }
  5150. }
  5151. string twoItemRemark = "备注:";
  5152. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  5153. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  5154. dic.Add("AirTotalStr", airTotalStr);
  5155. dic.Add("AirPriceStr", airPriceStr);
  5156. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5157. dic.Add("TwoItemRemark", twoItemRemark);
  5158. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5159. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5160. int table1Row = 0,
  5161. table2Row = 0,
  5162. table3Row = 0,
  5163. table4Row = 0,
  5164. table5Row = 0;
  5165. //住宿费
  5166. if (_EnterExitCosts.ChoiceThree == 1)
  5167. {
  5168. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5169. table1Row = dac1.Count;
  5170. #region 填充word表格内容
  5171. for (int i = 0; i < dac1.Count; i++)
  5172. {
  5173. Grp_DayAndCost dac = dac1[i];
  5174. if (dac == null) continue;
  5175. builder.MoveToCell(0, i, 0, 0);
  5176. builder.Write("第" + dac.Days.ToString() + "晚:");
  5177. builder.MoveToCell(0, i, 1, 0);
  5178. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5179. //builder.Write(dac.Place == null ? "" : dac.Place);
  5180. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5181. builder.MoveToCell(0, i, 2, 0);
  5182. builder.Write("费用标准:");
  5183. string curr = "";
  5184. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5185. if (currData != null)
  5186. {
  5187. curr = currData.Name;
  5188. }
  5189. builder.MoveToCell(0, i, 3, 0);
  5190. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5191. builder.MoveToCell(0, i, 4, 0);
  5192. builder.Write("费用小计:");
  5193. builder.MoveToCell(0, i, 5, 0);
  5194. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5195. }
  5196. #endregion
  5197. }
  5198. else dic.Add("SubZS", "0.00");
  5199. //删除多余行
  5200. while (table1.Rows.Count > table1Row)
  5201. {
  5202. table1.Rows.RemoveAt(table1Row);
  5203. }
  5204. //伙食费
  5205. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5206. if (_EnterExitCosts.ChoiceFour == 1)
  5207. {
  5208. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5209. table2Row = dac2.Count;
  5210. #region 填充word表格内容
  5211. for (int i = 0; i < dac2.Count; i++)
  5212. {
  5213. Grp_DayAndCost dac = dac2[i];
  5214. if (dac == null) continue;
  5215. builder.MoveToCell(1, i, 0, 0);
  5216. builder.Write("第" + dac.Days.ToString() + "天:");
  5217. builder.MoveToCell(1, i, 1, 0);
  5218. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5219. builder.MoveToCell(1, i, 2, 0);
  5220. builder.Write("费用标准:");
  5221. string curr = "";
  5222. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5223. if (currData != null)
  5224. {
  5225. curr = currData.Name;
  5226. }
  5227. builder.MoveToCell(1, i, 3, 0);
  5228. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5229. builder.MoveToCell(1, i, 4, 0);
  5230. builder.Write("费用小计:");
  5231. builder.MoveToCell(1, i, 5, 0);
  5232. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5233. }
  5234. #endregion
  5235. }
  5236. else dic.Add("SubHS", "0.00");
  5237. //删除多余行
  5238. while (table2.Rows.Count > table2Row)
  5239. {
  5240. table2.Rows.RemoveAt(table2Row);
  5241. }
  5242. //公杂费
  5243. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5244. if (_EnterExitCosts.ChoiceFive == 1)
  5245. {
  5246. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5247. table3Row = dac3.Count;
  5248. #region 填充word表格内容
  5249. for (int i = 0; i < dac3.Count; i++)
  5250. {
  5251. Grp_DayAndCost dac = dac3[i];
  5252. if (dac == null) continue;
  5253. builder.MoveToCell(2, i, 0, 0);
  5254. builder.Write("第" + dac.Days.ToString() + "天:");
  5255. builder.MoveToCell(2, i, 1, 0);
  5256. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5257. builder.MoveToCell(2, i, 2, 0);
  5258. builder.Write("费用标准:");
  5259. string curr = "";
  5260. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5261. if (currData != null)
  5262. {
  5263. curr = currData.Name;
  5264. }
  5265. builder.MoveToCell(2, i, 3, 0);
  5266. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5267. builder.MoveToCell(2, i, 4, 0);
  5268. builder.Write("费用小计:");
  5269. builder.MoveToCell(2, i, 5, 0);
  5270. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5271. }
  5272. //删除多余行
  5273. while (table3.Rows.Count > table3Row)
  5274. {
  5275. table3.Rows.RemoveAt(table3Row);
  5276. }
  5277. #endregion
  5278. }
  5279. else dic.Add("SubGZF", "0.00");
  5280. //删除多余行
  5281. while (table3.Rows.Count > table3Row)
  5282. {
  5283. table3.Rows.RemoveAt(table3Row);
  5284. }
  5285. //培训费
  5286. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5287. if (_EnterExitCosts.ChoiceSix == 1)
  5288. {
  5289. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5290. dic.Add("SubPX", pxStr);
  5291. table4Row = dac4.Count;
  5292. #region 填充word表格内容
  5293. for (int i = 0; i < dac4.Count; i++)
  5294. {
  5295. Grp_DayAndCost dac = dac4[i];
  5296. if (dac == null) continue;
  5297. builder.MoveToCell(3, i, 0, 0);
  5298. builder.Write("第" + dac.Days.ToString() + "天:");
  5299. builder.MoveToCell(3, i, 1, 0);
  5300. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5301. builder.MoveToCell(3, i, 2, 0);
  5302. builder.Write("费用标准:");
  5303. string curr = "";
  5304. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5305. if (currData != null)
  5306. {
  5307. curr = currData.Name;
  5308. }
  5309. builder.MoveToCell(3, i, 3, 0);
  5310. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5311. builder.MoveToCell(3, i, 4, 0);
  5312. builder.Write("费用小计:");
  5313. builder.MoveToCell(3, i, 5, 0);
  5314. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5315. }
  5316. #endregion
  5317. }
  5318. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  5319. //删除多余行
  5320. while (table4.Rows.Count > table4Row)
  5321. {
  5322. table4.Rows.RemoveAt(table4Row);
  5323. }
  5324. //其他费用
  5325. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5326. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5327. {
  5328. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5329. dic.Add("titleQi", qtStr);
  5330. table5Row = dac5.Count;
  5331. #region 填充word表格内容
  5332. for (int i = 0; i < dac5.Count; i++)
  5333. {
  5334. var dac = dac5[i];
  5335. if (dac == null) continue;
  5336. builder.MoveToCell(4, i, 0, 0);
  5337. builder.Write("第" + dac.Index.ToString() + "项:");
  5338. builder.MoveToCell(4, i, 1, 0);
  5339. builder.Write(dac.itemName);
  5340. builder.MoveToCell(4, i, 2, 0);
  5341. builder.Write("费用标准:");
  5342. builder.MoveToCell(4, i, 3, 0);
  5343. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5344. builder.MoveToCell(4, i, 4, 0);
  5345. builder.Write("费用小计:");
  5346. builder.MoveToCell(4, i, 5, 0);
  5347. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5348. builder.MoveToCell(4, i, 6, 0);
  5349. builder.Write("备注:");
  5350. builder.MoveToCell(4, i, 7, 0);
  5351. builder.Write(dac.Remark);
  5352. }
  5353. #endregion
  5354. }
  5355. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5356. //删除多余行
  5357. while (table5.Rows.Count > table5Row)
  5358. {
  5359. table5.Rows.RemoveAt(table5Row);
  5360. }
  5361. //加上其他费用
  5362. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5363. decimal subJJC = 0.00M,
  5364. subGWC = 0.00M,
  5365. subTDC = 0.00M;
  5366. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  5367. string totalLabel = string.Format("全部费用总计:");
  5368. //经济舱
  5369. if (_EnterExitCosts.SumJJC == 1)
  5370. {
  5371. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5372. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  5373. }
  5374. //公务舱
  5375. if (_EnterExitCosts.SumGWC == 1) {
  5376. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5377. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  5378. }
  5379. //头等舱
  5380. if (_EnterExitCosts.SumTDC == 1)
  5381. {
  5382. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5383. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  5384. }
  5385. //TotalLabel
  5386. dic.Add("TotalLabel", totalLabel);
  5387. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5388. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5389. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5390. #region 填充word模板书签内容
  5391. foreach (var key in dic.Keys)
  5392. {
  5393. Bookmark bookmark = doc.Range.Bookmarks[key];
  5394. if (bookmark != null)
  5395. {
  5396. builder.MoveToBookmark(key);
  5397. builder.Write(dic[key]);
  5398. }
  5399. }
  5400. #endregion
  5401. #region 设置页眉
  5402. string userLabel = string.Empty;
  5403. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5404. if (currUserInfo != null)
  5405. {
  5406. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5407. if (userInfo != null)
  5408. {
  5409. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5410. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5411. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5412. }
  5413. }
  5414. //设置页脚
  5415. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5416. #endregion
  5417. //文件名
  5418. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5419. AsposeHelper.removewatermark_v2180();
  5420. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5421. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5422. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5423. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5424. }
  5425. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5426. {
  5427. //获取模板
  5428. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5429. //载入模板
  5430. Document doc = new Document(tempPath);
  5431. DocumentBuilder builder = new DocumentBuilder(doc);
  5432. Dictionary<string, string> dic = new Dictionary<string, string>();
  5433. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5434. {
  5435. List<string> list = new List<string>();
  5436. try
  5437. {
  5438. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5439. foreach (var item in spilitArr)
  5440. {
  5441. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5442. var depCode = spDotandEmpty[2].Substring(0, 3);
  5443. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5444. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5445. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5446. list.Add(depName);
  5447. list.Add(arrName);
  5448. }
  5449. list = list.Distinct().ToList();
  5450. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5451. }
  5452. catch (Exception)
  5453. {
  5454. dic.Add("ReturnCode", "行程录入不正确!");
  5455. }
  5456. }
  5457. else
  5458. {
  5459. dic.Add("ReturnCode", "未录入行程!");
  5460. }
  5461. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5462. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5463. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5464. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5465. {
  5466. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5467. dic.Add("Day", sp.Days.ToString());
  5468. }
  5469. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5470. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5471. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5472. //dic.Add("Names", Names);
  5473. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5474. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5475. decimal dac1totalPrice = 0.00M;
  5476. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5477. foreach (var dac in dac1)
  5478. {
  5479. if (dac.SubTotal == 0.00M)
  5480. {
  5481. continue;
  5482. }
  5483. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5484. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5485. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5486. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5487. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5488. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5489. builder.Write(currency);//币种
  5490. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5491. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5492. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5493. builder.Write("");//人数
  5494. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5495. builder.Write("");//天数
  5496. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5497. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5498. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5499. decimal rate = 0.00M;
  5500. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5501. builder.Write(rate.ToString("#0.0000"));//汇率
  5502. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5503. decimal rbmPrice = dac.SubTotal;
  5504. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5505. accommodationStartIndex++;
  5506. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5507. }
  5508. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5509. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5510. {
  5511. table1.Rows.RemoveAt(i - 1);
  5512. foodandotherStartIndex--;
  5513. }
  5514. if (dac2.Count == dac3.Count)//国家 币种 金额
  5515. {
  5516. for (int i = 0; i < dac2.Count; i++)
  5517. {
  5518. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5519. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5520. }
  5521. }
  5522. decimal dac2totalPrice = 0.00M;
  5523. foreach (var dac in dac2)
  5524. {
  5525. if (dac.SubTotal == 0)
  5526. {
  5527. continue;
  5528. }
  5529. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5530. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5531. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5532. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5533. builder.Write(currency);//币种
  5534. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5535. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5536. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5537. builder.Write("");//人数
  5538. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5539. builder.Write("");//天数
  5540. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5541. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5542. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5543. decimal rate = 0.00M;
  5544. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5545. builder.Write(rate.ToString("#0.0000"));//汇率
  5546. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5547. decimal rbmPrice = dac.SubTotal;
  5548. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5549. foodandotherStartIndex++;
  5550. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5551. }
  5552. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5553. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5554. {
  5555. table1.Rows.RemoveAt(i - 1);
  5556. }
  5557. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5558. string otherFeeStr = "";
  5559. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5560. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5561. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5562. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5563. foreach (var otherInfo in dac5)
  5564. {
  5565. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5566. }
  5567. #endregion
  5568. if (otherFeeStr.Length > 0)
  5569. {
  5570. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5571. otherFeeStr = $"({otherFeeStr})";
  5572. dic.Add("OtherFeeStr", otherFeeStr);
  5573. }
  5574. //总计
  5575. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5576. //国际旅费
  5577. string outsideAir = string.Empty;
  5578. string allPriceAir = string.Empty;
  5579. if (_EnterExitCosts.SumJJC == 1)
  5580. {
  5581. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5582. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5583. }
  5584. if (_EnterExitCosts.SumGWC == 1)
  5585. {
  5586. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5587. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5588. }
  5589. if (_EnterExitCosts.SumTDC == 1)
  5590. {
  5591. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5592. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5593. }
  5594. dic.Add("InTravelPrice", $"({outsideAir})");
  5595. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5596. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5597. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5598. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5599. foreach (var key in dic.Keys)
  5600. {
  5601. builder.MoveToBookmark(key);
  5602. builder.Write(dic[key]);
  5603. }
  5604. //模板文件名
  5605. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5606. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5607. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5608. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5609. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5610. }
  5611. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5612. {
  5613. //获取模板
  5614. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5615. //载入模板
  5616. WorkbookDesigner designer = new WorkbookDesigner();
  5617. designer.Workbook = new Workbook(tempPath);
  5618. Dictionary<string, string> dic = new Dictionary<string, string>();
  5619. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5620. {
  5621. List<string> list = new List<string>();
  5622. try
  5623. {
  5624. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5625. foreach (var item in spilitArr)
  5626. {
  5627. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5628. var depCode = spDotandEmpty[2].Substring(0, 3);
  5629. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5630. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5631. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5632. list.Add(depName);
  5633. list.Add(arrName);
  5634. }
  5635. list = list.Distinct().ToList();
  5636. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5637. }
  5638. catch (Exception)
  5639. {
  5640. dic.Add("ReturnCode", "行程录入不正确!");
  5641. }
  5642. }
  5643. else
  5644. {
  5645. dic.Add("ReturnCode", "未录入行程!");
  5646. }
  5647. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5648. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5649. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5650. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5651. {
  5652. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5653. dic.Add("Day", sp.Days.ToString());
  5654. }
  5655. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5656. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5657. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5658. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5659. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5660. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5661. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5662. designer.SetDataSource("Name", Names);
  5663. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5664. designer.SetDataSource("Day", dic["Day"] + "天");
  5665. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5666. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5667. int startIndex = 10;
  5668. const int startIndexcopy = 10;
  5669. if (dac2.Count == dac3.Count)//国家 币种 金额
  5670. {
  5671. for (int i = 0; i < dac2.Count; i++)
  5672. {
  5673. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5674. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5675. }
  5676. }
  5677. DataTable dtdac1 = new DataTable();
  5678. List<string> place = new List<string>();
  5679. dtdac1.Columns.AddRange(new DataColumn[] {
  5680. new DataColumn(){ ColumnName = "city"},
  5681. new DataColumn(){ ColumnName = "curr"},
  5682. new DataColumn(){ ColumnName = "criterion"},
  5683. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5684. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5685. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5686. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5687. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5688. });
  5689. DataTable dtdac2 = new DataTable();
  5690. dtdac2.Columns.AddRange(new DataColumn[] {
  5691. new DataColumn(){ ColumnName = "city"},
  5692. new DataColumn(){ ColumnName = "curr"},
  5693. new DataColumn(){ ColumnName = "criterion"},
  5694. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5695. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5696. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5697. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5698. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5699. });
  5700. dtdac1.TableName = "tb1";
  5701. dtdac2.TableName = "tb2";
  5702. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5703. foreach (var item in dac1)
  5704. {
  5705. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5706. if (place.Contains(item.Place))
  5707. {
  5708. continue;
  5709. }
  5710. DataRow row = dtdac1.NewRow();
  5711. row["city"] = item.Place;
  5712. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5713. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5714. row["curr"] = currency;
  5715. row["rate"] = rate.ToString("#0.0000");
  5716. row["criterion"] = item.Cost.ToString("#0.00");
  5717. row["number"] = 1;
  5718. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5719. //row["costRMB"] = rbmPrice;
  5720. dtdac1.Rows.Add(row);
  5721. place.Add(item.Place);
  5722. }
  5723. place = new List<string>();
  5724. foreach (var item in dac2)
  5725. {
  5726. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5727. if (place.Contains(item.Place))
  5728. {
  5729. continue;
  5730. }
  5731. DataRow row = dtdac2.NewRow();
  5732. row["city"] = item.Place;
  5733. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5734. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5735. row["curr"] = currency;
  5736. row["rate"] = rate.ToString("#0.0000");
  5737. row["criterion"] = item.Cost.ToString("#0.00");
  5738. row["number"] = 1;
  5739. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5740. //row["cost"] = item.SubTotal;
  5741. //row["costRMB"] = rbmPrice;
  5742. dtdac2.Rows.Add(row);
  5743. place.Add(item.Place);
  5744. //dac2totalPrice += rbmPrice;
  5745. }
  5746. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5747. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5748. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5749. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5750. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5751. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5752. string cell4Str1 = string.Empty;
  5753. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5754. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5755. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5756. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5757. string cellStr = $" 5.其他费用(";
  5758. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5759. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5760. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5761. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5762. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5763. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5764. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5765. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5766. foreach (var otherInfo in dac5)
  5767. {
  5768. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5769. }
  5770. #endregion
  5771. if (cellStr.Length > 8)
  5772. {
  5773. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5774. }
  5775. cellStr += ")";
  5776. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5777. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5778. decimal pxFee = dac4.Sum(it => it.Cost);
  5779. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5780. string celllastStr1 = "";
  5781. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5782. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5783. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5784. celllastStr1 += $",国际旅费 元";
  5785. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5786. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5787. designer.SetDataSource("cell4Str", cell4Str);
  5788. designer.SetDataSource("cellStr", cellStr);
  5789. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5790. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5791. designer.SetDataSource("celllastStr", celllastStr);
  5792. Workbook wb = designer.Workbook;
  5793. var sheet = wb.Worksheets[0];
  5794. //绑定datatable数据集
  5795. designer.SetDataSource(dtdac1);
  5796. designer.SetDataSource(dtdac2);
  5797. designer.Process();
  5798. var rowStart = dtdac1.Rows.Count;
  5799. while (rowStart > 0)
  5800. {
  5801. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5802. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5803. startIndex++;
  5804. rowStart--;
  5805. }
  5806. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5807. startIndex += 1; //总计行
  5808. rowStart = dtdac2.Rows.Count;
  5809. while (rowStart > 0)
  5810. {
  5811. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5812. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5813. startIndex++;
  5814. rowStart--;
  5815. }
  5816. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5817. wb.CalculateFormula(true);
  5818. //模板文件名
  5819. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5820. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5821. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5822. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5823. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5824. }
  5825. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5826. {
  5827. //获取模板
  5828. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5829. //载入模板
  5830. Document doc = new Document(tempPath);
  5831. DocumentBuilder builder = new DocumentBuilder(doc);
  5832. Dictionary<string, string> dic = new Dictionary<string, string>();
  5833. dic.Add("GroupName", _DelegationInfo.TeamName);
  5834. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5835. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5836. string missionLeaderJob = "";//负责人job
  5837. //int groupNumber = 0; //团人数
  5838. if (DeleClientList.Count > 0)
  5839. {
  5840. missionLeader = DeleClientList[0]?.Name ?? "";
  5841. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5842. }
  5843. dic.Add("MissionLeader", missionLeader); //团负责人
  5844. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5845. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5846. #region MyRegion
  5847. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5848. //{
  5849. // List<string> list = new List<string>();
  5850. // try
  5851. // {
  5852. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5853. // foreach (var item in spilitArr)
  5854. // {
  5855. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5856. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5857. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5858. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5859. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5860. // list.Add(depName);
  5861. // list.Add(arrName);
  5862. // }
  5863. // list = list.Distinct().ToList();
  5864. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5865. // }
  5866. // catch (Exception)
  5867. // {
  5868. // dic.Add("ReturnCode", "行程录入不正确!");
  5869. // }
  5870. //}
  5871. //else
  5872. //{
  5873. // dic.Add("ReturnCode", "未录入行程!");
  5874. //}
  5875. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5876. dic.Add("ReturnCode", string.Join("、", countrys));
  5877. #endregion
  5878. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5879. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5880. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5881. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5882. //{
  5883. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5884. // dic.Add("Day", sp.Days.ToString());
  5885. //}
  5886. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5887. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5888. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5889. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5890. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5891. //培训人员名单
  5892. int cultivateRowIndex = 7;
  5893. foreach (var item in DeleClientList)
  5894. {
  5895. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5896. builder.Write(item.Name);
  5897. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5898. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5899. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5900. string birthDay = "";
  5901. if (item.Birthday != null)
  5902. {
  5903. DateTime dt = Convert.ToDateTime(item.Birthday);
  5904. birthDay = $"{dt.Year}.{dt.Month}";
  5905. }
  5906. builder.Write(birthDay);
  5907. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5908. builder.Write(item.Company);
  5909. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5910. builder.Write(item.Job);
  5911. cultivateRowIndex++;
  5912. }
  5913. //删除多余行
  5914. //cultivateRowIndex -= 2;
  5915. int delRows = 10 + 7 - cultivateRowIndex;
  5916. if (delRows > 0)
  5917. {
  5918. for (int i = 0; i < delRows; i++)
  5919. {
  5920. table1.Rows.RemoveAt(cultivateRowIndex);
  5921. //cultivateRowIndex++;
  5922. }
  5923. }
  5924. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5925. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5926. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5927. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5928. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5929. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5930. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5931. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5932. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5933. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5934. //其他费用
  5935. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5936. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5937. //其他费用合计
  5938. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5939. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5940. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5941. //公务舱合计
  5942. //国际旅费
  5943. //string outsideJJ = "";
  5944. //string allPriceJJ = "";
  5945. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5946. {
  5947. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5948. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5949. }
  5950. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5951. {
  5952. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5953. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5954. }
  5955. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5956. {
  5957. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5958. dic.Add("AirFeeTotal", airFeeTotalStr);
  5959. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5960. dic.Add("FeeTotal", feeTotalStr);
  5961. }
  5962. foreach (var key in dic.Keys)
  5963. {
  5964. builder.MoveToBookmark(key);
  5965. builder.Write(dic[key]);
  5966. }
  5967. //模板文件名
  5968. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5969. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5970. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5971. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5972. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5973. }
  5974. }
  5975. else if (dto.ExportType == 2) //表格
  5976. {
  5977. //利用键值对存放数据
  5978. Dictionary<string, string> dic = new Dictionary<string, string>();
  5979. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5980. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5981. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5982. dic.Add("Day", sp.Days.ToString());
  5983. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5984. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5985. {
  5986. //获取模板
  5987. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5988. //载入模板
  5989. Document doc = new Document(tempPath);
  5990. DocumentBuilder builder = new DocumentBuilder(doc);
  5991. dic.Add("TeamName", _DelegationInfo.TeamName);
  5992. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5993. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5994. string missionLeaderName = "",
  5995. missionLeaderJob = "";
  5996. if (DeleClientList.Count > 0)
  5997. {
  5998. missionLeaderName = DeleClientList[0].Name;
  5999. missionLeaderJob = DeleClientList[0].Job;
  6000. }
  6001. dic.Add("MissionLeaderName", missionLeaderName);
  6002. dic.Add("MissionLeaderJob", missionLeaderJob);
  6003. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  6004. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  6005. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6006. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6007. int rowCount = 10;//总人数行
  6008. int startRowIndex = 7; //起始行
  6009. for (int i = 0; i < DeleClientList.Count; i++)
  6010. {
  6011. builder.MoveToCell(0, startRowIndex, 0, 0);
  6012. builder.Write(DeleClientList[i].Name); //出国人员姓名
  6013. builder.MoveToCell(0, startRowIndex, 1, 0);
  6014. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6015. builder.Write(sex);//性别
  6016. builder.MoveToCell(0, startRowIndex, 2, 0);
  6017. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  6018. builder.MoveToCell(0, startRowIndex, 3, 0);
  6019. builder.Write(DeleClientList[i].Company);//工作单位
  6020. builder.MoveToCell(0, startRowIndex, 4, 0);
  6021. builder.Write(DeleClientList[i].Job);//职务及级别
  6022. builder.MoveToCell(0, startRowIndex, 5, 0);
  6023. builder.Write("");//人员属性
  6024. builder.MoveToCell(0, startRowIndex, 6, 0);
  6025. builder.Write("");//上次出国时间
  6026. startRowIndex++;
  6027. }
  6028. int nullRow = rowCount - DeleClientList.Count;//空行
  6029. for (int i = 0; i < nullRow; i++)
  6030. {
  6031. table1.Rows.Remove(table1.Rows[startRowIndex]);
  6032. }
  6033. foreach (var key in dic.Keys)
  6034. {
  6035. builder.MoveToBookmark(key);
  6036. builder.Write(dic[key]);
  6037. }
  6038. //模板文件名
  6039. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  6040. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6041. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6042. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  6043. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  6044. }
  6045. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  6046. {
  6047. //获取模板
  6048. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  6049. //载入模板
  6050. Document doc = new Document(tempPath);
  6051. DocumentBuilder builder = new DocumentBuilder(doc);
  6052. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6053. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6054. dic.Add("Names", Names);
  6055. int accommodationRows = 12;
  6056. //int foodandotherRows = 12;
  6057. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6058. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6059. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6060. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6061. int accommodationStartIndex = 6;
  6062. decimal dac1totalPrice = 0.00M;
  6063. foreach (var dac in dac1)
  6064. {
  6065. if (dac.SubTotal == 0)
  6066. {
  6067. continue;
  6068. }
  6069. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6070. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6071. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6072. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6073. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6074. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6075. builder.Write(currency);//币种
  6076. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6077. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6078. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6079. builder.Write("");//人数
  6080. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6081. builder.Write("");//天数
  6082. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6083. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6084. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6085. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6086. builder.Write(rate.ToString("#0.0000"));//汇率
  6087. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6088. decimal rbmPrice = rate * dac.SubTotal;
  6089. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6090. accommodationStartIndex++;
  6091. dac1totalPrice += rbmPrice;
  6092. }
  6093. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6094. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6095. builder.Write("小计");
  6096. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6097. builder.Write(dac1totalPrice.ToString("#0.00"));
  6098. accommodationStartIndex++;
  6099. int nullRow = accommodationRows - dac1.Count;
  6100. //删除空行
  6101. //if (nullRow > 0)
  6102. //{
  6103. // int rowIndex = accommodationStartIndex;
  6104. // for (int i = 0; i < nullRow; i++)
  6105. // {
  6106. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6107. // row.Remove();
  6108. // rowIndex++;
  6109. // }
  6110. //}
  6111. if (dac2.Count == dac3.Count)//国家 币种 金额
  6112. {
  6113. for (int i = 0; i < dac2.Count; i++)
  6114. {
  6115. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6116. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6117. }
  6118. }
  6119. int foodandotherStartIndex = 19;//
  6120. decimal dac2totalPrice = 0.00M;
  6121. foreach (var dac in dac2)
  6122. {
  6123. if (dac.SubTotal == 0)
  6124. {
  6125. continue;
  6126. }
  6127. //foodandotherStartIndex = 12;
  6128. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6129. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6130. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6131. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6132. builder.Write(currency);//币种
  6133. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6134. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6135. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6136. builder.Write("");//人数
  6137. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6138. builder.Write("");//天数
  6139. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6140. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6141. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6142. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6143. builder.Write(rate.ToString("#0.0000"));//汇率
  6144. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6145. decimal rbmPrice = rate * dac.SubTotal;
  6146. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6147. foodandotherStartIndex++;
  6148. dac2totalPrice += rbmPrice;
  6149. }
  6150. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6151. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6152. //删除空行
  6153. //if (dac2.Count < foodandotherRows)
  6154. //{
  6155. // while (table2.Rows.Count > dac2.Count)
  6156. // {
  6157. // table2.Rows.RemoveAt(dac2.Count);
  6158. // }
  6159. //}
  6160. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6161. string otherFeeStr = "";
  6162. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6163. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6164. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6165. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6166. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6167. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6168. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6169. foreach (var otherInfo in dac5)
  6170. {
  6171. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6172. }
  6173. #endregion
  6174. if (otherFeeStr.Length > 0)
  6175. {
  6176. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6177. otherFeeStr = $"({otherFeeStr})";
  6178. dic.Add("OtherFeeStr", otherFeeStr);
  6179. }
  6180. foreach (var key in dic.Keys)
  6181. {
  6182. builder.MoveToBookmark(key);
  6183. builder.Write(dic[key]);
  6184. }
  6185. //模板文件名
  6186. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6187. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6188. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6189. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6190. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6191. }
  6192. }
  6193. else if (dto.ExportType == 3)
  6194. {
  6195. if (dto.SubTypeId == 1) //团组成员名单
  6196. {
  6197. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6198. //获取模板
  6199. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6200. //载入模板
  6201. Document doc = new Document(tempPath);
  6202. DocumentBuilder builder = new DocumentBuilder(doc);
  6203. //获取word里所有表格
  6204. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6205. //获取所填表格的序数
  6206. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6207. var rowStart = tableOne.Rows[0]; //获取第1行
  6208. //循环赋值
  6209. for (int i = 0; i < DeleClientList.Count; i++)
  6210. {
  6211. builder.MoveToCell(0, i + 1, 0, 0);
  6212. builder.Write(DeleClientList[i].Name);
  6213. builder.MoveToCell(0, i + 1, 1, 0);
  6214. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6215. builder.Write(sex);
  6216. builder.MoveToCell(0, i + 1, 2, 0);
  6217. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6218. builder.MoveToCell(0, i + 1, 3, 0);
  6219. builder.Write(DeleClientList[i].Company);
  6220. builder.MoveToCell(0, i + 1, 4, 0);
  6221. builder.Write(DeleClientList[i].Job);
  6222. }
  6223. //删除多余行
  6224. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6225. {
  6226. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6227. }
  6228. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6229. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6230. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6231. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6232. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6233. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6234. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6235. }
  6236. }
  6237. return Ok(JsonView(400, "操作失败!", ""));
  6238. }
  6239. catch (Exception ex)
  6240. {
  6241. return Ok(JsonView(400, ex.Message, ""));
  6242. }
  6243. }
  6244. /// <summary>
  6245. /// 获取三公费用标准city
  6246. /// </summary>
  6247. /// <param name="placeData"></param>
  6248. /// <param name="nationalTravelFeeId"></param>
  6249. /// <returns></returns>
  6250. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6251. {
  6252. string _city = string.Empty;
  6253. if (placeData.Count < 1) return _city;
  6254. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6255. if (data == null) return _city;
  6256. string country = data.Country;
  6257. string city = data.City;
  6258. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6259. else _city = city;
  6260. return _city;
  6261. }
  6262. /// <summary>
  6263. /// 团组模块 - 出入境费用 - 明细表导出
  6264. /// </summary>
  6265. /// <returns></returns>
  6266. [HttpPost]
  6267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6268. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6269. {
  6270. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6271. if (data.Code != 0)
  6272. {
  6273. return Ok(JsonView(false, data.Msg));
  6274. }
  6275. return Ok(JsonView(true, data.Msg, data.Data));
  6276. }
  6277. /// <summary>
  6278. /// 团组模块 - 出入境费用 - 一键清空
  6279. /// </summary>
  6280. /// <returns></returns>
  6281. [HttpPost]
  6282. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6284. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6285. {
  6286. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6287. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6288. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6289. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6290. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6291. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6292. .SetColumns(x => new Grp_DayOtherPrice
  6293. {
  6294. IsDel = 1,
  6295. DeleteUserId = dto.UserId,
  6296. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6297. })
  6298. .ExecuteCommandAsync();
  6299. if (_view.Code == 0)
  6300. {
  6301. return Ok(JsonView(true, "操作成功"));
  6302. }
  6303. return Ok(JsonView(false, "操作失败"));
  6304. }
  6305. /// <summary>
  6306. /// 团组模块 - 出入境费用 - 子项删除
  6307. /// </summary>
  6308. /// <returns></returns>
  6309. [HttpPost]
  6310. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6311. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6312. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6313. {
  6314. try
  6315. {
  6316. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6317. if (data.Code != 0)
  6318. {
  6319. return Ok(JsonView(false, data.Msg));
  6320. }
  6321. return Ok(JsonView(true, "操作成功!", data.Data));
  6322. }
  6323. catch (Exception ex)
  6324. {
  6325. return Ok(JsonView(false, ex.Message));
  6326. }
  6327. }
  6328. /// <summary>
  6329. /// 删除三公其他费用
  6330. /// </summary>
  6331. /// <param name="dto"></param>
  6332. /// <returns></returns>
  6333. [HttpPost]
  6334. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6335. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6336. {
  6337. var jw = JsonView(false, "删除失败!");
  6338. var data = new Grp_DayOtherPrice()
  6339. {
  6340. Id = dto.Id,
  6341. IsDel = 1,
  6342. DeleteUserId = dto.DeleteUserId,
  6343. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6344. };
  6345. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6346. if (del > 0)
  6347. {
  6348. jw.Code = 200;
  6349. jw.Msg = "删除成功!";
  6350. }
  6351. return Ok(jw);
  6352. }
  6353. /// <summary>
  6354. /// 团组模块 - 出入境国家费用标准 List
  6355. /// </summary>
  6356. /// <returns></returns>
  6357. [HttpPost]
  6358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6359. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6360. {
  6361. try
  6362. {
  6363. Stopwatch sw = new Stopwatch();
  6364. sw.Start();
  6365. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6366. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6367. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6368. Where gntf.Isdel = 0");
  6369. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6370. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6371. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6372. //foreach (var item in nationalTravel)
  6373. //{
  6374. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6375. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6376. // if (otherData != null)
  6377. // {
  6378. // cityData.Remove(otherData);
  6379. // cityData.Add(otherData);
  6380. // }
  6381. // nationalTravelFeeData1.Add(new
  6382. // {
  6383. // Country = item.Country,
  6384. // CityData = cityData
  6385. // });
  6386. //}
  6387. sw.Stop();
  6388. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6389. }
  6390. catch (Exception ex)
  6391. {
  6392. return Ok(JsonView(false, ex.Message));
  6393. throw;
  6394. }
  6395. }
  6396. /// <summary>
  6397. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6398. /// </summary>
  6399. /// <returns></returns>
  6400. [HttpPost]
  6401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6402. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6403. {
  6404. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6405. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6406. List<string> countryData = new List<string>();
  6407. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  6408. countryData = countryData.Distinct().ToList();
  6409. List<dynamic> dataSource = new List<dynamic>();
  6410. foreach (var item in countryData)
  6411. {
  6412. var cityData1 = new List<string>();
  6413. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  6414. var countryData2 = new
  6415. {
  6416. CountryName = item,
  6417. CityData = cityData1
  6418. };
  6419. dataSource.Add(countryData2);
  6420. }
  6421. return Ok(JsonView(true, "查询成功!", dataSource));
  6422. }
  6423. /// <summary>
  6424. /// 团组模块 - 出入境国家费用标准 Page List
  6425. /// </summary>
  6426. /// <returns></returns>
  6427. [HttpPost]
  6428. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6429. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6430. {
  6431. int portId = dto.PortType;
  6432. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6433. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6434. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6435. string whereSql = string.Empty;
  6436. if (!string.IsNullOrEmpty(dto.Country))
  6437. {
  6438. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6439. }
  6440. if (!string.IsNullOrEmpty(dto.City))
  6441. {
  6442. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6443. }
  6444. string pageSql = string.Format(@"Select * From (
  6445. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6446. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6447. From Grp_NationalTravelFee gntf
  6448. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6449. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6450. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6451. RefAsync<int> total = 0;
  6452. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6453. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6454. }
  6455. /// <summary>
  6456. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6457. /// </summary>
  6458. /// <returns></returns>
  6459. [HttpPost]
  6460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6461. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6462. {
  6463. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6464. int portId = dto.PortType;
  6465. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6466. string whereSql = string.Empty;
  6467. if (!string.IsNullOrEmpty(dto.Country))
  6468. {
  6469. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6470. }
  6471. if (!string.IsNullOrEmpty(dto.City))
  6472. {
  6473. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6474. }
  6475. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6476. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6477. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6478. From Grp_NationalTravelFee gntf
  6479. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6480. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6481. Where gntf.Isdel = 0 {0} ", whereSql);
  6482. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6483. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6484. }
  6485. /// <summary>
  6486. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6487. /// </summary>
  6488. /// <returns></returns>
  6489. [HttpPost]
  6490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6491. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6492. {
  6493. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6494. if (data.Code != 0)
  6495. {
  6496. return Ok(JsonView(false, data.Msg));
  6497. }
  6498. return Ok(JsonView(true, "操作成功!", data.Data));
  6499. }
  6500. /// <summary>
  6501. /// 团组模块 - 出入境国家费用标准 - Del
  6502. /// </summary>
  6503. /// <returns></returns>
  6504. [HttpPost]
  6505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6506. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6507. {
  6508. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6509. {
  6510. Id = dto.Id,
  6511. DeleteUserId = dto.DeleteUserId,
  6512. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6513. IsDel = 1
  6514. };
  6515. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6516. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6517. .WhereColumns(it => new { it.Id })
  6518. .ExecuteCommandAsync();
  6519. if (delStatus <= 0)
  6520. {
  6521. return Ok(JsonView(false, "删除失败!"));
  6522. }
  6523. return Ok(JsonView(true, "操作成功!"));
  6524. }
  6525. /// <summary>
  6526. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6527. /// 注:Get 请求Headers 加 Token
  6528. /// </summary>
  6529. /// <param name="groupId"></param>
  6530. /// <returns></returns>
  6531. [HttpGet("{groupId}")]
  6532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6533. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6534. {
  6535. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6536. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6537. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6538. data.ForEach(x =>
  6539. {
  6540. x.CreateUserId = _currUserInfo.UserId;
  6541. });
  6542. if (data.Any())
  6543. {
  6544. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6545. if (add > 0)
  6546. {
  6547. return Ok(JsonView(true, "操作成功!"));
  6548. }
  6549. }
  6550. return Ok(JsonView(false, "未操作!"));
  6551. }
  6552. #endregion
  6553. #region 团组经理模块 出入境费用-草稿
  6554. /// <summary>
  6555. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6556. /// </summary>
  6557. /// <returns></returns>
  6558. [HttpPost]
  6559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6560. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6561. {
  6562. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6563. .Where(x => x.IsDel == 0)
  6564. .OrderByDescending(x => x.CreateTime)
  6565. .Select(x => new { x.Id, x.DraftName })
  6566. .ToListAsync();
  6567. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6568. //SetDataInfoView
  6569. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6570. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6571. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6572. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6573. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6574. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6575. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6576. //默认币种显示
  6577. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  6578. {
  6579. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  6580. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  6581. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  6582. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  6583. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  6584. };
  6585. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  6586. if (_currencyRate.Count > 0)
  6587. {
  6588. foreach (var item in _currencyInfos)
  6589. {
  6590. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6591. if (rateInfo != null)
  6592. {
  6593. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6594. if (rateInfo.Name.Equals("日元")) rate1 *= 1.3700M;
  6595. else rate1 *= 1.035M;
  6596. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6597. }
  6598. }
  6599. }
  6600. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6601. return Ok(JsonView(true, "查询成功!", new
  6602. {
  6603. DraftNameDatas = draftNameDatas,
  6604. CurrencyData = _CurrencyData,
  6605. WordTypeData = _WordTypeData,
  6606. ExcelTypeData = _ExcelTypeData,
  6607. CurrencyInit = _currencyInfos,
  6608. ViewPermissionData = viewPermissionData
  6609. }));
  6610. }
  6611. /// <summary>
  6612. /// 团组模块 - 出入境费用-草稿
  6613. /// 实时汇率 tips
  6614. /// 签证费用 tips
  6615. /// 机票费用 tips
  6616. /// </summary>
  6617. /// <returns></returns>
  6618. [HttpPost]
  6619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6620. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6621. {
  6622. //var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6623. //默认币种显示
  6624. var _currencyInfos = _currencyInit;
  6625. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  6626. List<dynamic> reteInfos = new List<dynamic>();
  6627. if (_currencyRate.Count > 0)
  6628. {
  6629. foreach (var item in _currencyInfos)
  6630. {
  6631. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6632. if (rateInfo != null)
  6633. {
  6634. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6635. decimal rate1 = item.Rate;
  6636. rate1 *= 1.03M;
  6637. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6638. reteInfos.Add(new
  6639. {
  6640. currCode = item.CurrencyCode,
  6641. currName = item.CurrencyName,
  6642. rate = rate2,
  6643. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6644. });
  6645. }
  6646. }
  6647. }
  6648. //var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  6649. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6650. return Ok(JsonView(true, "查询成功!", new
  6651. {
  6652. //GroupNameData = groupNameData.Data,
  6653. //visaData = visaData.Data,
  6654. //airData = airData.Data,
  6655. reteInfos = reteInfos
  6656. }));
  6657. }
  6658. /// <summary>
  6659. /// 团组模块 - 出入境费用-草稿 - Info
  6660. /// </summary>
  6661. /// <returns></returns>
  6662. [HttpPost]
  6663. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  6664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6665. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6666. {
  6667. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6668. }
  6669. /// <summary>
  6670. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6671. /// </summary>
  6672. /// <returns></returns>
  6673. [HttpPost]
  6674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6675. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6676. {
  6677. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6678. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6679. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6680. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6681. foreach (var userId in dto.UserIds)
  6682. {
  6683. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6684. }
  6685. if (permissions.Any())
  6686. {
  6687. _sqlSugar.BeginTran();
  6688. try
  6689. {
  6690. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6691. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6692. if (result < 1)
  6693. {
  6694. _sqlSugar.RollbackTran();
  6695. return Ok(JsonView(false));
  6696. }
  6697. }
  6698. catch (Exception ex)
  6699. {
  6700. _sqlSugar.RollbackTran();
  6701. return Ok(JsonView(false, ex.Message));
  6702. }
  6703. _sqlSugar.CommitTran();
  6704. return Ok(JsonView(true));
  6705. }
  6706. return Ok(JsonView(false));
  6707. }
  6708. /// <summary>
  6709. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6710. /// </summary>
  6711. /// <returns></returns>
  6712. [HttpPost]
  6713. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  6714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6715. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6716. {
  6717. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6718. if (data.Code != 0)
  6719. {
  6720. return Ok(JsonView(false, data.Msg));
  6721. }
  6722. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6723. //汇率信息记录
  6724. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6725. return Ok(JsonView(true, data.Msg, data.Data));
  6726. }
  6727. /// <summary>
  6728. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6729. /// </summary>
  6730. /// <param name="dto"></param>
  6731. /// <returns></returns>
  6732. [HttpPost]
  6733. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  6734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6735. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6736. {
  6737. try
  6738. {
  6739. var id = dto.Id;
  6740. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6741. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6742. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6743. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6744. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6745. 3 团组成员名单 1 团组成员名单", ""));
  6746. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6747. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6748. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6749. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6750. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6751. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6752. //数据源
  6753. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6754. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6755. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6756. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6757. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6758. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6759. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6760. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6761. .Select((x, a, b) => new
  6762. {
  6763. x.Index,
  6764. itemName = a.Name,
  6765. CurrencyStr = b.Name,
  6766. x.Cost,
  6767. x.SubTotal,
  6768. x.Remark
  6769. })
  6770. .OrderBy((x) => x.Index)
  6771. .ToList(); //其他款项费用
  6772. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6773. var peiceItemCurrencys = new List<string>();
  6774. if (_DayAndCosts.Any())
  6775. {
  6776. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6777. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6778. }
  6779. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6780. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6781. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6782. {
  6783. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6784. }
  6785. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6786. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6787. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6788. if (dto.ExportType == 1) //明细表
  6789. {
  6790. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6791. {
  6792. //获取模板
  6793. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6794. //载入模板
  6795. Document doc = new Document(tempPath);
  6796. DocumentBuilder builder = new DocumentBuilder(doc);
  6797. //利用键值对存放数据
  6798. Dictionary<string, string> dic = new Dictionary<string, string>();
  6799. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6800. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6801. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6802. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6803. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6804. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6805. //境内费用(其他费用)
  6806. if (_EnterExitCosts.ChoiceOne == 1)
  6807. {
  6808. string row1_1 = "";
  6809. if (_EnterExitCosts.Visa > 0)
  6810. {
  6811. //insidePayTotal += _EnterExitCosts.Visa;
  6812. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6813. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6814. {
  6815. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6816. }
  6817. }
  6818. string row1_2 = "";
  6819. if (_EnterExitCosts.YiMiao > 0)
  6820. {
  6821. //insidePayTotal += _EnterExitCosts.YiMiao;
  6822. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6823. }
  6824. if (_EnterExitCosts.HeSuan > 0)
  6825. {
  6826. //insidePayTotal += _EnterExitCosts.HeSuan;
  6827. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6828. }
  6829. if (_EnterExitCosts.Service > 0)
  6830. {
  6831. //insidePayTotal += _EnterExitCosts.Service;
  6832. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6833. }
  6834. string row1_3 = "";
  6835. if (_EnterExitCosts.Safe > 0)
  6836. {
  6837. //insidePayTotal += _EnterExitCosts.Safe;
  6838. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6839. }
  6840. if (_EnterExitCosts.Ticket > 0)
  6841. {
  6842. //insidePayTotal += _EnterExitCosts.Ticket;
  6843. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6844. }
  6845. string row1 = "";
  6846. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6847. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6848. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6849. row1 += $"备注:{_EnterExitCosts.Remark}";
  6850. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6851. dic.Add("Row1Str", row1);
  6852. }
  6853. string airTotalStr = string.Empty,
  6854. airPriceStr = string.Empty;
  6855. //经济舱
  6856. if (_EnterExitCosts.SumJJC == 1)
  6857. {
  6858. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6859. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6860. }
  6861. //公务舱
  6862. if (_EnterExitCosts.SumGWC == 1)
  6863. {
  6864. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6865. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6866. }
  6867. //头等舱
  6868. if (_EnterExitCosts.SumTDC == 1)
  6869. {
  6870. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6871. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6872. }
  6873. //汇率描述
  6874. string rateStr = "";
  6875. if (peiceItemCurrencyInfos.Any())
  6876. {
  6877. rateStr = "\r\n汇率描述:";
  6878. foreach (var item in peiceItemCurrencyInfos)
  6879. {
  6880. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6881. }
  6882. }
  6883. string twoItemRemark = "备注:";
  6884. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6885. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6886. dic.Add("AirTotalStr", airTotalStr);
  6887. dic.Add("AirPriceStr", airPriceStr);
  6888. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6889. dic.Add("TwoItemRemark", twoItemRemark);
  6890. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6891. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6892. int table1Row = 0,
  6893. table2Row = 0,
  6894. table3Row = 0,
  6895. table4Row = 0,
  6896. table5Row = 0;
  6897. //住宿费
  6898. if (_EnterExitCosts.ChoiceThree == 1)
  6899. {
  6900. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6901. table1Row = dac1.Count;
  6902. #region 填充word表格内容
  6903. for (int i = 0; i < dac1.Count; i++)
  6904. {
  6905. var dac = dac1[i];
  6906. if (dac == null) continue;
  6907. builder.MoveToCell(0, i, 0, 0);
  6908. builder.Write("第" + dac.Days.ToString() + "晚:");
  6909. builder.MoveToCell(0, i, 1, 0);
  6910. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6911. //builder.Write(dac.Place == null ? "" : dac.Place);
  6912. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6913. builder.MoveToCell(0, i, 2, 0);
  6914. builder.Write("费用标准:");
  6915. string curr = "";
  6916. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6917. if (currData != null)
  6918. {
  6919. curr = currData.Name;
  6920. }
  6921. builder.MoveToCell(0, i, 3, 0);
  6922. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6923. builder.MoveToCell(0, i, 4, 0);
  6924. builder.Write("费用小计:");
  6925. builder.MoveToCell(0, i, 5, 0);
  6926. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6927. }
  6928. #endregion
  6929. }
  6930. else dic.Add("SubZS", "0.00");
  6931. //删除多余行
  6932. while (table1.Rows.Count > table1Row)
  6933. {
  6934. table1.Rows.RemoveAt(table1Row);
  6935. }
  6936. //伙食费
  6937. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6938. if (_EnterExitCosts.ChoiceFour == 1)
  6939. {
  6940. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6941. table2Row = dac2.Count;
  6942. #region 填充word表格内容
  6943. for (int i = 0; i < dac2.Count; i++)
  6944. {
  6945. var dac = dac2[i];
  6946. if (dac == null) continue;
  6947. builder.MoveToCell(1, i, 0, 0);
  6948. builder.Write("第" + dac.Days.ToString() + "天:");
  6949. builder.MoveToCell(1, i, 1, 0);
  6950. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6951. builder.MoveToCell(1, i, 2, 0);
  6952. builder.Write("费用标准:");
  6953. string curr = "";
  6954. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6955. if (currData != null)
  6956. {
  6957. curr = currData.Name;
  6958. }
  6959. builder.MoveToCell(1, i, 3, 0);
  6960. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6961. builder.MoveToCell(1, i, 4, 0);
  6962. builder.Write("费用小计:");
  6963. builder.MoveToCell(1, i, 5, 0);
  6964. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6965. }
  6966. #endregion
  6967. }
  6968. else dic.Add("SubHS", "0.00");
  6969. //删除多余行
  6970. while (table2.Rows.Count > table2Row)
  6971. {
  6972. table2.Rows.RemoveAt(table2Row);
  6973. }
  6974. //公杂费
  6975. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6976. if (_EnterExitCosts.ChoiceFive == 1)
  6977. {
  6978. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6979. table3Row = dac3.Count;
  6980. #region 填充word表格内容
  6981. for (int i = 0; i < dac3.Count; i++)
  6982. {
  6983. var dac = dac3[i];
  6984. if (dac == null) continue;
  6985. builder.MoveToCell(2, i, 0, 0);
  6986. builder.Write("第" + dac.Days.ToString() + "天:");
  6987. builder.MoveToCell(2, i, 1, 0);
  6988. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6989. builder.MoveToCell(2, i, 2, 0);
  6990. builder.Write("费用标准:");
  6991. string curr = "";
  6992. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6993. if (currData != null)
  6994. {
  6995. curr = currData.Name;
  6996. }
  6997. builder.MoveToCell(2, i, 3, 0);
  6998. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6999. builder.MoveToCell(2, i, 4, 0);
  7000. builder.Write("费用小计:");
  7001. builder.MoveToCell(2, i, 5, 0);
  7002. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7003. }
  7004. //删除多余行
  7005. while (table3.Rows.Count > table3Row)
  7006. {
  7007. table3.Rows.RemoveAt(table3Row);
  7008. }
  7009. #endregion
  7010. }
  7011. else dic.Add("SubGZF", "0.00");
  7012. //删除多余行
  7013. while (table3.Rows.Count > table3Row)
  7014. {
  7015. table3.Rows.RemoveAt(table3Row);
  7016. }
  7017. //培训费
  7018. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7019. if (_EnterExitCosts.ChoiceSix == 1)
  7020. {
  7021. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  7022. dic.Add("SubPX", pxStr);
  7023. table4Row = dac4.Count;
  7024. #region 填充word表格内容
  7025. for (int i = 0; i < dac4.Count; i++)
  7026. {
  7027. var dac = dac4[i];
  7028. if (dac == null) continue;
  7029. builder.MoveToCell(3, i, 0, 0);
  7030. builder.Write("第" + dac.Days.ToString() + "天:");
  7031. builder.MoveToCell(3, i, 1, 0);
  7032. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7033. builder.MoveToCell(3, i, 2, 0);
  7034. builder.Write("费用标准:");
  7035. string curr = "";
  7036. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7037. if (currData != null)
  7038. {
  7039. curr = currData.Name;
  7040. }
  7041. builder.MoveToCell(3, i, 3, 0);
  7042. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7043. builder.MoveToCell(3, i, 4, 0);
  7044. builder.Write("费用小计:");
  7045. builder.MoveToCell(3, i, 5, 0);
  7046. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7047. }
  7048. #endregion
  7049. }
  7050. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  7051. //删除多余行
  7052. while (table4.Rows.Count > table4Row)
  7053. {
  7054. table4.Rows.RemoveAt(table4Row);
  7055. }
  7056. //其他费用
  7057. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7058. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7059. {
  7060. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  7061. dic.Add("titleQi", qtStr);
  7062. table5Row = dac5.Count;
  7063. #region 填充word表格内容
  7064. for (int i = 0; i < dac5.Count; i++)
  7065. {
  7066. var dac = dac5[i];
  7067. if (dac == null) continue;
  7068. builder.MoveToCell(4, i, 0, 0);
  7069. builder.Write("第" + dac.Index.ToString() + "项:");
  7070. builder.MoveToCell(4, i, 1, 0);
  7071. builder.Write(dac.itemName);
  7072. builder.MoveToCell(4, i, 2, 0);
  7073. builder.Write("费用标准:");
  7074. builder.MoveToCell(4, i, 3, 0);
  7075. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7076. builder.MoveToCell(4, i, 4, 0);
  7077. builder.Write("费用小计:");
  7078. builder.MoveToCell(4, i, 5, 0);
  7079. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7080. builder.MoveToCell(4, i, 6, 0);
  7081. builder.Write("备注:");
  7082. builder.MoveToCell(4, i, 7, 0);
  7083. builder.Write(dac.Remark);
  7084. }
  7085. #endregion
  7086. }
  7087. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7088. //删除多余行
  7089. while (table5.Rows.Count > table5Row)
  7090. {
  7091. table5.Rows.RemoveAt(table5Row);
  7092. }
  7093. //加上其他费用
  7094. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7095. decimal subJJC = 0.00M,
  7096. subGWC = 0.00M,
  7097. subTDC = 0.00M;
  7098. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7099. string totalLabel = string.Format("全部费用总计:");
  7100. //经济舱
  7101. if (_EnterExitCosts.SumJJC == 1)
  7102. {
  7103. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7104. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  7105. }
  7106. //公务舱
  7107. if (_EnterExitCosts.SumGWC == 1)
  7108. {
  7109. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7110. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  7111. }
  7112. //头等舱
  7113. if (_EnterExitCosts.SumTDC == 1)
  7114. {
  7115. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7116. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  7117. }
  7118. //TotalLabel
  7119. dic.Add("TotalLabel", totalLabel);
  7120. #region 填充word模板书签内容
  7121. foreach (var key in dic.Keys)
  7122. {
  7123. Bookmark bookmark = doc.Range.Bookmarks[key];
  7124. if (bookmark != null)
  7125. {
  7126. builder.MoveToBookmark(key);
  7127. builder.Write(dic[key]);
  7128. }
  7129. }
  7130. #endregion
  7131. //文件名
  7132. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7133. strFileName = CommonFun.ValidFileName(strFileName);
  7134. AsposeHelper.removewatermark_v2180();
  7135. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7136. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7137. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7138. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7139. }
  7140. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7141. {
  7142. //获取模板
  7143. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7144. //载入模板
  7145. Document doc = new Document(tempPath);
  7146. DocumentBuilder builder = new DocumentBuilder(doc);
  7147. Dictionary<string, string> dic = new Dictionary<string, string>();
  7148. string returnCodeLabel = string.Empty;
  7149. if (nationalTravelFeeData.Any())
  7150. {
  7151. List<string> list = new List<string>();
  7152. foreach (var item in nationalTravelFeeData)
  7153. {
  7154. list.Add($"{item.Country}({item.City})");
  7155. }
  7156. list = list.Distinct().ToList();
  7157. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7158. }
  7159. var countryLabel = string.Empty;
  7160. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7161. if (countryData.Any())
  7162. {
  7163. countryLabel = string.Join("、", countryData);
  7164. }
  7165. dic.Add("ReturnCodeAir", returnCodeLabel);
  7166. dic.Add("VisitStartDate", "-");
  7167. dic.Add("VisitEndDate", "-");
  7168. dic.Add("Day", "-");
  7169. dic.Add("VisitCountry", countryLabel);
  7170. dic.Add("ClientUnit", "-");
  7171. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7172. //dic.Add("Names", Names);
  7173. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7174. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7175. decimal dac1totalPrice = 0.00M;
  7176. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7177. foreach (var dac in dac1)
  7178. {
  7179. if (dac.SubTotal == 0.00M)
  7180. {
  7181. continue;
  7182. }
  7183. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7184. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7185. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7186. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7187. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7188. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7189. builder.Write(currency);//币种
  7190. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7191. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7192. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7193. builder.Write("");//人数
  7194. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7195. builder.Write("");//天数
  7196. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7197. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7198. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7199. decimal rate = 0.00M;
  7200. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7201. builder.Write(rate.ToString("#0.0000"));//汇率
  7202. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7203. decimal rbmPrice = dac.SubTotal;
  7204. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7205. accommodationStartIndex++;
  7206. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7207. }
  7208. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7209. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7210. {
  7211. table1.Rows.RemoveAt(i - 1);
  7212. foodandotherStartIndex--;
  7213. }
  7214. if (dac2.Count == dac3.Count)//国家 币种 金额
  7215. {
  7216. for (int i = 0; i < dac2.Count; i++)
  7217. {
  7218. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7219. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7220. }
  7221. }
  7222. decimal dac2totalPrice = 0.00M;
  7223. foreach (var dac in dac2)
  7224. {
  7225. if (dac.SubTotal == 0)
  7226. {
  7227. continue;
  7228. }
  7229. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7230. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7231. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7232. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7233. builder.Write(currency);//币种
  7234. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7235. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7236. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7237. builder.Write("");//人数
  7238. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7239. builder.Write("");//天数
  7240. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7241. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7242. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7243. decimal rate = 0.00M;
  7244. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7245. builder.Write(rate.ToString("#0.0000"));//汇率
  7246. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7247. decimal rbmPrice = dac.SubTotal;
  7248. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7249. foodandotherStartIndex++;
  7250. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7251. }
  7252. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7253. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7254. {
  7255. table1.Rows.RemoveAt(i - 1);
  7256. }
  7257. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7258. string otherFeeStr = "";
  7259. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7260. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7261. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7262. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7263. foreach (var otherInfo in dac5)
  7264. {
  7265. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7266. }
  7267. #endregion
  7268. if (otherFeeStr.Length > 0)
  7269. {
  7270. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7271. otherFeeStr = $"({otherFeeStr})";
  7272. dic.Add("OtherFeeStr", otherFeeStr);
  7273. }
  7274. //总计
  7275. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7276. //国际旅费
  7277. string outsideAir = string.Empty;
  7278. string allPriceAir = string.Empty;
  7279. if (_EnterExitCosts.SumJJC == 1)
  7280. {
  7281. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7282. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7283. }
  7284. if (_EnterExitCosts.SumGWC == 1)
  7285. {
  7286. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7287. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7288. }
  7289. if (_EnterExitCosts.SumTDC == 1)
  7290. {
  7291. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7292. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7293. }
  7294. dic.Add("InTravelPrice", $"({outsideAir})");
  7295. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7296. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7297. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7298. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7299. foreach (var key in dic.Keys)
  7300. {
  7301. builder.MoveToBookmark(key);
  7302. builder.Write(dic[key]);
  7303. }
  7304. //模板文件名
  7305. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7306. strFileName = CommonFun.ValidFileName(strFileName);
  7307. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7308. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7309. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7310. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7311. }
  7312. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7313. {
  7314. //获取模板
  7315. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7316. //载入模板
  7317. WorkbookDesigner designer = new WorkbookDesigner();
  7318. designer.Workbook = new Workbook(tempPath);
  7319. Dictionary<string, string> dic = new Dictionary<string, string>();
  7320. string returnCodeLabel = string.Empty;
  7321. if (nationalTravelFeeData.Any())
  7322. {
  7323. List<string> list = new List<string>();
  7324. foreach (var item in nationalTravelFeeData)
  7325. {
  7326. list.Add($"{item.Country}({item.City})");
  7327. }
  7328. list = list.Distinct().ToList();
  7329. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7330. }
  7331. var countryLabel = string.Empty;
  7332. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7333. if (countryData.Any())
  7334. {
  7335. countryLabel = string.Join("、", countryData);
  7336. }
  7337. dic.Add("ReturnCodeAir", returnCodeLabel);
  7338. dic.Add("VisitStartDate", "-");
  7339. dic.Add("VisitEndDate", "-");
  7340. dic.Add("Day", "0");
  7341. dic.Add("VisitCountry", countryLabel);
  7342. dic.Add("ClientUnit", "-");
  7343. designer.SetDataSource("ClientUnit", "-");
  7344. designer.SetDataSource("VisitCountry", countryLabel);
  7345. designer.SetDataSource("Group", "-");
  7346. designer.SetDataSource("ClientUnitTitle", "-");
  7347. designer.SetDataSource("Name", "-");
  7348. designer.SetDataSource("VisitStartDate", "-");
  7349. designer.SetDataSource("Day", "0");
  7350. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7351. designer.SetDataSource("ReturnCodeAir", "-");
  7352. int startIndex = 10;
  7353. const int startIndexcopy = 10;
  7354. if (dac2.Count == dac3.Count)//国家 币种 金额
  7355. {
  7356. for (int i = 0; i < dac2.Count; i++)
  7357. {
  7358. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7359. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7360. }
  7361. }
  7362. DataTable dtdac1 = new DataTable();
  7363. List<string> place = new List<string>();
  7364. dtdac1.Columns.AddRange(new DataColumn[] {
  7365. new DataColumn(){ ColumnName = "city"},
  7366. new DataColumn(){ ColumnName = "curr"},
  7367. new DataColumn(){ ColumnName = "criterion"},
  7368. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7369. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7370. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7371. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7372. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7373. });
  7374. DataTable dtdac2 = new DataTable();
  7375. dtdac2.Columns.AddRange(new DataColumn[] {
  7376. new DataColumn(){ ColumnName = "city"},
  7377. new DataColumn(){ ColumnName = "curr"},
  7378. new DataColumn(){ ColumnName = "criterion"},
  7379. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7380. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7381. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7382. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7383. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7384. });
  7385. dtdac1.TableName = "tb1";
  7386. dtdac2.TableName = "tb2";
  7387. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7388. foreach (var item in dac1)
  7389. {
  7390. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7391. if (place.Contains(item.Place))
  7392. {
  7393. continue;
  7394. }
  7395. DataRow row = dtdac1.NewRow();
  7396. row["city"] = item.Place;
  7397. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7398. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7399. row["curr"] = currency;
  7400. row["rate"] = rate.ToString("#0.0000");
  7401. row["criterion"] = item.Cost.ToString("#0.00");
  7402. row["number"] = 1;
  7403. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7404. //row["costRMB"] = rbmPrice;
  7405. dtdac1.Rows.Add(row);
  7406. place.Add(item.Place);
  7407. }
  7408. place = new List<string>();
  7409. foreach (var item in dac2)
  7410. {
  7411. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7412. if (place.Contains(item.Place))
  7413. {
  7414. continue;
  7415. }
  7416. DataRow row = dtdac2.NewRow();
  7417. row["city"] = item.Place;
  7418. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7419. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7420. row["curr"] = currency;
  7421. row["rate"] = rate.ToString("#0.0000");
  7422. row["criterion"] = item.Cost.ToString("#0.00");
  7423. row["number"] = 1;
  7424. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7425. //row["cost"] = item.SubTotal;
  7426. //row["costRMB"] = rbmPrice;
  7427. dtdac2.Rows.Add(row);
  7428. place.Add(item.Place);
  7429. //dac2totalPrice += rbmPrice;
  7430. }
  7431. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7432. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7433. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7434. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7435. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7436. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7437. string cell4Str1 = string.Empty;
  7438. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7439. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7440. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7441. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7442. string cellStr = $" 5.其他费用(";
  7443. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7444. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7445. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7446. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7447. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7448. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7449. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7450. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7451. foreach (var otherInfo in dac5)
  7452. {
  7453. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7454. }
  7455. #endregion
  7456. if (cellStr.Length > 8)
  7457. {
  7458. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7459. }
  7460. cellStr += ")";
  7461. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7462. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7463. decimal pxFee = dac4.Sum(it => it.Cost);
  7464. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7465. string celllastStr1 = "";
  7466. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7467. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7468. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7469. celllastStr1 += $",国际旅费 元";
  7470. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7471. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7472. designer.SetDataSource("cell4Str", cell4Str);
  7473. designer.SetDataSource("cellStr", cellStr);
  7474. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7475. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7476. designer.SetDataSource("celllastStr", celllastStr);
  7477. Workbook wb = designer.Workbook;
  7478. var sheet = wb.Worksheets[0];
  7479. //绑定datatable数据集
  7480. designer.SetDataSource(dtdac1);
  7481. designer.SetDataSource(dtdac2);
  7482. designer.Process();
  7483. var rowStart = dtdac1.Rows.Count;
  7484. while (rowStart > 0)
  7485. {
  7486. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7487. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7488. startIndex++;
  7489. rowStart--;
  7490. }
  7491. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7492. startIndex += 1; //总计行
  7493. rowStart = dtdac2.Rows.Count;
  7494. while (rowStart > 0)
  7495. {
  7496. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7497. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7498. startIndex++;
  7499. rowStart--;
  7500. }
  7501. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7502. wb.CalculateFormula(true);
  7503. //模板文件名
  7504. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7505. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7506. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7507. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7508. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7509. }
  7510. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7511. {
  7512. //获取模板
  7513. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7514. //载入模板
  7515. Document doc = new Document(tempPath);
  7516. DocumentBuilder builder = new DocumentBuilder(doc);
  7517. Dictionary<string, string> dic = new Dictionary<string, string>();
  7518. dic.Add("GroupName", "-");
  7519. dic.Add("ClientUnit", "-");
  7520. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7521. //string missionLeaderJob = "";//负责人job
  7522. //int groupNumber = 0; //团人数
  7523. dic.Add("MissionLeader", "-"); //团负责人
  7524. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7525. dic.Add("GroupNumber", "0"); //团人数
  7526. dic.Add("Day", "0");
  7527. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7528. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7529. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7530. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7531. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7532. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7533. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7534. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7535. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7536. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7537. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7538. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7539. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7540. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7541. //其他费用
  7542. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7543. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7544. //其他费用合计
  7545. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7546. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7547. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7548. //公务舱合计
  7549. //国际旅费
  7550. //string outsideJJ = "";
  7551. //string allPriceJJ = "";
  7552. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7553. {
  7554. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7555. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7556. }
  7557. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7558. {
  7559. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7560. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7561. }
  7562. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7563. {
  7564. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7565. dic.Add("AirFeeTotal", airFeeTotalStr);
  7566. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7567. dic.Add("FeeTotal", feeTotalStr);
  7568. }
  7569. foreach (var key in dic.Keys)
  7570. {
  7571. builder.MoveToBookmark(key);
  7572. builder.Write(dic[key]);
  7573. }
  7574. //模板文件名
  7575. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7576. strFileName = CommonFun.ValidFileName(strFileName);
  7577. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7578. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7579. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7580. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7581. }
  7582. }
  7583. else if (dto.ExportType == 2) //表格
  7584. {
  7585. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7586. }
  7587. else if (dto.ExportType == 3)
  7588. {
  7589. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7590. }
  7591. return Ok(JsonView(400, "只可导出明细表!", ""));
  7592. }
  7593. catch (Exception ex)
  7594. {
  7595. return Ok(JsonView(400, ex.Message, ""));
  7596. }
  7597. }
  7598. /// <summary>
  7599. /// 获取三公费用标准city
  7600. /// </summary>
  7601. /// <param name="placeData"></param>
  7602. /// <param name="nationalTravelFeeId"></param>
  7603. /// <returns></returns>
  7604. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7605. {
  7606. string _city = string.Empty;
  7607. if (!placeData.Any()) return _city;
  7608. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7609. if (data == null) return _city;
  7610. string country = data.Country;
  7611. string city = data.City;
  7612. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7613. else _city = city;
  7614. return _city;
  7615. }
  7616. /// <summary>
  7617. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7618. /// </summary>
  7619. /// <returns></returns>
  7620. [HttpPost]
  7621. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7623. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7624. {
  7625. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7626. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7627. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7628. if (_view.Code == 0)
  7629. {
  7630. return Ok(JsonView(true, "操作成功"));
  7631. }
  7632. return Ok(JsonView(false, "操作失败"));
  7633. }
  7634. /// <summary>
  7635. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7636. /// </summary>
  7637. /// <returns></returns>
  7638. [HttpPost]
  7639. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7641. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7642. {
  7643. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7644. if (data.Code != 0)
  7645. {
  7646. return Ok(JsonView(false, data.Msg));
  7647. }
  7648. return Ok(JsonView(true, "操作成功!", data.Data));
  7649. }
  7650. /// <summary>
  7651. /// 三公其他费用草稿 删除
  7652. /// </summary>
  7653. /// <param name="dto"></param>
  7654. /// <returns></returns>
  7655. [HttpPost]
  7656. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7657. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7658. {
  7659. var jw = JsonView(false, "删除失败!");
  7660. var data = new Grp_DayOtherPriceDraft()
  7661. {
  7662. Id = dto.Id,
  7663. IsDel = 1,
  7664. DeleteUserId = dto.DeleteUserId,
  7665. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7666. };
  7667. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7668. if (del > 0)
  7669. {
  7670. jw.Code = 200;
  7671. jw.Msg = "删除成功!";
  7672. }
  7673. return Ok(jw);
  7674. }
  7675. /// <summary>
  7676. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7677. /// </summary>
  7678. /// <returns></returns>
  7679. [HttpPost]
  7680. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7681. {
  7682. var jw = JsonView(false);
  7683. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7684. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  7685. jw.Code = StatusCodes.Status200OK;
  7686. jw.Msg = "操作成功!";
  7687. jw.Data = new { groupNameDatas = groupNameDatas.Data, draftNames = draftDatas };
  7688. return Ok(jw);
  7689. }
  7690. /// <summary>
  7691. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7692. /// </summary>
  7693. /// <param name="dto"></param>
  7694. /// <returns></returns>
  7695. [HttpPost]
  7696. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7697. {
  7698. int userId = dto.UserId,
  7699. portId = dto.PortType,
  7700. groupId = dto.GroupId,
  7701. draftId = dto.DraftId;
  7702. _portTypeData.Add(1);
  7703. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7704. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7705. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7706. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7707. _sqlSugar.BeginTran();
  7708. try
  7709. {
  7710. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7711. if (draftDatas == null)
  7712. {
  7713. _sqlSugar.RollbackTran();
  7714. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7715. }
  7716. //验证可覆盖已有数据 两边创建人需为同一人;
  7717. int draftCreateUserId = draftDatas.CreateUserId,
  7718. formalCreateUserId = 0;
  7719. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7720. if (formalData != null)
  7721. {
  7722. formalCreateUserId = formalData.CreateUserId;
  7723. if (draftCreateUserId != formalCreateUserId)
  7724. {
  7725. _sqlSugar.RollbackTran();
  7726. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7727. }
  7728. }
  7729. //默认添加查看、编辑权限(创建人、自己)
  7730. await _enterExitCostRep.InitPerm(dto.GroupId,dto.UserId);
  7731. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7732. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7733. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7734. newExterData.DiId = groupId;
  7735. newExterData.CreateUserId = userId;
  7736. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7737. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7738. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7739. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7740. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7741. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7742. //数据如果存在执行删除
  7743. if (enterExitCostInfo != null)
  7744. {
  7745. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7746. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7747. .Where(x => x.Id == enterExitCostInfo.Id)
  7748. .ExecuteCommand();
  7749. _sqlSugar.Updateable<Grp_DayAndCost>()
  7750. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7751. .Where(x => x.DiId == groupId)
  7752. .ExecuteCommand();
  7753. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7754. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7755. .Where(x => x.Diid == groupId)
  7756. .ExecuteCommand();
  7757. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7758. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7759. .Where(x => x.GroupId == groupId)
  7760. .ExecuteCommand();
  7761. }
  7762. //执行insert
  7763. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7764. if (insertId < 1)
  7765. {
  7766. _sqlSugar.RollbackTran();
  7767. return Ok(JsonView(false, "草稿数据导入失败!"));
  7768. }
  7769. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7770. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7771. #region 默认添加权限
  7772. #endregion
  7773. _sqlSugar.CommitTran();
  7774. //执行操作之后
  7775. //生成默认文件pdf并且通知人员
  7776. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7777. {
  7778. DiId = groupId,
  7779. ExportType = 1,
  7780. SubTypeId = 1005
  7781. }, "pdf");
  7782. //发送通知
  7783. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7784. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7785. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7786. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7787. //汇率信息记录
  7788. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7789. return Ok(JsonView(true));
  7790. }
  7791. catch (Exception ex)
  7792. {
  7793. _sqlSugar.RollbackTran();
  7794. return Ok(JsonView(false, ex.Message));
  7795. }
  7796. }
  7797. #endregion
  7798. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7799. /// <summary>
  7800. /// 获取币种基础数据(含逻辑处理)
  7801. /// </summary>
  7802. /// <returns></returns>
  7803. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7804. {
  7805. //默认币种显示
  7806. var _currencyInfos = _currencyInit;
  7807. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  7808. if (_currencyRate.Count > 0)
  7809. {
  7810. foreach (var item in _currencyInfos)
  7811. {
  7812. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7813. if (rateInfo != null)
  7814. {
  7815. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  7816. rate1 *= 1.035M;
  7817. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7818. }
  7819. }
  7820. }
  7821. return _currencyInfos;
  7822. }
  7823. /// <summary>
  7824. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7825. /// </summary>
  7826. /// <returns></returns>
  7827. [HttpPost]
  7828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7829. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7830. {
  7831. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7832. //SetDataInfoView
  7833. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7834. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7835. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7836. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7837. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7838. //默认币种显示
  7839. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7840. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7841. return Ok(JsonView(true, "查询成功!", new
  7842. {
  7843. WordTypeData = _WordTypeData,
  7844. ExcelTypeData = _ExcelTypeData,
  7845. CurrencyInit = _currencyInfos,
  7846. viewPermissionData = viewPermissionData
  7847. }));
  7848. }
  7849. /// <summary>
  7850. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7851. /// </summary>
  7852. /// <returns></returns>
  7853. [HttpPost]
  7854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7855. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7856. {
  7857. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7858. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7859. RefAsync<int> total = 0;
  7860. int diId = 0;
  7861. var status = int.TryParse(dto.GroupName, out diId);
  7862. string sql = string.Format(@"SELECT
  7863. Id,
  7864. TeamName GroupName,
  7865. CASE WHEN EXISTS (
  7866. SELECT
  7867. 1
  7868. FROM
  7869. Grp_EnterExitCost
  7870. WHERE
  7871. IsDel = 0
  7872. AND DiId = di.Id
  7873. ) THEN 1 ELSE 0 END AS [IsNull],
  7874. CASE WHEN EXISTS(
  7875. SELECT
  7876. TOP 1 *
  7877. FROM
  7878. Grp_EnterExitCost
  7879. WHERE
  7880. IsDel = 0
  7881. AND DiId = di.Id
  7882. AND CreateUserId = {0}
  7883. ORDER BY
  7884. CreateTime DESC
  7885. ) THEN 1 ELSE 0 END AS [IsEdit],
  7886. CASE WHEN EXISTS(
  7887. SELECT
  7888. TOP 1 *
  7889. FROM
  7890. Grp_EnterExitCost
  7891. WHERE
  7892. IsDel = 0
  7893. AND DiId = di.Id
  7894. AND CreateUserId = {0}
  7895. ORDER BY
  7896. CreateTime DESC
  7897. ) THEN 1 WHEN EXISTS(
  7898. SELECT
  7899. TOP 1 *
  7900. FROM
  7901. Grp_EnterExitCostPermission
  7902. WHERE
  7903. IsDel = 0
  7904. AND GroupId = di.Id
  7905. AND Permission = 1
  7906. AND UserId = {0}
  7907. ORDER BY
  7908. CreateTime DESC
  7909. ) THEN 1 ELSE 0 END AS [IsView]
  7910. FROM
  7911. Grp_DelegationInfo di
  7912. WHERE
  7913. di.Isdel = 0 ", dto.CurrUserId);
  7914. var data = await _sqlSugar.SqlQueryable<EnterExitCostMobileGroupView>(sql)
  7915. .Where(x => !string.IsNullOrEmpty(x.GroupName))
  7916. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7917. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.GroupName.Contains(dto.GroupName))
  7918. .OrderByDescending(x => x.Id)
  7919. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7920. return Ok(JsonView(true, "查询成功!", data, total));
  7921. }
  7922. /// <summary>
  7923. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7924. /// </summary>
  7925. /// <returns></returns>
  7926. [HttpPost]
  7927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7928. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7929. {
  7930. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7931. RefAsync<int> total = 0;
  7932. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7933. .Where(x => x.IsDel == 0 && x.STid == 66)
  7934. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7935. .Select(x => new
  7936. {
  7937. id = x.Id,
  7938. name = x.Name,
  7939. remark = x.Remark,
  7940. })
  7941. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7942. return Ok(JsonView(true, "查询成功!", data, total));
  7943. }
  7944. /// <summary>
  7945. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7946. /// </summary>
  7947. /// <returns></returns>
  7948. [HttpPost]
  7949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7950. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7951. {
  7952. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7953. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7954. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7955. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7956. var groupOtherRateData = groupRateData.TeamRates;
  7957. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7958. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  7959. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  7960. groupOtherRateData = groupOtherRateData
  7961. .Select(x => new TeamRateDescAddCurrencyIdView
  7962. {
  7963. CurrencyId = x.CurrencyId,
  7964. CurrencyName = x.CurrencyName,
  7965. CurrencyCode = x.CurrencyCode,
  7966. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  7967. }).ToList();
  7968. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  7969. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  7970. }
  7971. /// <summary>
  7972. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  7973. /// </summary>
  7974. /// <returns></returns>
  7975. [HttpPost]
  7976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7977. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  7978. {
  7979. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7980. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7981. var tipsData = new List<int>() { 1, 2, 3 };
  7982. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  7983. if (dto.TipsType == 1)
  7984. {
  7985. //默认币种显示
  7986. var _currencyInfos = _currencyInit;
  7987. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  7988. List<dynamic> reteInfos = new List<dynamic>();
  7989. if (_currencyRate.Count > 0)
  7990. {
  7991. foreach (var item in _currencyInfos)
  7992. {
  7993. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7994. if (rateInfo != null)
  7995. {
  7996. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  7997. decimal rate1 = item.Rate;
  7998. rate1 *= 1.03M;
  7999. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  8000. reteInfos.Add(new
  8001. {
  8002. currCode = item.CurrencyCode,
  8003. currName = item.CurrencyName,
  8004. rate = rate2,
  8005. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  8006. });
  8007. }
  8008. }
  8009. }
  8010. return Ok(JsonView(true, "查询成功!", reteInfos));
  8011. }
  8012. else if (dto.TipsType == 2)
  8013. {
  8014. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  8015. return Ok(JsonView(true, "查询成功!", visaData.Data));
  8016. }
  8017. else if (dto.TipsType == 3)
  8018. {
  8019. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  8020. return Ok(JsonView(true, "查询成功!", airData.Data));
  8021. }
  8022. return Ok(JsonView(false));
  8023. }
  8024. /// <summary>
  8025. /// 团组模块 - 出入境国家费用标准-移动端 List
  8026. /// </summary>
  8027. /// <returns></returns>
  8028. [HttpPost]
  8029. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8030. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  8031. {
  8032. Stopwatch sw = new Stopwatch();
  8033. sw.Start();
  8034. RefAsync<int> total = 0;
  8035. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8036. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  8037. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  8038. .Where((ntf, sd, u) => ntf.IsDel == 0)
  8039. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  8040. .Select((ntf, sd, u) => new
  8041. {
  8042. Id = ntf.Id,
  8043. Area = $"{ntf.Country}-{ntf.City}",
  8044. Currency = ntf.Currency,
  8045. CurrencyCode = sd.Name,
  8046. CurrencyName = sd.Remark,
  8047. RoomCost = ntf.RoomCost,
  8048. FoodCost = ntf.FoodCost,
  8049. PublicCost = ntf.PublicCost,
  8050. LastUpdateUserId = ntf.LastUpdateUserId,
  8051. LastUpdateUserName = u.CnName,
  8052. LastUpdateTime = ntf.LastUpdateTime,
  8053. })
  8054. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8055. sw.Stop();
  8056. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  8057. }
  8058. /// <summary>
  8059. /// 团组模块 - 出入境费用-移动端 - Info
  8060. /// </summary>
  8061. /// <returns></returns>
  8062. [HttpPost]
  8063. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8064. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  8065. {
  8066. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8067. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8068. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  8069. return Ok(data);
  8070. }
  8071. /// <summary>
  8072. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  8073. /// </summary>
  8074. /// <returns></returns>
  8075. [HttpPost]
  8076. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8077. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  8078. {
  8079. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8080. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8081. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8082. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8083. var mobileInfo = new EnterExitCostMobileParentInfoView();
  8084. mobileInfo.DiId = dto.DiId;
  8085. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8086. if (eecInfo == null) return Ok(mobileInfo);
  8087. //验证查看权限
  8088. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8089. //if (!isView) return Ok(JsonView(false, msg));
  8090. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8091. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8092. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8093. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8094. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8095. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8096. {
  8097. SubId = dac.Id,
  8098. DiId = dac.DiId,
  8099. Type = dac.Type,
  8100. Days = dac.Days,
  8101. NationalTravelFeeId = dac.NationalTravelFeeId,
  8102. Arae = $"{ntf.Country}-{ntf.City}",
  8103. Cost = dac.Cost,
  8104. Currency = dac.Currency,
  8105. CurrencyName = sd.Name,
  8106. SubTotal = dac.SubTotal,
  8107. })
  8108. .ToList();
  8109. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8110. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8111. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8112. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8113. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8114. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8115. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8116. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8117. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8118. //其他款项
  8119. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8120. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8121. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8122. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8123. .OrderBy((dop, sd1, sd2) => dop.Index)
  8124. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8125. {
  8126. SubId = dop.Id,
  8127. DiId = dop.Diid,
  8128. Index = dop.Index,
  8129. SetDataId = dop.SetDataId,
  8130. SetDataName = sd1.Name,
  8131. Cost = dop.Cost,
  8132. Currency = dop.Currency,
  8133. CurrencyName = sd2.Remark,
  8134. SubTotal = dop.SubTotal,
  8135. Remark = dop.Remark,
  8136. })
  8137. .ToArray();
  8138. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8139. return Ok(mobileInfo);
  8140. }
  8141. /// <summary>
  8142. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8143. /// </summary>
  8144. /// <returns></returns>
  8145. [HttpPost]
  8146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8147. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8148. {
  8149. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8150. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8151. //验证查看权限
  8152. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8153. if (!isView) return Ok(JsonView(false, msg));
  8154. var userIds = Array.Empty<int>();
  8155. userIds = await _sqlSugar
  8156. .Queryable<Grp_EnterExitCostPermission>()
  8157. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8158. .Select(x => x.UserId)
  8159. .ToArrayAsync();
  8160. return Ok(userIds);
  8161. }
  8162. /// <summary>
  8163. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8164. /// </summary>
  8165. /// <returns></returns>
  8166. [HttpPost]
  8167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8168. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8169. {
  8170. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8171. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8172. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8173. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8174. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8175. //验证查看权限
  8176. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8177. //if (!isView) return Ok(JsonView(false, msg));
  8178. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8179. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8180. var subType = dto.SubType;
  8181. if (subType == 1) //1:境内费用
  8182. {
  8183. var oneData = new ChoiceOneMobileSubInfoView()
  8184. {
  8185. Id = eecInfo.Id,
  8186. ChoiceOne = eecInfo.ChoiceOne,
  8187. ChoiceOneTotalCost = eecInfo.InsidePay,
  8188. Visa = eecInfo.Visa,
  8189. VisaRemark = eecInfo.VisaRemark,
  8190. YiMiao = eecInfo.YiMiao,
  8191. HeSuan = eecInfo.HeSuan,
  8192. Service = eecInfo.Service,
  8193. Ticket = eecInfo.Ticket,
  8194. Safe = eecInfo.Safe,
  8195. FirstItemRemark = eecInfo.FirstItemRemark
  8196. };
  8197. return Ok(JsonView(oneData));
  8198. }
  8199. else if (subType == 2) //2:国际旅费
  8200. {
  8201. var twoData = new ChoiceTwoMobileSubInfoView()
  8202. {
  8203. Id = eecInfo.Id,
  8204. ChoiceTwoJJ = eecInfo.SumJJC,
  8205. OutsideJJPay = eecInfo.OutsideJJPay,
  8206. ChoiceTwoGW = eecInfo.SumGWC,
  8207. OutsideGWPay = eecInfo.OutsideGWPay,
  8208. ChoiceTwoTD = eecInfo.SumTDC,
  8209. OutsideTDPay = eecInfo.OutsideTDPay,
  8210. AirJJ = eecInfo.AirJJ,
  8211. AirGW = eecInfo.AirGW,
  8212. AirTD = eecInfo.AirTD,
  8213. CityTranffic = eecInfo.CityTranffic,
  8214. TwoItemRemark = eecInfo.TwoItemRemark
  8215. };
  8216. return Ok(JsonView(twoData));
  8217. }
  8218. else if (subType == 3) //3:住宿费
  8219. {
  8220. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8221. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8222. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8223. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8224. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8225. {
  8226. SubId = dac.Id,
  8227. DiId = dac.DiId,
  8228. Type = dac.Type,
  8229. Days = dac.Days,
  8230. NationalTravelFeeId = dac.NationalTravelFeeId,
  8231. Arae = $"{ntf.Country}-{ntf.City}",
  8232. Cost = dac.Cost,
  8233. Currency = dac.Currency,
  8234. CurrencyName = sd.Name,
  8235. SubTotal = dac.SubTotal,
  8236. })
  8237. .ToArray();
  8238. var data = new ChoiceMobileSubInfo3To6View()
  8239. {
  8240. ParentId = eecInfo.Id,
  8241. Choice = eecInfo.ChoiceThree,
  8242. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8243. Details = dayAndCostDatas
  8244. };
  8245. return Ok(JsonView(data));
  8246. }
  8247. else if (subType == 4) //4:伙食费
  8248. {
  8249. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8250. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8251. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8252. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8253. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8254. {
  8255. SubId = dac.Id,
  8256. DiId = dac.DiId,
  8257. Type = dac.Type,
  8258. Days = dac.Days,
  8259. NationalTravelFeeId = dac.NationalTravelFeeId,
  8260. Arae = $"{ntf.Country}-{ntf.City}",
  8261. Cost = dac.Cost,
  8262. Currency = dac.Currency,
  8263. CurrencyName = sd.Name,
  8264. SubTotal = dac.SubTotal,
  8265. })
  8266. .ToArray();
  8267. var data = new ChoiceMobileSubInfo3To6View()
  8268. {
  8269. ParentId = eecInfo.Id,
  8270. Choice = eecInfo.ChoiceFour,
  8271. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8272. Details = dayAndCostDatas
  8273. };
  8274. return Ok(JsonView(data));
  8275. }
  8276. else if (subType == 5) //5:公杂费
  8277. {
  8278. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8279. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8280. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8281. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8282. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8283. {
  8284. SubId = dac.Id,
  8285. DiId = dac.DiId,
  8286. Type = dac.Type,
  8287. Days = dac.Days,
  8288. NationalTravelFeeId = dac.NationalTravelFeeId,
  8289. Arae = $"{ntf.Country}-{ntf.City}",
  8290. Cost = dac.Cost,
  8291. Currency = dac.Currency,
  8292. CurrencyName = sd.Name,
  8293. SubTotal = dac.SubTotal,
  8294. })
  8295. .ToArray();
  8296. var data = new ChoiceMobileSubInfo3To6View()
  8297. {
  8298. ParentId = eecInfo.Id,
  8299. Choice = eecInfo.ChoiceFive,
  8300. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8301. Details = dayAndCostDatas
  8302. };
  8303. return Ok(JsonView(data));
  8304. }
  8305. else if (subType == 6) //6:培训费
  8306. {
  8307. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8308. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8309. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8310. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8311. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8312. {
  8313. SubId = dac.Id,
  8314. DiId = dac.DiId,
  8315. Type = dac.Type,
  8316. Days = dac.Days,
  8317. NationalTravelFeeId = dac.NationalTravelFeeId,
  8318. Arae = $"{ntf.Country}-{ntf.City}",
  8319. Cost = dac.Cost,
  8320. Currency = dac.Currency,
  8321. CurrencyName = sd.Name,
  8322. SubTotal = dac.SubTotal,
  8323. })
  8324. .ToArray();
  8325. var data = new ChoiceMobileSubInfo3To6View()
  8326. {
  8327. ParentId = eecInfo.Id,
  8328. Choice = eecInfo.ChoiceSix,
  8329. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8330. Details = dayAndCostDatas
  8331. };
  8332. return Ok(JsonView(data));
  8333. }
  8334. else if (subType == 7) //7:其他
  8335. {
  8336. //其他款项
  8337. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8338. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8339. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8340. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8341. .OrderBy((dop, sd1, sd2) => dop.Index)
  8342. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8343. {
  8344. SubId = dop.Id,
  8345. DiId = dop.Diid,
  8346. Index = dop.Index,
  8347. SetDataId = dop.SetDataId,
  8348. SetDataName = sd1.Name,
  8349. Cost = dop.Cost,
  8350. Currency = dop.Currency,
  8351. CurrencyName = sd2.Name,
  8352. SubTotal = dop.SubTotal,
  8353. Remark = dop.Remark,
  8354. })
  8355. .ToArray();
  8356. var data = new ChoiceSevenMobileSubInfoView()
  8357. {
  8358. ParentId = eecInfo.Id,
  8359. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8360. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8361. Details = otherData
  8362. };
  8363. return Ok(JsonView(data));
  8364. }
  8365. return Ok(JsonView(false));
  8366. }
  8367. #region op
  8368. /// <summary>
  8369. /// 移动端更新费用消息通知
  8370. /// </summary>
  8371. /// <param name="diid"></param>
  8372. /// <param name="id"></param>
  8373. /// <param name="currUserId"></param>
  8374. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  8375. {
  8376. try
  8377. {
  8378. ////生成默认文件pdf并且通知人员
  8379. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8380. //{
  8381. // DiId = diid,
  8382. // ExportType = 1,
  8383. // SubTypeId = 1005
  8384. //}, "pdf");
  8385. ////发送通知
  8386. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8387. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8388. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8389. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8390. ////汇率信息记录
  8391. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8392. }
  8393. catch (Exception ex)
  8394. {
  8395. //记录日志
  8396. throw;
  8397. }
  8398. }
  8399. /// <summary>
  8400. /// 验证出入境费用数据是否存在
  8401. /// 不存在添加
  8402. /// </summary>
  8403. /// <param name="diId"></param>
  8404. /// <param name="currUserId"></param>
  8405. /// <returns></returns>
  8406. /// <exception cref="CustomException"></exception>
  8407. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  8408. {
  8409. var parentId = 0;
  8410. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8411. if (info != null)
  8412. {
  8413. parentId = info.Id;
  8414. }
  8415. else
  8416. {
  8417. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8418. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8419. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8420. parentId = addId;
  8421. }
  8422. return parentId;
  8423. }
  8424. /// <summary>
  8425. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8426. /// </summary>
  8427. /// <returns></returns>
  8428. [HttpPost]
  8429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8430. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8431. {
  8432. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8433. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8434. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8435. //验证编辑权限
  8436. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8437. //if (!isEdit) return Ok(JsonView(false, msg));
  8438. var permissions = new List<Grp_EnterExitCostPermission>();
  8439. foreach (var userId in dto.UserIds)
  8440. {
  8441. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8442. }
  8443. if (permissions.Any())
  8444. {
  8445. _sqlSugar.BeginTran();
  8446. try
  8447. {
  8448. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8449. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8450. if (result < 1)
  8451. {
  8452. _sqlSugar.RollbackTran();
  8453. return Ok(JsonView(false));
  8454. }
  8455. }
  8456. catch (Exception ex)
  8457. {
  8458. _sqlSugar.RollbackTran();
  8459. return Ok(JsonView(false, ex.Message));
  8460. }
  8461. _sqlSugar.CommitTran();
  8462. return Ok(JsonView(true));
  8463. }
  8464. return Ok(JsonView(false));
  8465. }
  8466. /// <summary>
  8467. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8468. /// </summary>
  8469. /// <returns></returns>
  8470. [HttpPost]
  8471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8472. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8473. {
  8474. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8475. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8476. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8477. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8478. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8479. int id = dto.Id;
  8480. if (id <= 0) //add
  8481. {
  8482. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8483. if (add < 1) return Ok(JsonView(false));
  8484. id = add;
  8485. }
  8486. else //update
  8487. {
  8488. ////验证编辑权限
  8489. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8490. //if (!isEdit) return Ok(JsonView(false, msg));
  8491. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8492. if (upd < 1) return Ok(JsonView(false));
  8493. }
  8494. #region 汇率变更时更改币种相关费用
  8495. var opDayCosts = new List<Grp_DayAndCost>();
  8496. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8497. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8498. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8499. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  8500. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8501. .Select((dac, sd) => new
  8502. {
  8503. dac.Id,
  8504. dac.DiId,
  8505. CurrencyCode = sd.Name,
  8506. dac.Cost
  8507. })
  8508. .ToList();
  8509. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8510. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8511. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8512. .Select((dop, sd) => new
  8513. {
  8514. dop.Id,
  8515. dop.Diid,
  8516. CurrencyCode = sd.Name,
  8517. dop.Cost
  8518. })
  8519. .ToList();
  8520. if (dayCosts.Count > 0)
  8521. {
  8522. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8523. foreach (var dc in new_dayCosts)
  8524. {
  8525. var thisCurrency = dc.Key.ToUpper();
  8526. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8527. if (thisRate == 0.00M) continue;
  8528. foreach (var dcSub in dc)
  8529. {
  8530. opDayCosts.Add(new Grp_DayAndCost()
  8531. {
  8532. Id = dcSub.Id,
  8533. DiId = dcSub.DiId,
  8534. Cost = dcSub.Cost,
  8535. SubTotal = dcSub.Cost * thisRate,
  8536. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8537. });
  8538. }
  8539. }
  8540. if (opDayCosts.Count > 0)
  8541. {
  8542. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8543. }
  8544. }
  8545. if (dayOtherCosts.Count > 0)
  8546. {
  8547. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8548. foreach (var dc in new_dayOtherCosts)
  8549. {
  8550. var thisCurrency = dc.Key.ToUpper();
  8551. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8552. if (thisRate == 0.00M) continue;
  8553. foreach (var dcSub in dc)
  8554. {
  8555. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8556. {
  8557. Id = dcSub.Id,
  8558. Diid = dcSub.Diid,
  8559. Cost = dcSub.Cost,
  8560. SubTotal = dcSub.Cost * thisRate,
  8561. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8562. });
  8563. }
  8564. }
  8565. if (opDayOtherCosts.Count > 0)
  8566. {
  8567. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8568. }
  8569. }
  8570. #endregion
  8571. //消息通知
  8572. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8573. //汇率信息记录
  8574. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8575. return Ok(JsonView(new { parentId = id }));
  8576. }
  8577. /// <summary>
  8578. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8579. /// </summary>
  8580. /// <returns></returns>
  8581. [HttpPost]
  8582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8583. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8584. {
  8585. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8586. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8587. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8588. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8589. int id = dto.Id;
  8590. if (id <= 0) //add
  8591. {
  8592. checkboxInfo.CreateUserId = dto.CurrUserId;
  8593. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8594. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8595. if (add < 1) return Ok(JsonView(false));
  8596. }
  8597. else //update
  8598. {
  8599. ////验证编辑权限
  8600. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8601. //if (!isEdit) return Ok(JsonView(false, msg));
  8602. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8603. .UpdateColumns(x => new
  8604. {
  8605. x.ChoiceOne,
  8606. x.ChoiceTwo,
  8607. x.SumJJC,
  8608. x.SumGWC,
  8609. x.SumTDC,
  8610. x.ChoiceThree,
  8611. x.ChoiceFour,
  8612. x.ChoiceFive,
  8613. x.ChoiceSix,
  8614. x.OtherExpenses_Checked
  8615. })
  8616. .Where(x => x.Id == id)
  8617. .ExecuteCommandAsync();
  8618. if (upd < 1) return Ok(JsonView(false));
  8619. }
  8620. return Ok(JsonView(new { parentId = id }));
  8621. }
  8622. /// <summary>
  8623. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8624. /// </summary>
  8625. /// <returns></returns>
  8626. [HttpPost]
  8627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8628. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8629. {
  8630. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  8631. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8632. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8633. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8634. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8635. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8636. var checkboxInfo = new Grp_EnterExitCost()
  8637. {
  8638. Id = id,
  8639. DiId = diId,
  8640. CreateUserId = currUserId
  8641. };
  8642. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8643. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8644. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8645. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8646. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8647. if (id <= 0) //add
  8648. {
  8649. checkboxInfo.CreateUserId = dto.CurrUserId;
  8650. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8651. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8652. if (add < 1) return Ok(JsonView(false));
  8653. }
  8654. else //update
  8655. {
  8656. ////验证编辑权限
  8657. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8658. //if (!isEdit) return Ok(JsonView(false, msg));
  8659. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8660. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8661. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8662. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8663. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8664. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8665. .Where(x => x.Id == id)
  8666. .ExecuteCommandAsync();
  8667. if (upd < 1) return Ok(JsonView(false));
  8668. }
  8669. return Ok(JsonView(new { parentId = id }));
  8670. }
  8671. /// <summary>
  8672. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8673. /// </summary>
  8674. /// <returns></returns>
  8675. [HttpPost]
  8676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8677. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8678. {
  8679. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8680. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8681. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8682. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8683. info.FirstItemRemark = dto.FirstItemRemark;
  8684. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8685. int id = dto.Id;
  8686. if (id <= 0) //add
  8687. {
  8688. info.CreateUserId = dto.CurrUserId;
  8689. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8690. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8691. if (add < 1) return Ok(JsonView(false));
  8692. id = add;
  8693. }
  8694. else //update
  8695. {
  8696. ////验证编辑权限
  8697. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8698. //if (!isEdit) return Ok(JsonView(false, msg));
  8699. var upd = await _sqlSugar.Updateable(info)
  8700. .UpdateColumns(x => new
  8701. {
  8702. x.ChoiceOne,
  8703. x.InsidePay,
  8704. x.VisaRemark,
  8705. x.Visa,
  8706. x.Service,
  8707. x.Safe,
  8708. x.Ticket,
  8709. x.HeSuan,
  8710. x.YiMiao,
  8711. x.FirstItemRemark
  8712. })
  8713. .Where(x => x.Id == id)
  8714. .ExecuteCommandAsync();
  8715. if (upd < 1) return Ok(JsonView(false));
  8716. }
  8717. //消息通知
  8718. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8719. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8720. }
  8721. /// <summary>
  8722. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8723. /// </summary>
  8724. /// <returns></returns>
  8725. [HttpPost]
  8726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8727. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8728. {
  8729. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8730. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8731. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8732. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8733. info.OutsideJJPay = dto.OutsideJJPay;
  8734. info.OutsideGWPay = dto.OutsideGWPay;
  8735. info.OutsideTDPay = dto.OutsideTDPay;
  8736. info.AirJJ = dto.AirJJ;
  8737. info.AirGW = dto.AirGW;
  8738. info.AirTD = dto.AirTD;
  8739. info.CityTranffic = dto.CityTranffic;
  8740. info.TwoItemRemark = dto.TwoItemRemark;
  8741. info.SumJJC = dto.ChoiceTwoJJ;
  8742. info.SumGWC = dto.ChoiceTwoGW;
  8743. info.SumTDC = dto.ChoiceTwoTD;
  8744. int id = dto.Id;
  8745. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8746. if (id <= 0) //add
  8747. {
  8748. info.CreateUserId = dto.CurrUserId;
  8749. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8750. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8751. if (addId <= 0) return Ok(JsonView(false));
  8752. id = addId;
  8753. }
  8754. else //update
  8755. {
  8756. ////验证编辑权限
  8757. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8758. //if (!isEdit) return Ok(JsonView(false, msg));
  8759. var upd = await _sqlSugar.Updateable(info)
  8760. .UpdateColumns(x => new
  8761. {
  8762. x.SumJJC,
  8763. x.OutsideJJPay,
  8764. x.SumGWC,
  8765. x.OutsideGWPay,
  8766. x.SumTDC,
  8767. x.OutsideTDPay,
  8768. x.AirJJ,
  8769. x.AirGW,
  8770. x.AirTD,
  8771. x.CityTranffic,
  8772. x.TwoItemRemark
  8773. })
  8774. .Where(x => x.Id == id)
  8775. .ExecuteCommandAsync();
  8776. if (upd < 1) return Ok(JsonView(false));
  8777. }
  8778. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8779. gwcItemTotal = info.AirGW + info.CityTranffic;
  8780. tdcItemTotal = info.AirTD + info.CityTranffic;
  8781. //消息通知
  8782. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8783. return Ok(JsonView(new
  8784. {
  8785. parentId = id,
  8786. choiceTwoJJ = dto.ChoiceTwoJJ,
  8787. jjcItemTotal = jjcItemTotal,
  8788. choiceTwoGW = dto.ChoiceTwoGW,
  8789. gwcItemTotal = gwcItemTotal,
  8790. choiceTwoTD = dto.ChoiceTwoTD,
  8791. tdcItemTotal = tdcItemTotal
  8792. }));
  8793. }
  8794. /// <summary>
  8795. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8796. /// </summary>
  8797. /// <returns></returns>
  8798. [HttpPost]
  8799. [ApiExplorerSettings(IgnoreApi = true)]
  8800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8801. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8802. {
  8803. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8804. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8805. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8806. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8807. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8808. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8809. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8810. var infos = infos1.Select(x => new Grp_DayAndCost
  8811. {
  8812. Id = x.Id,
  8813. DiId = dto.DiId,
  8814. Type = dto.FeeType,
  8815. Days = x.Days,
  8816. NationalTravelFeeId = x.NationalTravelFeeId,
  8817. Cost = x.Cost,
  8818. Currency = x.Currency,
  8819. SubTotal = x.SubTotal,
  8820. CreateUserId = dto.CurrUserId
  8821. })
  8822. .ToList();
  8823. var adds = infos.Where(x => x.Id <= 0).ToList();
  8824. var upds = infos.Where(x => x.Id > 0).ToList();
  8825. if (adds.Count > 0)
  8826. {
  8827. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8828. if (add < 1) return Ok(JsonView(false));
  8829. }
  8830. if (upds.Count > 0)
  8831. {
  8832. var upd = await _sqlSugar.Updateable(adds)
  8833. .UpdateColumns(x => new
  8834. {
  8835. x.Days,
  8836. x.NationalTravelFeeId,
  8837. x.Cost,
  8838. x.Currency,
  8839. x.SubTotal
  8840. })
  8841. .WhereColumns(x => new { x.Id })
  8842. .ExecuteCommandAsync();
  8843. if (upd < 1) return Ok(JsonView(false));
  8844. }
  8845. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8846. //消息通知
  8847. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8848. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8849. return Ok(JsonView(new { itemTotal = itemTotal }));
  8850. }
  8851. /// <summary>
  8852. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8853. /// </summary>
  8854. /// <returns></returns>
  8855. [HttpPost]
  8856. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8857. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8858. {
  8859. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8860. int subId = dto.SubId, feeType = dto.FeeType;
  8861. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8862. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8863. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8864. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8865. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8866. subInfo.Id = subId;
  8867. subInfo.DiId = dto.DiId;
  8868. if (feeType == 3) subInfo.Type = 1;
  8869. else if (feeType == 4) subInfo.Type = 2;
  8870. else if (feeType == 5) subInfo.Type = 3;
  8871. else if (feeType == 6) subInfo.Type = 4;
  8872. subInfo.CreateUserId = dto.CurrUserId;
  8873. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8874. if (parentId < 1) return Ok(JsonView(false));
  8875. //子表op
  8876. if (subId < 1)
  8877. {
  8878. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8879. if (subAdd < 1) return Ok(JsonView(false));
  8880. }
  8881. else
  8882. {
  8883. ////验证编辑权限
  8884. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8885. //if (!isEdit) return Ok(JsonView(false, msg));
  8886. var subUpd = await _sqlSugar.Updateable(subInfo)
  8887. .UpdateColumns(x => new
  8888. {
  8889. x.Days,
  8890. x.NationalTravelFeeId,
  8891. x.Cost,
  8892. x.Currency,
  8893. x.SubTotal
  8894. })
  8895. .WhereColumns(x => new { x.Id })
  8896. .ExecuteCommandAsync();
  8897. if (subUpd < 1) return Ok(JsonView(false));
  8898. }
  8899. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8900. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8901. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8902. }
  8903. /// <summary>
  8904. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8905. /// </summary>
  8906. /// <returns></returns>
  8907. [HttpPost]
  8908. [ApiExplorerSettings(IgnoreApi = true)]
  8909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8910. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8911. {
  8912. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8913. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8914. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8915. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8916. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8917. {
  8918. Id = x.Id,
  8919. Diid = dto.DiId,
  8920. SetDataId = x.SetDataId,
  8921. Index = x.Index,
  8922. Cost = x.Cost,
  8923. Currency = x.Currency,
  8924. SubTotal = x.SubTotal,
  8925. CreateUserId = dto.CurrUserId,
  8926. Remark = x.Remark
  8927. }).ToList();
  8928. var adds = infos.Where(x => x.Id <= 0).ToList();
  8929. var upds = infos.Where(x => x.Id > 0).ToList();
  8930. if (adds.Count > 0)
  8931. {
  8932. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8933. if (add < 1) return Ok(JsonView(false));
  8934. }
  8935. if (upds.Count > 0)
  8936. {
  8937. var upd = await _sqlSugar.Updateable(adds)
  8938. .UpdateColumns(x => new
  8939. {
  8940. x.Index,
  8941. x.SetDataId,
  8942. x.Cost,
  8943. x.Currency,
  8944. x.SubTotal,
  8945. x.Remark
  8946. })
  8947. .WhereColumns(x => new { x.Id })
  8948. .ExecuteCommandAsync();
  8949. if (upd < 1) return Ok(JsonView(false));
  8950. }
  8951. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8952. //消息通知
  8953. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8954. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8955. return Ok(JsonView(new { itemTotal = itemTotal }));
  8956. }
  8957. /// <summary>
  8958. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8959. /// </summary>
  8960. /// <returns></returns>
  8961. [HttpPost]
  8962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8963. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8964. {
  8965. int subId = dto.SubId;
  8966. int diId = dto.Diid;
  8967. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8968. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8969. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8970. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8971. subInfo.Id = subId;
  8972. subInfo.Diid = dto.Diid;
  8973. subInfo.CreateUserId = dto.CurrUserId;
  8974. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8975. if (parentId < 1) return Ok(JsonView(false));
  8976. #region 子表op
  8977. if (subId < 1)//add
  8978. {
  8979. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8980. if (subAdd < 1) return Ok(JsonView(false));
  8981. }
  8982. else //upd
  8983. {
  8984. ////验证编辑权限
  8985. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  8986. //if (!isEdit) return Ok(JsonView(false, msg));
  8987. var subUpd = await _sqlSugar.Updateable(subInfo)
  8988. .UpdateColumns(x => new
  8989. {
  8990. x.Index,
  8991. x.SetDataId,
  8992. x.Cost,
  8993. x.Currency,
  8994. x.SubTotal,
  8995. x.Remark
  8996. })
  8997. .WhereColumns(x => new { x.Id })
  8998. .ExecuteCommandAsync();
  8999. if (subUpd < 1) return Ok(JsonView(false));
  9000. }
  9001. #endregion
  9002. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  9003. //消息通知
  9004. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  9005. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9006. }
  9007. /// <summary>
  9008. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  9009. /// </summary>
  9010. /// <returns></returns>
  9011. [HttpPost]
  9012. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9013. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  9014. {
  9015. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  9016. if (data.Code != 0)
  9017. {
  9018. return Ok(JsonView(false, data.Msg));
  9019. }
  9020. return Ok(JsonView(true, "操作成功!", data.Data));
  9021. }
  9022. /// <summary>
  9023. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  9024. /// </summary>
  9025. /// <param name="dto"></param>
  9026. /// <returns></returns>
  9027. [HttpPost]
  9028. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  9029. {
  9030. var data = new Grp_DayOtherPrice()
  9031. {
  9032. Id = dto.Id,
  9033. IsDel = 1,
  9034. DeleteUserId = dto.DeleteUserId,
  9035. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9036. };
  9037. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9038. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  9039. return Ok(JsonView(false, "删除失败!"));
  9040. }
  9041. #endregion
  9042. #endregion
  9043. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  9044. /// <summary>
  9045. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  9046. /// </summary>
  9047. /// <returns></returns>
  9048. [HttpPost]
  9049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9050. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  9051. {
  9052. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9053. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9054. RefAsync<int> total = 0;
  9055. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  9056. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  9057. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  9058. .Select(x => new
  9059. {
  9060. Id = x.Id,
  9061. DraftName = x.DraftName,
  9062. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  9063. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  9064. .Any()
  9065. })
  9066. .OrderByDescending(x => x.Id)
  9067. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9068. return Ok(JsonView(true, "查询成功!", data, total));
  9069. }
  9070. /// <summary>
  9071. /// 出入境费用-草稿 移动端
  9072. /// 获取币种基础数据(含逻辑处理)
  9073. /// </summary>
  9074. /// <returns></returns>
  9075. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  9076. {
  9077. //默认币种显示
  9078. var _currencyInfos = _currencyInit;
  9079. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  9080. if (_currencyRate.Count > 0)
  9081. {
  9082. foreach (var item in _currencyInfos)
  9083. {
  9084. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  9085. if (rateInfo != null)
  9086. {
  9087. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  9088. rate1 *= 1.035M;
  9089. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  9090. }
  9091. }
  9092. }
  9093. return _currencyInfos;
  9094. }
  9095. /// <summary>
  9096. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9097. /// </summary>
  9098. /// <returns></returns>
  9099. [HttpPost]
  9100. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9101. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(PortDtoBase dto)
  9102. {
  9103. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  9104. //SetDataInfoView
  9105. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  9106. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  9107. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  9108. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  9109. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  9110. //默认币种显示
  9111. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9112. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9113. return Ok(JsonView(true, "查询成功!", new
  9114. {
  9115. WordTypeData = _WordTypeData,
  9116. ExcelTypeData = _ExcelTypeData,
  9117. CurrencyInit = _currencyInfos,
  9118. viewPermissionData = viewPermissionData
  9119. }));
  9120. }
  9121. /// <summary>
  9122. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9123. /// </summary>
  9124. /// <returns></returns>
  9125. [HttpPost]
  9126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9127. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9128. {
  9129. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9130. RefAsync<int> total = 0;
  9131. int diId = 0;
  9132. var status = int.TryParse(dto.GroupName, out diId);
  9133. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9134. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9135. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9136. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9137. .Select(x => new
  9138. {
  9139. Id = x.Id,
  9140. GroupName = x.TeamName
  9141. })
  9142. .OrderByDescending(x => x.Id)
  9143. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9144. return Ok(JsonView(true, "查询成功!", data, total));
  9145. }
  9146. /// <summary>
  9147. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9148. /// </summary>
  9149. /// <returns></returns>
  9150. [HttpPost]
  9151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9152. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9153. {
  9154. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9155. RefAsync<int> total = 0;
  9156. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9157. .Where(x => x.IsDel == 0 && x.STid == 66)
  9158. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9159. .Select(x => new
  9160. {
  9161. id = x.Id,
  9162. name = x.Name,
  9163. remark = x.Remark,
  9164. })
  9165. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9166. return Ok(JsonView(true, "查询成功!", data, total));
  9167. }
  9168. /// <summary>
  9169. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9170. /// </summary>
  9171. /// <returns></returns>
  9172. [HttpPost]
  9173. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9174. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9175. {
  9176. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9177. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9178. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, 2274, 98);
  9179. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9180. var groupOtherRateData = groupRateData.TeamRates;
  9181. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9182. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9183. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9184. groupOtherRateData = groupOtherRateData
  9185. .Select(x => new TeamRateDescAddCurrencyIdView
  9186. {
  9187. CurrencyId = x.CurrencyId,
  9188. CurrencyName = x.CurrencyName,
  9189. CurrencyCode = x.CurrencyCode,
  9190. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9191. }).ToList();
  9192. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9193. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9194. }
  9195. /// <summary>
  9196. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9197. /// </summary>
  9198. /// <returns></returns>
  9199. [HttpPost]
  9200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9201. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9202. {
  9203. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9204. var tipsData = new List<int>() { 1, 2, 3 };
  9205. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9206. if (dto.TipsType == 1)
  9207. {
  9208. //默认币种显示
  9209. var _currencyInfos = _currencyInit;
  9210. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  9211. List<dynamic> reteInfos = new List<dynamic>();
  9212. if (_currencyRate.Count > 0)
  9213. {
  9214. foreach (var item in _currencyInfos)
  9215. {
  9216. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  9217. if (rateInfo != null)
  9218. {
  9219. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  9220. decimal rate1 = item.Rate;
  9221. rate1 *= 1.03M;
  9222. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  9223. reteInfos.Add(new
  9224. {
  9225. currCode = item.CurrencyCode,
  9226. currName = item.CurrencyName,
  9227. rate = rate2,
  9228. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  9229. });
  9230. }
  9231. }
  9232. }
  9233. return Ok(JsonView(true, "查询成功!", reteInfos));
  9234. }
  9235. else if (dto.TipsType == 2)
  9236. {
  9237. }
  9238. else if (dto.TipsType == 3)
  9239. {
  9240. }
  9241. return Ok(JsonView(false));
  9242. }
  9243. /// <summary>
  9244. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9245. /// </summary>
  9246. /// <returns></returns>
  9247. [HttpPost]
  9248. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9249. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9250. {
  9251. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9252. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9253. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9254. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9255. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9256. if (eecInfo == null) return Ok(mobileInfo);
  9257. //验证查看权限
  9258. (bool isView, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId);
  9259. if (!isView) return Ok(JsonView(false, msg));
  9260. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9261. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9262. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9263. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9264. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9265. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9266. {
  9267. ParentId = dac.ParentId,
  9268. SubId = dac.Id,
  9269. Type = dac.Type,
  9270. Days = dac.Days,
  9271. NationalTravelFeeId = dac.NationalTravelFeeId,
  9272. Arae = $"{ntf.Country}-{ntf.City}",
  9273. Cost = dac.Cost,
  9274. Currency = dac.Currency,
  9275. CurrencyName = sd.Name,
  9276. SubTotal = dac.SubTotal,
  9277. })
  9278. .ToList();
  9279. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9280. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9281. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9282. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9283. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9284. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9285. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9286. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9287. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9288. //其他款项
  9289. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9290. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9291. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9292. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9293. .OrderBy((dop, sd1, sd2) => dop.Index)
  9294. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9295. {
  9296. ParentId = dop.ParentId,
  9297. SubId = dop.Id,
  9298. Index = dop.Index,
  9299. SetDataId = dop.SetDataId,
  9300. SetDataName = sd1.Name,
  9301. Cost = dop.Cost,
  9302. Currency = dop.Currency,
  9303. CurrencyName = sd2.Remark,
  9304. SubTotal = dop.SubTotal,
  9305. Remark = dop.Remark,
  9306. })
  9307. .ToArray();
  9308. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9309. return Ok(mobileInfo);
  9310. }
  9311. /// <summary>
  9312. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9313. /// </summary>
  9314. /// <returns></returns>
  9315. [HttpPost]
  9316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9317. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9318. {
  9319. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9320. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9321. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9322. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9323. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9324. //验证查看权限
  9325. (bool isView, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId);
  9326. if (!isView) return Ok(JsonView(false, msg));
  9327. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9328. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9329. var subType = dto.SubType;
  9330. if (subType == 1) //1:境内费用
  9331. {
  9332. var oneData = new ChoiceOneMobileSubInfoView()
  9333. {
  9334. Id = eecInfo.Id,
  9335. ChoiceOne = eecInfo.ChoiceOne,
  9336. ChoiceOneTotalCost = eecInfo.InsidePay,
  9337. Visa = eecInfo.Visa,
  9338. VisaRemark = eecInfo.VisaRemark,
  9339. YiMiao = eecInfo.YiMiao,
  9340. HeSuan = eecInfo.HeSuan,
  9341. Service = eecInfo.Service,
  9342. Ticket = eecInfo.Ticket,
  9343. Safe = eecInfo.Safe,
  9344. FirstItemRemark = eecInfo.FirstItemRemark
  9345. };
  9346. return Ok(JsonView(oneData));
  9347. }
  9348. else if (subType == 2) //2:国际旅费
  9349. {
  9350. var twoData = new ChoiceTwoMobileSubInfoView()
  9351. {
  9352. Id = eecInfo.Id,
  9353. ChoiceTwoJJ = eecInfo.SumJJC,
  9354. OutsideJJPay = eecInfo.OutsideJJPay,
  9355. ChoiceTwoGW = eecInfo.SumGWC,
  9356. OutsideGWPay = eecInfo.OutsideGWPay,
  9357. ChoiceTwoTD = eecInfo.SumTDC,
  9358. OutsideTDPay = eecInfo.OutsideTDPay,
  9359. AirJJ = eecInfo.AirJJ,
  9360. AirGW = eecInfo.AirGW,
  9361. AirTD = eecInfo.AirTD,
  9362. CityTranffic = eecInfo.CityTranffic,
  9363. TwoItemRemark = eecInfo.TwoItemRemark
  9364. };
  9365. return Ok(JsonView(twoData));
  9366. }
  9367. else if (subType == 3) //3:住宿费
  9368. {
  9369. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9370. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9371. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9372. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9373. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9374. {
  9375. ParentId = dac.ParentId,
  9376. SubId = dac.Id,
  9377. Type = dac.Type,
  9378. Days = dac.Days,
  9379. NationalTravelFeeId = dac.NationalTravelFeeId,
  9380. Arae = $"{ntf.Country}-{ntf.City}",
  9381. Cost = dac.Cost,
  9382. Currency = dac.Currency,
  9383. CurrencyName = sd.Name,
  9384. SubTotal = dac.SubTotal,
  9385. })
  9386. .ToArray();
  9387. var data = new ChoiceDraftMobileSubInfo3To6View()
  9388. {
  9389. ParentId = eecInfo.Id,
  9390. Choice = eecInfo.ChoiceThree,
  9391. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9392. Details = dayAndCostDatas
  9393. };
  9394. return Ok(JsonView(data));
  9395. }
  9396. else if (subType == 4) //4:伙食费
  9397. {
  9398. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9399. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9400. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9401. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9402. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9403. {
  9404. ParentId = dac.ParentId,
  9405. SubId = dac.Id,
  9406. Type = dac.Type,
  9407. Days = dac.Days,
  9408. NationalTravelFeeId = dac.NationalTravelFeeId,
  9409. Arae = $"{ntf.Country}-{ntf.City}",
  9410. Cost = dac.Cost,
  9411. Currency = dac.Currency,
  9412. CurrencyName = sd.Name,
  9413. SubTotal = dac.SubTotal,
  9414. })
  9415. .ToArray();
  9416. var data = new ChoiceDraftMobileSubInfo3To6View()
  9417. {
  9418. ParentId = eecInfo.Id,
  9419. Choice = eecInfo.ChoiceFour,
  9420. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9421. Details = dayAndCostDatas
  9422. };
  9423. return Ok(JsonView(data));
  9424. }
  9425. else if (subType == 5) //5:公杂费
  9426. {
  9427. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9428. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9429. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9430. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9431. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9432. {
  9433. ParentId = dac.ParentId,
  9434. SubId = dac.Id,
  9435. Type = dac.Type,
  9436. Days = dac.Days,
  9437. NationalTravelFeeId = dac.NationalTravelFeeId,
  9438. Arae = $"{ntf.Country}-{ntf.City}",
  9439. Cost = dac.Cost,
  9440. Currency = dac.Currency,
  9441. CurrencyName = sd.Name,
  9442. SubTotal = dac.SubTotal,
  9443. })
  9444. .ToArray();
  9445. var data = new ChoiceDraftMobileSubInfo3To6View()
  9446. {
  9447. ParentId = eecInfo.Id,
  9448. Choice = eecInfo.ChoiceFive,
  9449. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9450. Details = dayAndCostDatas
  9451. };
  9452. return Ok(JsonView(data));
  9453. }
  9454. else if (subType == 6) //6:培训费
  9455. {
  9456. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9457. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9458. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9459. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9460. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9461. {
  9462. ParentId = dac.ParentId,
  9463. SubId = dac.Id,
  9464. Type = dac.Type,
  9465. Days = dac.Days,
  9466. NationalTravelFeeId = dac.NationalTravelFeeId,
  9467. Arae = $"{ntf.Country}-{ntf.City}",
  9468. Cost = dac.Cost,
  9469. Currency = dac.Currency,
  9470. CurrencyName = sd.Name,
  9471. SubTotal = dac.SubTotal,
  9472. })
  9473. .ToArray();
  9474. var data = new ChoiceDraftMobileSubInfo3To6View()
  9475. {
  9476. ParentId = eecInfo.Id,
  9477. Choice = eecInfo.ChoiceSix,
  9478. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9479. Details = dayAndCostDatas
  9480. };
  9481. return Ok(JsonView(data));
  9482. }
  9483. else if (subType == 7) //7:其他
  9484. {
  9485. //其他款项
  9486. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9487. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9488. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9489. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9490. .OrderBy((dop, sd1, sd2) => dop.Index)
  9491. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9492. {
  9493. ParentId = dop.ParentId,
  9494. SubId = dop.Id,
  9495. Index = dop.Index,
  9496. SetDataId = dop.SetDataId,
  9497. SetDataName = sd1.Name,
  9498. Cost = dop.Cost,
  9499. Currency = dop.Currency,
  9500. CurrencyName = sd2.Name,
  9501. SubTotal = dop.SubTotal,
  9502. Remark = dop.Remark,
  9503. })
  9504. .ToArray();
  9505. var data = new ChoiceSevenDraftMobileSubInfoView()
  9506. {
  9507. ParentId = eecInfo.Id,
  9508. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9509. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9510. Details = otherData
  9511. };
  9512. return Ok(JsonView(data));
  9513. }
  9514. return Ok(JsonView(false));
  9515. }
  9516. #region op
  9517. /// <summary>
  9518. /// 移动端更新费用消息通知
  9519. /// </summary>
  9520. /// <param name="draftId"></param>
  9521. /// <param name="id"></param>
  9522. /// <param name="currUserId"></param>
  9523. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9524. {
  9525. try
  9526. {
  9527. ////生成默认文件pdf并且通知人员
  9528. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9529. //{
  9530. // DiId = draftId,
  9531. // ExportType = 1,
  9532. // SubTypeId = 1005
  9533. //}, "pdf");
  9534. ////发送通知
  9535. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9536. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9537. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9538. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9539. ////汇率信息记录
  9540. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9541. }
  9542. catch (Exception ex)
  9543. {
  9544. //记录日志
  9545. throw;
  9546. }
  9547. }
  9548. /// <summary>
  9549. /// 验证出入境费用数据是否存在
  9550. /// 不存在添加
  9551. /// </summary>
  9552. /// <param name="draftId"></param>
  9553. /// <param name="currUserId"></param>
  9554. /// <returns></returns>
  9555. /// <exception cref="CustomException"></exception>
  9556. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9557. {
  9558. var parentId = 0;
  9559. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9560. if (info != null) parentId = info.Id;
  9561. else
  9562. {
  9563. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9564. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9565. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9566. parentId = addId;
  9567. }
  9568. return parentId;
  9569. }
  9570. /// <summary>
  9571. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9572. /// </summary>
  9573. /// <returns></returns>
  9574. [HttpPost]
  9575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9576. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9577. {
  9578. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9579. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9580. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9581. //验证编辑权限
  9582. (bool isEdit, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId, 2);
  9583. if (!isEdit) return Ok(JsonView(false, msg));
  9584. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  9585. foreach (var userId in dto.UserIds)
  9586. {
  9587. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9588. }
  9589. if (permissions.Any())
  9590. {
  9591. _sqlSugar.BeginTran();
  9592. try
  9593. {
  9594. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9595. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9596. if (result < 1)
  9597. {
  9598. _sqlSugar.RollbackTran();
  9599. return Ok(JsonView(false));
  9600. }
  9601. }
  9602. catch (Exception ex)
  9603. {
  9604. _sqlSugar.RollbackTran();
  9605. return Ok(JsonView(false, ex.Message));
  9606. }
  9607. _sqlSugar.CommitTran();
  9608. return Ok(JsonView(true));
  9609. }
  9610. return Ok(JsonView(false));
  9611. }
  9612. /// <summary>
  9613. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9614. /// </summary>
  9615. /// <returns></returns>
  9616. [HttpPost]
  9617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9618. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9619. {
  9620. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9621. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9622. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9623. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9624. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9625. int id = dto.DraftId;
  9626. if (id <= 0) //add
  9627. {
  9628. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9629. if (add < 1) return Ok(JsonView(false));
  9630. id = add;
  9631. }
  9632. else //update
  9633. {
  9634. //验证编辑权限
  9635. (bool isEdit, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId, 2);
  9636. if (!isEdit) return Ok(JsonView(false, msg));
  9637. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9638. if (upd < 1) return Ok(JsonView(false));
  9639. }
  9640. #region 汇率变更时更改币种相关费用
  9641. var opDayCosts = new List<Grp_DayAndCostDraft>();
  9642. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  9643. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9644. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9645. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9646. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9647. .Select((dac, sd) => new
  9648. {
  9649. dac.Id,
  9650. dac.ParentId,
  9651. CurrencyCode = sd.Name,
  9652. dac.Cost
  9653. })
  9654. .ToList();
  9655. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9656. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9657. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9658. .Select((dop, sd) => new
  9659. {
  9660. dop.Id,
  9661. dop.ParentId,
  9662. CurrencyCode = sd.Name,
  9663. dop.Cost
  9664. })
  9665. .ToList();
  9666. if (dayCosts.Count > 0)
  9667. {
  9668. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9669. foreach (var dc in new_dayCosts)
  9670. {
  9671. var thisCurrency = dc.Key.ToUpper();
  9672. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9673. if (thisRate == 0.00M) continue;
  9674. foreach (var dcSub in dc)
  9675. {
  9676. opDayCosts.Add(new Grp_DayAndCostDraft()
  9677. {
  9678. Id = dcSub.Id,
  9679. ParentId = dcSub.ParentId,
  9680. Cost = dcSub.Cost,
  9681. SubTotal = dcSub.Cost * thisRate,
  9682. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  9683. });
  9684. }
  9685. }
  9686. if (opDayCosts.Count > 0)
  9687. {
  9688. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9689. }
  9690. }
  9691. if (dayOtherCosts.Count > 0)
  9692. {
  9693. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9694. foreach (var dc in new_dayOtherCosts)
  9695. {
  9696. var thisCurrency = dc.Key.ToUpper();
  9697. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9698. if (thisRate == 0.00M) continue;
  9699. foreach (var dcSub in dc)
  9700. {
  9701. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  9702. {
  9703. Id = dcSub.Id,
  9704. ParentId = dcSub.ParentId,
  9705. Cost = dcSub.Cost,
  9706. SubTotal = dcSub.Cost * thisRate,
  9707. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9708. });
  9709. }
  9710. }
  9711. if (opDayOtherCosts.Count > 0)
  9712. {
  9713. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9714. }
  9715. }
  9716. #endregion
  9717. ////消息通知
  9718. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9719. ////汇率信息记录
  9720. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9721. return Ok(JsonView(new { parentId = id }));
  9722. }
  9723. /// <summary>
  9724. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  9725. /// </summary>
  9726. /// <returns></returns>
  9727. [HttpPost]
  9728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9729. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  9730. {
  9731. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9732. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9733. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9734. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9735. int id = dto.DraftId;
  9736. if (id <= 0) //add
  9737. {
  9738. checkboxInfo.CreateUserId = dto.CurrUserId;
  9739. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  9740. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9741. if (add < 1) return Ok(JsonView(false));
  9742. }
  9743. else //update
  9744. {
  9745. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9746. .UpdateColumns(x => new
  9747. {
  9748. x.ChoiceOne,
  9749. x.ChoiceTwo,
  9750. x.SumJJC,
  9751. x.SumGWC,
  9752. x.SumTDC,
  9753. x.ChoiceThree,
  9754. x.ChoiceFour,
  9755. x.ChoiceFive,
  9756. x.ChoiceSix,
  9757. x.OtherExpenses_Checked
  9758. })
  9759. .Where(x => x.Id == id)
  9760. .ExecuteCommandAsync();
  9761. if (upd < 1) return Ok(JsonView(false));
  9762. }
  9763. return Ok(JsonView(new { parentId = id }));
  9764. }
  9765. /// <summary>
  9766. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框更改
  9767. /// </summary>
  9768. /// <returns></returns>
  9769. [HttpPost]
  9770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9771. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  9772. {
  9773. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  9774. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9775. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9776. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9777. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9778. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9779. var checkboxInfo = new Grp_EnterExitCostDraft()
  9780. {
  9781. Id = draftId,
  9782. CreateUserId = currUserId
  9783. };
  9784. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9785. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9786. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9787. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9788. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9789. if (draftId <= 0) //add
  9790. {
  9791. checkboxInfo.CreateUserId = dto.CurrUserId;
  9792. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9793. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9794. if (add < 1) return Ok(JsonView(false));
  9795. }
  9796. else //update
  9797. {
  9798. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  9799. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9800. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9801. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9802. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9803. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9804. .Where(x => x.Id == draftId)
  9805. .ExecuteCommandAsync();
  9806. if (upd < 1) return Ok(JsonView(false));
  9807. }
  9808. return Ok(JsonView(new { parentId = draftId }));
  9809. }
  9810. /// <summary>
  9811. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  9812. /// </summary>
  9813. /// <returns></returns>
  9814. [HttpPost]
  9815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9816. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  9817. {
  9818. int id = dto.DraftId, currUserId = dto.CurrUserId;
  9819. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9820. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9821. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9822. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9823. info.FirstItemRemark = dto.FirstItemRemark;
  9824. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9825. if (id <= 0) //add
  9826. {
  9827. info.CreateUserId = dto.CurrUserId;
  9828. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9829. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9830. if (add < 1) return Ok(JsonView(false));
  9831. id = add;
  9832. }
  9833. else //update
  9834. {
  9835. var upd = await _sqlSugar.Updateable(info)
  9836. .UpdateColumns(x => new
  9837. {
  9838. x.ChoiceOne,
  9839. x.InsidePay,
  9840. x.VisaRemark,
  9841. x.Visa,
  9842. x.Service,
  9843. x.Safe,
  9844. x.Ticket,
  9845. x.HeSuan,
  9846. x.YiMiao,
  9847. x.FirstItemRemark
  9848. })
  9849. .Where(x => x.Id == id)
  9850. .ExecuteCommandAsync();
  9851. if (upd < 1) return Ok(JsonView(false));
  9852. }
  9853. ////消息通知
  9854. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9855. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9856. }
  9857. /// <summary>
  9858. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  9859. /// </summary>
  9860. /// <returns></returns>
  9861. [HttpPost]
  9862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9863. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  9864. {
  9865. int id = dto.DraftId;
  9866. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9867. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9868. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9869. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9870. info.OutsideJJPay = dto.OutsideJJPay;
  9871. info.OutsideGWPay = dto.OutsideGWPay;
  9872. info.OutsideTDPay = dto.OutsideTDPay;
  9873. info.AirJJ = dto.AirJJ;
  9874. info.AirGW = dto.AirGW;
  9875. info.AirTD = dto.AirTD;
  9876. info.CityTranffic = dto.CityTranffic;
  9877. info.TwoItemRemark = dto.TwoItemRemark;
  9878. info.SumJJC = dto.ChoiceTwoJJ;
  9879. info.SumGWC = dto.ChoiceTwoGW;
  9880. info.SumTDC = dto.ChoiceTwoTD;
  9881. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9882. if (id <= 0) //add
  9883. {
  9884. info.CreateUserId = dto.CurrUserId;
  9885. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9886. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9887. if (addId <= 0) return Ok(JsonView(false));
  9888. id = addId;
  9889. }
  9890. else //update
  9891. {
  9892. var upd = await _sqlSugar.Updateable(info)
  9893. .UpdateColumns(x => new
  9894. {
  9895. x.SumJJC,
  9896. x.OutsideJJPay,
  9897. x.SumGWC,
  9898. x.OutsideGWPay,
  9899. x.SumTDC,
  9900. x.OutsideTDPay,
  9901. x.AirJJ,
  9902. x.AirGW,
  9903. x.AirTD,
  9904. x.CityTranffic,
  9905. x.TwoItemRemark
  9906. })
  9907. .Where(x => x.Id == id)
  9908. .ExecuteCommandAsync();
  9909. if (upd < 1) return Ok(JsonView(false));
  9910. }
  9911. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9912. gwcItemTotal = info.AirGW + info.CityTranffic;
  9913. tdcItemTotal = info.AirTD + info.CityTranffic;
  9914. ////消息通知
  9915. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9916. return Ok(JsonView(new
  9917. {
  9918. parentId = id,
  9919. choiceTwoJJ = dto.ChoiceTwoJJ,
  9920. jjcItemTotal = jjcItemTotal,
  9921. choiceTwoGW = dto.ChoiceTwoGW,
  9922. gwcItemTotal = gwcItemTotal,
  9923. choiceTwoTD = dto.ChoiceTwoTD,
  9924. tdcItemTotal = tdcItemTotal
  9925. }));
  9926. }
  9927. /// <summary>
  9928. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9929. /// </summary>
  9930. /// <returns></returns>
  9931. [HttpPost]
  9932. [ApiExplorerSettings(IgnoreApi = true)]
  9933. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9934. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  9935. {
  9936. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9937. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9938. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9939. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9940. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9941. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9942. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  9943. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  9944. {
  9945. Id = x.Id,
  9946. ParentId = dto.DraftId,
  9947. Type = dto.FeeType,
  9948. Days = x.Days,
  9949. NationalTravelFeeId = x.NationalTravelFeeId,
  9950. Cost = x.Cost,
  9951. Currency = x.Currency,
  9952. SubTotal = x.SubTotal,
  9953. CreateUserId = dto.CurrUserId
  9954. })
  9955. .ToList();
  9956. var adds = infos.Where(x => x.Id <= 0).ToList();
  9957. var upds = infos.Where(x => x.Id > 0).ToList();
  9958. if (adds.Count > 0)
  9959. {
  9960. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9961. if (add < 1) return Ok(JsonView(false));
  9962. }
  9963. if (upds.Count > 0)
  9964. {
  9965. var upd = await _sqlSugar.Updateable(adds)
  9966. .UpdateColumns(x => new
  9967. {
  9968. x.Days,
  9969. x.NationalTravelFeeId,
  9970. x.Cost,
  9971. x.Currency,
  9972. x.SubTotal
  9973. })
  9974. .WhereColumns(x => new { x.Id })
  9975. .ExecuteCommandAsync();
  9976. if (upd < 1) return Ok(JsonView(false));
  9977. }
  9978. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9979. ////消息通知
  9980. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  9981. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9982. return Ok(JsonView(new { itemTotal = itemTotal }));
  9983. }
  9984. /// <summary>
  9985. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9986. /// </summary>
  9987. /// <returns></returns>
  9988. [HttpPost]
  9989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9990. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  9991. {
  9992. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9993. int subId = dto.SubId, feeType = dto.FeeType;
  9994. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9995. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9996. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9997. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9998. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  9999. subInfo.Id = subId;
  10000. subInfo.ParentId = dto.DraftId;
  10001. if (feeType == 3) subInfo.Type = 1;
  10002. else if (feeType == 4) subInfo.Type = 2;
  10003. else if (feeType == 5) subInfo.Type = 3;
  10004. else if (feeType == 6) subInfo.Type = 4;
  10005. subInfo.CreateUserId = dto.CurrUserId;
  10006. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  10007. if (parentId < 1) return Ok(JsonView(false));
  10008. //子表op
  10009. if (subId < 1)
  10010. {
  10011. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10012. if (subAdd < 1) return Ok(JsonView(false));
  10013. }
  10014. else
  10015. {
  10016. var subUpd = await _sqlSugar.Updateable(subInfo)
  10017. .UpdateColumns(x => new
  10018. {
  10019. x.Days,
  10020. x.NationalTravelFeeId,
  10021. x.Cost,
  10022. x.Currency,
  10023. x.SubTotal
  10024. })
  10025. .WhereColumns(x => new { x.Id })
  10026. .ExecuteCommandAsync();
  10027. if (subUpd < 1) return Ok(JsonView(false));
  10028. }
  10029. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  10030. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10031. }
  10032. /// <summary>
  10033. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  10034. /// </summary>
  10035. /// <returns></returns>
  10036. [HttpPost]
  10037. [ApiExplorerSettings(IgnoreApi = true)]
  10038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10039. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  10040. {
  10041. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10042. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10043. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10044. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  10045. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  10046. {
  10047. Id = x.Id,
  10048. ParentId = dto.DraftId,
  10049. SetDataId = x.SetDataId,
  10050. Index = x.Index,
  10051. Cost = x.Cost,
  10052. Currency = x.Currency,
  10053. SubTotal = x.SubTotal,
  10054. CreateUserId = dto.CurrUserId,
  10055. Remark = x.Remark
  10056. }).ToList();
  10057. var adds = infos.Where(x => x.Id <= 0).ToList();
  10058. var upds = infos.Where(x => x.Id > 0).ToList();
  10059. if (adds.Count > 0)
  10060. {
  10061. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10062. if (add < 1) return Ok(JsonView(false));
  10063. }
  10064. if (upds.Count > 0)
  10065. {
  10066. var upd = await _sqlSugar.Updateable(adds)
  10067. .UpdateColumns(x => new
  10068. {
  10069. x.Index,
  10070. x.SetDataId,
  10071. x.Cost,
  10072. x.Currency,
  10073. x.SubTotal,
  10074. x.Remark
  10075. })
  10076. .WhereColumns(x => new { x.Id })
  10077. .ExecuteCommandAsync();
  10078. if (upd < 1) return Ok(JsonView(false));
  10079. }
  10080. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  10081. //消息通知
  10082. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  10083. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10084. return Ok(JsonView(new { itemTotal = itemTotal }));
  10085. }
  10086. /// <summary>
  10087. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  10088. /// </summary>
  10089. /// <returns></returns>
  10090. [HttpPost]
  10091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10092. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  10093. {
  10094. int subId = dto.SubId, id = dto.DarftId;
  10095. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10096. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  10097. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10098. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  10099. subInfo.Id = subId;
  10100. subInfo.ParentId = dto.DarftId;
  10101. subInfo.CreateUserId = dto.CurrUserId;
  10102. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  10103. if (parentId < 1) return Ok(JsonView(false));
  10104. #region 子表op
  10105. if (subId < 1)//add
  10106. {
  10107. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10108. if (subAdd < 1) return Ok(JsonView(false));
  10109. }
  10110. else //upd
  10111. {
  10112. var subUpd = await _sqlSugar.Updateable(subInfo)
  10113. .UpdateColumns(x => new
  10114. {
  10115. x.Index,
  10116. x.SetDataId,
  10117. x.Cost,
  10118. x.Currency,
  10119. x.SubTotal,
  10120. x.Remark
  10121. })
  10122. .WhereColumns(x => new { x.Id })
  10123. .ExecuteCommandAsync();
  10124. if (subUpd < 1) return Ok(JsonView(false));
  10125. }
  10126. #endregion
  10127. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10128. ////消息通知
  10129. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10130. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10131. }
  10132. /// <summary>
  10133. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10134. /// </summary>
  10135. /// <returns></returns>
  10136. [HttpPost]
  10137. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10138. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10139. {
  10140. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10141. if (data.Code != 0)
  10142. {
  10143. return Ok(JsonView(false, data.Msg));
  10144. }
  10145. return Ok(JsonView(true, "操作成功!", data.Data));
  10146. }
  10147. /// <summary>
  10148. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10149. /// </summary>
  10150. /// <param name="dto"></param>
  10151. /// <returns></returns>
  10152. [HttpPost]
  10153. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10154. {
  10155. var data = new Grp_DayOtherPriceDraft()
  10156. {
  10157. Id = dto.Id,
  10158. IsDel = 1,
  10159. DeleteUserId = dto.DeleteUserId,
  10160. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10161. };
  10162. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10163. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10164. return Ok(JsonView(false, "删除失败!"));
  10165. }
  10166. #endregion
  10167. #endregion
  10168. #region 签证费用录入
  10169. /// <summary>
  10170. /// 根据diid查询签证费用列表
  10171. /// </summary>
  10172. /// <param name="dto"></param>
  10173. /// <returns></returns>
  10174. [HttpPost]
  10175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10176. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  10177. {
  10178. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  10179. if (groupData.Code != 0)
  10180. {
  10181. return Ok(JsonView(false, groupData.Msg));
  10182. }
  10183. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10184. }
  10185. /// <summary>
  10186. /// 根据签证费用Id查询单条数据及c表数据
  10187. /// </summary>
  10188. /// <param name="dto"></param>
  10189. /// <returns></returns>
  10190. [HttpPost]
  10191. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10192. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  10193. {
  10194. Result groupData = await _visaPriceRep.PostVisaById(dto);
  10195. if (groupData.Code != 0)
  10196. {
  10197. return Ok(JsonView(false, groupData.Msg));
  10198. }
  10199. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10200. }
  10201. /// <summary>
  10202. /// 签证费用删除
  10203. /// </summary>
  10204. /// <param name="dto"></param>
  10205. /// <returns></returns>
  10206. [HttpPost]
  10207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10208. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  10209. {
  10210. _sqlSugar.BeginTran();
  10211. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  10212. if (!res)
  10213. {
  10214. _sqlSugar.RollbackTran();
  10215. return Ok(JsonView(false, "删除失败"));
  10216. }
  10217. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  10218. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  10219. .SetColumns(a => new Grp_CreditCardPayment()
  10220. {
  10221. IsDel = 1,
  10222. DeleteUserId = dto.DeleteUserId,
  10223. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10224. })
  10225. .ExecuteCommand();
  10226. if (resSub < 1)
  10227. {
  10228. _sqlSugar.RollbackTran();
  10229. return Ok(JsonView(false, "删除失败"));
  10230. }
  10231. _sqlSugar.CommitTran();
  10232. return Ok(JsonView(true, "删除成功!"));
  10233. }
  10234. /// <summary>
  10235. /// 签证费用录入下拉框初始化
  10236. /// </summary>
  10237. /// <returns></returns>
  10238. [HttpPost]
  10239. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10240. public async Task<IActionResult> VisaPriceAddSelect()
  10241. {
  10242. //支付方式
  10243. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  10244. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  10245. //币种
  10246. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  10247. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  10248. //乘客类型
  10249. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  10250. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  10251. //卡类型
  10252. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  10253. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  10254. //代办费类型
  10255. var agencyFeeTypeData = new List<dynamic>() {
  10256. new { id = 0 , Text = "未选择" },
  10257. new { id = 1 , Text = "小公务" },
  10258. new { id = 2 , Text = "大公务" },
  10259. };
  10260. //签证费用标准国家Data
  10261. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  10262. var data = new
  10263. {
  10264. Payment = _Payment,
  10265. CurrencyList = _CurrencyList,
  10266. PassengerType = _PassengerType,
  10267. BankCard = _BankCard,
  10268. AgencyFeeType = agencyFeeTypeData,
  10269. CountryFeeData = visaCountryFeeData
  10270. };
  10271. return Ok(JsonView(true, "查询成功!", data));
  10272. }
  10273. /// <summary>
  10274. /// 签证费用录入操作(Status:1.新增,2.修改)
  10275. /// </summary>
  10276. /// <param name="dto"></param>
  10277. /// <returns></returns>
  10278. [HttpPost]
  10279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10280. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  10281. {
  10282. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  10283. if (groupData.Code != 0)
  10284. {
  10285. return Ok(JsonView(false, groupData.Msg));
  10286. }
  10287. #region 应用推送
  10288. try
  10289. {
  10290. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10291. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10292. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10293. //2024-10-21 新增LZ UID
  10294. var userIds = new List<int>() { 21 };
  10295. string title = $"系统通知";
  10296. string content = "";
  10297. var diId = dto.DiId;
  10298. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10299. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10300. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10301. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10302. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10303. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10304. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10305. }
  10306. catch (Exception ex)
  10307. {
  10308. }
  10309. #endregion
  10310. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10311. }
  10312. #endregion
  10313. #region 签证提成录入
  10314. /// <summary>
  10315. /// 签证提成录入
  10316. /// 基础数据
  10317. /// </summary>
  10318. /// <returns></returns>
  10319. [HttpGet]
  10320. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10321. public async Task<IActionResult> VisaCommissionInit()
  10322. {
  10323. return Ok(await _visaCommissionRep.Init());
  10324. }
  10325. /// <summary>
  10326. /// 签证提成录入
  10327. /// Item
  10328. /// </summary>
  10329. /// <param name="_dto"></param>
  10330. /// <returns></returns>
  10331. [HttpPost]
  10332. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10333. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  10334. {
  10335. var validator = new VisaCommissionItemDtoValidator();
  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.Item(_dto));
  10347. }
  10348. /// <summary>
  10349. /// 签证提成录入
  10350. /// Save
  10351. /// </summary>
  10352. /// <param name="_dto"></param>
  10353. /// <returns></returns>
  10354. [HttpPost]
  10355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10356. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  10357. {
  10358. //参数验证
  10359. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  10360. foreach (var item in _dto.Items)
  10361. {
  10362. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  10363. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  10364. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  10365. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  10366. }
  10367. return Ok(await _visaCommissionRep.Save(_dto));
  10368. }
  10369. /// <summary>
  10370. /// 签证提成录入
  10371. /// Create
  10372. /// </summary>
  10373. /// <param name="_dto"></param>
  10374. /// <returns></returns>
  10375. [HttpPost]
  10376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10377. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  10378. {
  10379. var validator = new VisaCommissionCreateDtoValidator();
  10380. var validatorRes = await validator.ValidateAsync(_dto);
  10381. if (!validatorRes.IsValid)
  10382. {
  10383. StringBuilder sb = new StringBuilder();
  10384. foreach (var item in validatorRes.Errors)
  10385. {
  10386. sb.AppendLine(item.ErrorMessage);
  10387. }
  10388. return Ok(JsonView(false, sb.ToString()));
  10389. }
  10390. return Ok(await _visaCommissionRep.Create(_dto));
  10391. }
  10392. /// <summary>
  10393. /// 签证提成录入
  10394. /// Put(编辑)
  10395. /// </summary>
  10396. /// <param name="id"></param>
  10397. /// <param name="_dto"></param>
  10398. /// <returns></returns>
  10399. [HttpPut]
  10400. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10401. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  10402. {
  10403. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10404. var validator = new VisaCommissionCreateDtoValidator();
  10405. var validatorRes = await validator.ValidateAsync(_dto);
  10406. if (!validatorRes.IsValid)
  10407. {
  10408. StringBuilder sb = new StringBuilder();
  10409. foreach (var item in validatorRes.Errors)
  10410. {
  10411. sb.AppendLine(item.ErrorMessage);
  10412. }
  10413. return Ok(JsonView(false, sb.ToString()));
  10414. }
  10415. return Ok(await _visaCommissionRep.Edit(id, _dto));
  10416. }
  10417. /// <summary>
  10418. /// 签证提成录入
  10419. /// Del
  10420. /// </summary>
  10421. /// <param name="id"></param>
  10422. /// <param name="currUserId"></param>
  10423. /// <returns></returns>
  10424. [HttpPost]
  10425. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10426. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  10427. {
  10428. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10429. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  10430. return Ok(await _visaCommissionRep.Del(id, currUserId));
  10431. }
  10432. #endregion
  10433. #region op费用录入
  10434. /// <summary>
  10435. /// 根据diid查询op费用列表
  10436. /// </summary>
  10437. /// <param name="dto"></param>
  10438. /// <returns></returns>
  10439. [HttpPost]
  10440. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10441. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  10442. {
  10443. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  10444. if (groupData.Code != 0)
  10445. {
  10446. return Ok(JsonView(false, groupData.Msg));
  10447. }
  10448. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10449. }
  10450. /// <summary>
  10451. /// 根据op费用Id查询单条数据及c表数据
  10452. /// </summary>
  10453. /// <param name="dto"></param>
  10454. /// <returns></returns>
  10455. [HttpPost]
  10456. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10457. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  10458. {
  10459. try
  10460. {
  10461. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  10462. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  10463. var data = new
  10464. {
  10465. CarTouristGuideGround = _groupData,
  10466. CreditCardPayment = _creditCardPayment
  10467. };
  10468. return Ok(JsonView(true, "查询成功!", data));
  10469. }
  10470. catch (Exception ex)
  10471. {
  10472. return Ok(JsonView(false, "程序错误!"));
  10473. }
  10474. }
  10475. /// <summary>
  10476. /// op费用删除
  10477. /// </summary>
  10478. /// <param name="dto"></param>
  10479. /// <returns></returns>
  10480. [HttpPost]
  10481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10482. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  10483. {
  10484. try
  10485. {
  10486. _sqlSugar.BeginTran();
  10487. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  10488. if (!res)
  10489. {
  10490. return Ok(JsonView(false, "删除失败"));
  10491. }
  10492. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  10493. {
  10494. IsDel = 1,
  10495. DeleteUserId = dto.DeleteUserId,
  10496. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10497. }).ExecuteCommandAsync();
  10498. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  10499. {
  10500. IsDel = 1,
  10501. DeleteUserId = dto.DeleteUserId,
  10502. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10503. }).ExecuteCommandAsync();
  10504. #region 删除超支相关数据
  10505. //删除导入的超支数据
  10506. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  10507. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  10508. {
  10509. IsDel = 1,
  10510. DeleteUserId = dto.DeleteUserId,
  10511. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10512. }).ExecuteCommand();
  10513. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  10514. {
  10515. IsDel = 1,
  10516. DeleteUserId = dto.DeleteUserId,
  10517. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10518. }).ExecuteCommand();
  10519. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  10520. {
  10521. IsDel = 1,
  10522. DeleteUserId = dto.DeleteUserId,
  10523. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10524. }).ExecuteCommand();
  10525. #endregion
  10526. _sqlSugar.CommitTran();
  10527. return Ok(JsonView(true, "删除成功!"));
  10528. }
  10529. catch (Exception ex)
  10530. {
  10531. _sqlSugar.RollbackTran();
  10532. return Ok(JsonView(false, "程序错误!" + ex.Message));
  10533. }
  10534. }
  10535. /// <summary>
  10536. /// op费用录入操作(Status:1.新增,2.修改)
  10537. /// </summary>
  10538. /// <param name="dto"></param>
  10539. /// <returns></returns>
  10540. [HttpPost]
  10541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10542. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  10543. {
  10544. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  10545. if (groupData.Code != 0)
  10546. {
  10547. return Ok(JsonView(false, groupData.Msg));
  10548. }
  10549. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10550. }
  10551. /// <summary>
  10552. /// 填写费用详细页面初始化绑定
  10553. /// </summary>
  10554. /// <param name="dto"></param>
  10555. /// <returns></returns>
  10556. [HttpPost]
  10557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10558. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  10559. {
  10560. try
  10561. {
  10562. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  10563. if (groupData.Code != 0)
  10564. {
  10565. return Ok(JsonView(false, groupData.Msg));
  10566. }
  10567. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10568. }
  10569. catch (Exception ex)
  10570. {
  10571. return Ok(JsonView(false, ex.Message));
  10572. }
  10573. }
  10574. /// <summary>
  10575. /// 根据op费用Id查询详细数据
  10576. /// </summary>
  10577. /// <param name="dto"></param>
  10578. /// <returns></returns>
  10579. [HttpPost]
  10580. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10581. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  10582. {
  10583. try
  10584. {
  10585. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  10586. if (groupData.Code != 0)
  10587. {
  10588. return Ok(JsonView(false, groupData.Msg));
  10589. }
  10590. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10591. }
  10592. catch (Exception ex)
  10593. {
  10594. return Ok(JsonView(false, ex.Message));
  10595. }
  10596. }
  10597. /// <summary>
  10598. /// OP费用录入填写详情
  10599. /// </summary>
  10600. /// <param name="dto"></param>
  10601. /// <returns></returns>
  10602. [HttpPost]
  10603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10604. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  10605. {
  10606. try
  10607. {
  10608. #region 参数校验
  10609. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  10610. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  10611. if (di == null) return Ok(JsonView(false, "团组错误!"));
  10612. #endregion
  10613. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  10614. if (groupData.Code != 0)
  10615. {
  10616. return Ok(JsonView(false, groupData.Msg));
  10617. }
  10618. //自动审核
  10619. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  10620. #region 应用推送
  10621. try
  10622. {
  10623. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10624. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10625. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10626. //2024-10-21 新增LZ UID
  10627. var userIds = new List<int>() { 21 };
  10628. string title = $"系统通知";
  10629. var diId = dto.DiId;
  10630. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10631. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10632. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  10633. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10634. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10635. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10636. }
  10637. catch (Exception ex)
  10638. {
  10639. }
  10640. #endregion
  10641. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10642. }
  10643. catch (Exception ex)
  10644. {
  10645. return Ok(JsonView(false, ex.Message));
  10646. }
  10647. }
  10648. /// <summary>
  10649. /// 获取三公详细所有城市
  10650. /// </summary>
  10651. /// <returns></returns>
  10652. [HttpGet]
  10653. public IActionResult OpCarCityResult()
  10654. {
  10655. var jw = JsonView(false);
  10656. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  10657. {
  10658. x.Id,
  10659. x.Country,
  10660. x.City,
  10661. }).ToList();
  10662. if (data.Count > 0)
  10663. {
  10664. jw = JsonView(true, "获取成功!", data);
  10665. }
  10666. else
  10667. {
  10668. jw.Msg = "城市数据为空!";
  10669. jw.Data = new string[0];
  10670. }
  10671. return Ok(jw);
  10672. }
  10673. /// <summary>
  10674. /// 导出地接费用明细
  10675. /// </summary>
  10676. /// <param name="dto"></param>
  10677. /// <returns></returns>
  10678. [HttpPost]
  10679. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  10680. {
  10681. var jw = JsonView(false);
  10682. if (dto.Diid < 1)
  10683. {
  10684. jw.Msg = "请输入正确的diid!";
  10685. return Ok(jw);
  10686. }
  10687. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  10688. if (group == null)
  10689. {
  10690. jw.Msg = "未找到团组信息!";
  10691. return Ok(jw);
  10692. }
  10693. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  10694. if (localGuideArr.Count == 0)
  10695. {
  10696. jw.Msg = "该团组暂无地接信息!";
  10697. return Ok(jw);
  10698. }
  10699. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  10700. var overspendSoure = new Dictionary<int, int>
  10701. {
  10702. { 91, 982 }, //车
  10703. { 92 , 1059} ,//导游
  10704. { 994 , 1073}, //翻译
  10705. { 988 , 1074 }, //早餐
  10706. { 93 , 1075 }, //午餐
  10707. { 989 , 1076 }, //晚餐
  10708. };
  10709. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  10710. foreach (var groupArr in localGroup)
  10711. {
  10712. var keyValue = groupArr.Key;
  10713. if (int.TryParse(keyValue, out int cityid))
  10714. {
  10715. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  10716. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  10717. }
  10718. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  10719. foreach (var item in groupArr)
  10720. {
  10721. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  10722. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  10723. new Grp_CarTouristGuideGroundReservationsContentExtend
  10724. {
  10725. Count = a.Count,
  10726. CreateTime = a.CreateTime,
  10727. CreateUserId = a.CreateUserId,
  10728. CTGGRId = a.CTGGRId,
  10729. Currency = a.Currency,
  10730. DatePrice = a.DatePrice,
  10731. DeleteTime = a.DeleteTime,
  10732. DeleteUserId = a.DeleteUserId,
  10733. DiId = a.DiId,
  10734. Id = a.Id,
  10735. IsDel = a.IsDel,
  10736. Price = a.Price,
  10737. PriceContent = a.PriceContent,
  10738. Remark = a.Remark,
  10739. SId = a.SId,
  10740. SidName = b.Name,
  10741. Units = a.Units,
  10742. }
  10743. ).ToList();
  10744. if (content.Count > 0)
  10745. {
  10746. contentArr.Add(content);
  10747. }
  10748. }
  10749. //open excel
  10750. //set excel
  10751. //save excel
  10752. try
  10753. {
  10754. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  10755. IWorkbook workbook;
  10756. if (Path.GetExtension(filePath).ToLower() == ".xls")
  10757. {
  10758. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10759. }
  10760. else
  10761. {
  10762. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10763. }
  10764. ISheet sheet = workbook.GetSheetAt(0);
  10765. var rowStartIndex = 2;
  10766. var clounmCount = 10;
  10767. var initStyleRow = sheet.GetRow(2);
  10768. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  10769. //var overspendArrDetail =
  10770. var existsId = new List<CarCompare>();
  10771. var lastElem = arr.Last();
  10772. var thisSid = -1;
  10773. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  10774. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  10775. {
  10776. Name = "未知币种!",
  10777. Remark = "未知币种!",
  10778. };
  10779. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  10780. Action cloneRowFn = () =>
  10781. {
  10782. rowStartIndex++;
  10783. var cloneRow = sheet.CreateRow(rowStartIndex);
  10784. // 复制样式
  10785. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  10786. {
  10787. ICell sourceCell = initStyleRow.GetCell(i);
  10788. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  10789. // 确保单元格存在样式
  10790. if (sourceCell.CellStyle != null)
  10791. {
  10792. targetCell.CellStyle = sourceCell.CellStyle;
  10793. }
  10794. }
  10795. };
  10796. var mergeRow = () =>
  10797. {
  10798. for (int i = 2; i < sheet.LastRowNum; i++)
  10799. {
  10800. var row = sheet.GetRow(i);
  10801. var cellFirst = row.GetCell(0);
  10802. var thisIndex = i + 1;
  10803. while (thisIndex < sheet.LastRowNum)
  10804. {
  10805. var nextRow = sheet.GetRow(thisIndex);
  10806. var nextCellFirst = nextRow.GetCell(0);
  10807. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  10808. {
  10809. thisIndex++;
  10810. }
  10811. else
  10812. {
  10813. break;
  10814. }
  10815. }
  10816. thisIndex--;
  10817. if (thisIndex != i)
  10818. {
  10819. //合并row
  10820. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10821. i, // 起始行索引(0-based)
  10822. thisIndex, // 结束行索引(0-based)
  10823. 0, // 起始列索引(0-based)
  10824. 0 // 结束列索引(0-based)
  10825. );
  10826. sheet.AddMergedRegion(cellRangeAddress);
  10827. i = thisIndex;
  10828. }
  10829. }
  10830. };
  10831. var chaoshiNumber = 0;
  10832. var totalNumber = 0.00M;
  10833. string lastStr = "";
  10834. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  10835. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  10836. {
  10837. b.IsAuditGM,
  10838. x.Id,
  10839. x.Area,
  10840. b.PayPercentage,
  10841. b.PayMoney,
  10842. }).ToList();
  10843. string yesPayment = "", noPayment = "";
  10844. foreach (var item in queryCarArrByCityAndDiid)
  10845. {
  10846. if (item.IsAuditGM == 1)
  10847. {
  10848. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10849. }
  10850. else
  10851. {
  10852. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10853. }
  10854. }
  10855. lastStr = yesPayment + noPayment;
  10856. foreach (var item in arr)
  10857. {
  10858. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  10859. {
  10860. if (thisSid != item.SId)
  10861. {
  10862. if (thisSid == -1)
  10863. {
  10864. thisSid = item.SId;
  10865. }
  10866. else
  10867. {
  10868. //合并小计行
  10869. //创建合并区域的实例
  10870. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10871. rowStartIndex, // 起始行索引(0-based)
  10872. rowStartIndex, // 结束行索引(0-based)
  10873. 0, // 起始列索引(0-based)
  10874. 3 // 结束列索引(0-based)
  10875. );
  10876. sheet.AddMergedRegion(cellRangeAddress);
  10877. var CellStyle = workbook.CreateCellStyle();
  10878. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10879. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10880. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10881. for (int i = 0; i <= clounmCount; i++)
  10882. {
  10883. if (i > 6)
  10884. {
  10885. var CellStyle1 = workbook.CreateCellStyle();
  10886. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10887. IFont Font = workbook.CreateFont(); // 创建字体
  10888. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  10889. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10890. CellStyle1.SetFont(Font);
  10891. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  10892. }
  10893. else
  10894. {
  10895. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  10896. }
  10897. }
  10898. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  10899. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  10900. //超时合计
  10901. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  10902. //超时数
  10903. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  10904. //超时合计费用
  10905. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  10906. thisSid = item.SId;
  10907. cloneRowFn();
  10908. chaoshiNumber = 0;
  10909. totalNumber = 0;
  10910. }
  10911. }
  10912. IRow row = sheet.GetRow(rowStartIndex);
  10913. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10914. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  10915. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  10916. if (isOpenOverspendSoure)
  10917. {
  10918. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10919. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  10920. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  10921. }
  10922. for (int i = 0; i <= clounmCount; i++)
  10923. {
  10924. var cell = row.GetCell(i);
  10925. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  10926. if (cell == null)
  10927. {
  10928. cell = row.CreateCell(i);
  10929. }
  10930. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  10931. fontRed.CloneStyleFrom(cell.CellStyle);
  10932. IFont Font = workbook.CreateFont(); // 创建字体
  10933. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  10934. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10935. fontRed.SetFont(Font);
  10936. byte[] rgb = new byte[3] { 255, 242, 204 };
  10937. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  10938. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  10939. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  10940. if (workbook is XSSFWorkbook)
  10941. {
  10942. BackgroundColor255_242_204.FillForegroundColor = 0;
  10943. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  10944. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  10945. }
  10946. else
  10947. {
  10948. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  10949. }
  10950. if (i == 1 || i > 6)
  10951. {
  10952. if (i > 6)
  10953. {
  10954. fontRed.FillForegroundColor = 0;
  10955. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  10956. fontRed.FillPattern = FillPattern.SolidForeground;
  10957. }
  10958. cell.CellStyle = fontRed;
  10959. }
  10960. if (i > 2 && i < 7)
  10961. {
  10962. cell.CellStyle = BackgroundColor255_242_204;
  10963. }
  10964. cell.SetCellValue(setCellValue); //写入单元格
  10965. }
  10966. if (overspendSoure.ContainsKey(thisSid))
  10967. {
  10968. var overspendId = overspendSoure[thisSid];
  10969. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10970. }
  10971. cloneRowFn();
  10972. existsId.Add(new CarCompare
  10973. {
  10974. DataPrice = item.DatePrice.ObjToDate(),
  10975. Sid = item.SId
  10976. });
  10977. }
  10978. if (item.Equals(lastElem))
  10979. {
  10980. //合并小计行
  10981. //创建合并区域的实例
  10982. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10983. rowStartIndex, // 起始行索引(0-based)
  10984. rowStartIndex, // 结束行索引(0-based)
  10985. 0, // 起始列索引(0-based)
  10986. 3 // 结束列索引(0-based)
  10987. );
  10988. sheet.AddMergedRegion(cellRangeAddress);
  10989. var CellStyle = workbook.CreateCellStyle();
  10990. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10991. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10992. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10993. for (int i = 0; i <= clounmCount; i++)
  10994. {
  10995. if (i > 6)
  10996. {
  10997. var CellStyle1 = workbook.CreateCellStyle();
  10998. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10999. IFont Font = workbook.CreateFont(); // 创建字体
  11000. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11001. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11002. CellStyle1.SetFont(Font);
  11003. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11004. }
  11005. else
  11006. {
  11007. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11008. }
  11009. }
  11010. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11011. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11012. //超时合计
  11013. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11014. //超时数
  11015. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11016. //超时合计费用
  11017. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11018. cloneRowFn();
  11019. // 创建合并区域的实例
  11020. cellRangeAddress = new CellRangeAddress(
  11021. rowStartIndex, // 起始行索引(0-based)
  11022. rowStartIndex, // 结束行索引(0-based)
  11023. 0, // 起始列索引(0-based)
  11024. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  11025. );
  11026. // 添加合并区域
  11027. sheet.AddMergedRegion(cellRangeAddress);
  11028. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  11029. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  11030. }
  11031. }
  11032. mergeRow();
  11033. // 保存修改后的Excel文件到新文件
  11034. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  11035. // new FileStream(newFilePath, FileMode.CreateNew)
  11036. using (var stream = new MemoryStream())
  11037. {
  11038. workbook.Write(stream, true);
  11039. stream.Flush();
  11040. stream.Seek(0, SeekOrigin.Begin);
  11041. MemoryStream memoryStream = new MemoryStream();
  11042. stream.CopyTo(memoryStream);
  11043. memoryStream.Seek(0, SeekOrigin.Begin);
  11044. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  11045. }
  11046. workbook.Close();
  11047. workbook.Dispose();
  11048. }
  11049. catch (Exception ex)
  11050. {
  11051. jw.Msg = "出现异常!" + ex.Message;
  11052. return Ok(jw);
  11053. }
  11054. }
  11055. if (Zips.Count > 0)
  11056. {
  11057. IOOperatorHelper io = new IOOperatorHelper();
  11058. var byts = io.ConvertZipStream(Zips);
  11059. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  11060. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  11061. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  11062. }
  11063. else
  11064. {
  11065. jw.Msg = "暂无生成文件!";
  11066. }
  11067. return Ok(jw);
  11068. }
  11069. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  11070. {
  11071. string outStr = string.Empty;
  11072. switch (i)
  11073. {
  11074. case 0:
  11075. outStr = arr[0].SidName;
  11076. break;
  11077. case 1:
  11078. outStr = arr[0].DataPriceStr;
  11079. break;
  11080. case 2:
  11081. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  11082. break;
  11083. case 4:
  11084. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  11085. break;
  11086. case 7:
  11087. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11088. {
  11089. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  11090. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  11091. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  11092. }
  11093. break;
  11094. case 8:
  11095. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11096. {
  11097. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  11098. }
  11099. break;
  11100. case 9:
  11101. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11102. {
  11103. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  11104. }
  11105. break;
  11106. case 10:
  11107. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11108. {
  11109. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  11110. }
  11111. break;
  11112. }
  11113. return outStr;
  11114. }
  11115. #region OP行程单
  11116. /// <summary>
  11117. /// OP行程单初始化
  11118. /// </summary>
  11119. /// <param name="dto"></param>
  11120. /// <returns></returns>
  11121. [HttpPost]
  11122. public IActionResult InitOpTravel(InitOpTravelDto dto)
  11123. {
  11124. var jw = JsonView(false);
  11125. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  11126. var group = groupList.First();
  11127. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11128. if (group == null)
  11129. {
  11130. jw.Msg = "暂无团组!";
  11131. return Ok(jw);
  11132. }
  11133. group = groupList.Find(x => x.Id == diid);
  11134. if (group == null)
  11135. {
  11136. jw.Msg = "请输入正确的团组ID!";
  11137. return Ok(jw);
  11138. }
  11139. string city = string.Empty;
  11140. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  11141. if (blackCode.Count > 0)
  11142. {
  11143. var black = blackCode.First();
  11144. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  11145. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  11146. if (blackSp.Length > 0)
  11147. {
  11148. try
  11149. {
  11150. var cityArrCode = new List<string>(20);
  11151. foreach (var item in blackSp)
  11152. {
  11153. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  11154. var IndexSelect = itemSp[2];
  11155. var cityArrCodeLength = cityArrCode.Count - 1;
  11156. var startCity = IndexSelect.Substring(0, 3);
  11157. if (cityArrCodeLength > 0)
  11158. {
  11159. var arrEndCity = cityArrCode[cityArrCodeLength];
  11160. if (arrEndCity != startCity)
  11161. {
  11162. cityArrCode.Add(startCity.ToUpper());
  11163. }
  11164. }
  11165. else
  11166. {
  11167. cityArrCode.Add(startCity.ToUpper());
  11168. }
  11169. var endCity = IndexSelect.Substring(3, 3);
  11170. cityArrCode.Add(endCity.ToUpper());
  11171. }
  11172. var cityThree = string.Empty;
  11173. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  11174. cityThree = cityThree.TrimEnd(',');
  11175. if (string.IsNullOrWhiteSpace(cityThree))
  11176. {
  11177. throw new
  11178. Exception("error");
  11179. }
  11180. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  11181. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  11182. foreach (var item in cityArrCode)
  11183. {
  11184. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  11185. if (find != null)
  11186. {
  11187. city += find.City + "/";
  11188. }
  11189. else
  11190. {
  11191. city += item + "三字码未收入/";
  11192. }
  11193. }
  11194. city = city.TrimEnd('/');
  11195. }
  11196. catch (Exception e)
  11197. {
  11198. city = "黑屏代码格式不正确!";
  11199. }
  11200. }
  11201. }
  11202. else
  11203. {
  11204. city = "未录入黑屏代码";
  11205. }
  11206. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  11207. {
  11208. Date = x.Date,
  11209. Days = x.Days,
  11210. Diffgroup = x.Diffgroup,
  11211. Diid = x.Diid,
  11212. Traffic_First = x.Traffic_First,
  11213. Traffic_Second = x.Traffic_Second,
  11214. Trip = x.Trip,
  11215. WeekDay = x.WeekDay,
  11216. Id = x.Id
  11217. }).ToList();
  11218. jw.Data = new
  11219. {
  11220. groupList = groupList.Select(x => new
  11221. {
  11222. x.Id,
  11223. x.TeamName,
  11224. x.TourCode
  11225. }).ToList(),
  11226. groupInfo = new
  11227. {
  11228. group.VisitDays,
  11229. group.TourCode,
  11230. group.VisitPNumber,
  11231. group.TeamName,
  11232. city
  11233. },
  11234. OpTravelList
  11235. };
  11236. jw.Code = 200;
  11237. jw.Msg = "操作成功!";
  11238. return Ok(jw);
  11239. }
  11240. /// <summary>
  11241. /// 删除团组行程单
  11242. /// </summary>
  11243. /// <returns></returns>
  11244. [HttpPost]
  11245. public IActionResult DelTravel(DelOpTravelDto dto)
  11246. {
  11247. var jw = JsonView(false);
  11248. if (dto.UserId <= 0 || dto.Diid <= 0)
  11249. {
  11250. jw.Msg = "请输入正确的参数!";
  11251. return Ok(jw);
  11252. }
  11253. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  11254. .SetColumns(x => new Grp_TravelList
  11255. {
  11256. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11257. DeleteUserId = dto.UserId,
  11258. IsDel = 1,
  11259. }).ExecuteCommand();
  11260. jw = JsonView(true);
  11261. return Ok(jw);
  11262. }
  11263. /// <summary>
  11264. /// 行程单保存
  11265. /// </summary>
  11266. /// <returns></returns>
  11267. [HttpPost]
  11268. public IActionResult TravelSave(TravelSaveDto dto)
  11269. {
  11270. var jw = JsonView(false);
  11271. if (dto.Arr.Count > 0)
  11272. {
  11273. try
  11274. {
  11275. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  11276. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  11277. .ToList();
  11278. _sqlSugar.BeginTran();
  11279. foreach (var item in dto.Arr)
  11280. {
  11281. if (item.Id == 0)
  11282. {
  11283. throw new Exception("请传入正确的Id");
  11284. }
  11285. //比较上一次的差异
  11286. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  11287. if (findTravel != null)
  11288. {
  11289. item.Trip = item.Trip.Replace("[++]", string.Empty);
  11290. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  11291. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  11292. }
  11293. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  11294. .SetColumns(x => new Grp_TravelList
  11295. {
  11296. Trip = item.Trip
  11297. }).ExecuteCommand();
  11298. }
  11299. _sqlSugar.CommitTran();
  11300. jw = JsonView(true);
  11301. }
  11302. catch (Exception ex)
  11303. {
  11304. _sqlSugar.RollbackTran();
  11305. jw.Msg = "程序异常!" + ex.Message;
  11306. }
  11307. }
  11308. else
  11309. {
  11310. jw.Msg = "请传入正确的参数!";
  11311. }
  11312. return Ok(jw);
  11313. }
  11314. private string CheckStr(string original, string changed)
  11315. {
  11316. // 创建diff_match_patch对象
  11317. var dmp = new diff_match_patch();
  11318. // 计算差异
  11319. List<Diff> diffs = dmp.diff_main(original, changed);
  11320. // 清理和合并差异
  11321. dmp.diff_cleanupSemantic(diffs);
  11322. // 使用StringBuilder构建最终的字符串
  11323. StringBuilder finalString = new StringBuilder();
  11324. // 输出差异结果,并构建变动后的字符串
  11325. foreach (Diff diff in diffs)
  11326. {
  11327. switch (diff.operation)
  11328. {
  11329. case Operation.EQUAL:
  11330. // 相等的部分,直接添加到最终字符串
  11331. finalString.Append(diff.text);
  11332. break;
  11333. case Operation.INSERT:
  11334. // 插入的部分,添加标记并添加到最终字符串
  11335. finalString.Append("[++]" + diff.text + "[++]");
  11336. break;
  11337. case Operation.DELETE:
  11338. // 删除的部分,不添加到最终字符串
  11339. //finalString.Append("[++]" + diff.text + "[++]");
  11340. break;
  11341. }
  11342. }
  11343. // 输出变动后的字符串
  11344. return finalString.ToString();
  11345. }
  11346. private class tagContent
  11347. {
  11348. public DateTime Date { get; set; }
  11349. public string StartTag { get; set; }
  11350. public string EndTag { get; set; }
  11351. public string Content { get; set; }
  11352. public static int tagLength { get { return 3; } }
  11353. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  11354. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  11355. public bool IsFinally { get; set; }
  11356. }
  11357. private List<string> ExtractContentBetweenTags(string input, string tag)
  11358. {
  11359. List<string> results = new List<string>();
  11360. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  11361. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  11362. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  11363. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  11364. string[] strValueArr = new string[1];
  11365. foreach (System.Text.RegularExpressions.Match match in matches)
  11366. {
  11367. var strValue = match.Groups[1].Value;
  11368. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  11369. }
  11370. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  11371. return results;
  11372. }
  11373. /// <summary>
  11374. /// 导出行程单
  11375. /// </summary>
  11376. /// <param name="dto"></param>
  11377. /// <returns></returns>
  11378. [HttpPost]
  11379. public IActionResult ExportTravel(ExportTravelDto dto)
  11380. {
  11381. var jw = JsonView(false);
  11382. jw.Data = "";
  11383. int diid = 0;
  11384. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  11385. if (Find == null)
  11386. {
  11387. jw.Msg = "请选择正确的团组!";
  11388. return Ok(jw);
  11389. }
  11390. else
  11391. {
  11392. diid = Find.Id;
  11393. }
  11394. //数据源
  11395. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  11396. DataTable dtBlack = null;
  11397. try
  11398. {
  11399. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  11400. }
  11401. catch (Exception)
  11402. {
  11403. jw.Msg = "机票黑屏代码有误!";
  11404. return Ok(jw);
  11405. }
  11406. string CityStr = string.Empty;
  11407. if (dtBlack.Rows.Count == 0)
  11408. {
  11409. jw.Msg = "机票黑屏代码有误!";
  11410. return Ok(jw);
  11411. }
  11412. else
  11413. {
  11414. foreach (DataRow row in dtBlack.Rows)
  11415. {
  11416. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11417. {
  11418. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  11419. return Ok(jw);
  11420. }
  11421. }
  11422. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  11423. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  11424. }
  11425. // 指定的文字
  11426. var targetTextDic = new Dictionary<string, List<string>>();
  11427. //创建数据源Table
  11428. DataTable dtSource = new DataTable();
  11429. dtSource.Columns.Add("Days", typeof(string));
  11430. dtSource.Columns.Add("Date", typeof(string));
  11431. dtSource.Columns.Add("Week", typeof(string));
  11432. dtSource.Columns.Add("Traffic", typeof(string));
  11433. dtSource.Columns.Add("Trip", typeof(string));
  11434. //获取数据,放到datatable
  11435. foreach (var item in _travelList)
  11436. {
  11437. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  11438. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  11439. .Replace(tagContent.TagFormat.Item2, string.Empty)
  11440. .Replace("[++]", string.Empty);
  11441. DataRow dr = dtSource.NewRow();
  11442. dr["Days"] = item.Days;
  11443. dr["Date"] = item.Date;
  11444. dr["Week"] = item.WeekDay;
  11445. dr["Traffic"] = item.Traffic_First
  11446. + "\r\n"
  11447. + item.Traffic_Second;
  11448. dr["Trip"] = item.Trip;
  11449. dtSource.Rows.Add(dr);
  11450. }
  11451. Dictionary<string, string> dic = new Dictionary<string, string>();
  11452. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  11453. dic.Add("City", CityStr);
  11454. dic.Add("Days", Find.VisitDays.ToString());
  11455. dic.Add("DeleCode", Find.TourCode);
  11456. dic.Add("Pnum", Find.VisitPNumber.ToString());
  11457. //模板路径
  11458. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  11459. //载入模板
  11460. Document doc = null;
  11461. DocumentBuilder builder = null;
  11462. try
  11463. {
  11464. //载入模板
  11465. doc = new Document(tempPath);
  11466. builder = new DocumentBuilder(doc);
  11467. }
  11468. catch (Exception)
  11469. {
  11470. jw.Msg = "模板位置不存在!";
  11471. return Ok(jw);
  11472. }
  11473. foreach (var key in dic.Keys)
  11474. {
  11475. Bookmark bookmark = doc.Range.Bookmarks[key];
  11476. if (bookmark != null)
  11477. {
  11478. builder.MoveToBookmark(key);
  11479. builder.Write(dic[key]);
  11480. }
  11481. }
  11482. //获取word里所有表格
  11483. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11484. //获取所填表格的序数
  11485. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11486. try
  11487. {
  11488. //循环赋值
  11489. for (int i = 0; i < dtSource.Rows.Count; i++)
  11490. {
  11491. builder.MoveToCell(0, i + 1, 0, 0);
  11492. builder.Write(dtSource.Rows[i]["Days"].ToString());
  11493. builder.MoveToCell(0, i + 1, 1, 0);
  11494. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  11495. builder.MoveToCell(0, i + 1, 2, 0);
  11496. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  11497. var trip = dtSource.Rows[i]["Trip"].ToString();
  11498. builder.MoveToCell(0, i + 1, 3, 0);
  11499. builder.Write(trip);
  11500. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  11501. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11502. // 获取特定索引的段落
  11503. Paragraph paragraph = (Paragraph)paragraphs[0];
  11504. Run run = paragraph.Runs[0];
  11505. Aspose.Words.Font font = run.Font;
  11506. font.Name = "黑体";
  11507. //设置双休红色
  11508. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  11509. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11510. paragraph = (Paragraph)paragraphs[1];
  11511. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  11512. {
  11513. run = paragraph.Runs[0];
  11514. font = run.Font;
  11515. font.Color = Color.Red;
  11516. }
  11517. }
  11518. }
  11519. catch (Exception ex)
  11520. {
  11521. }
  11522. //删除多余行
  11523. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  11524. {
  11525. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  11526. }
  11527. var targetTextList = new List<string>();
  11528. // 遍历文档中的表格
  11529. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11530. {
  11531. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11532. {
  11533. var cellIndex = 0;
  11534. foreach (Cell cell in row.Cells)
  11535. {
  11536. if (cellIndex == 1 && row.Cells.Count == 4)
  11537. {
  11538. foreach (var target in targetTextDic.Keys)
  11539. {
  11540. if (cell.GetText().Contains(target))
  11541. {
  11542. targetTextList = targetTextDic[target];
  11543. break;
  11544. }
  11545. }
  11546. }
  11547. // 遍历单元格中的所有段落
  11548. foreach (Paragraph paragraph in cell.Paragraphs)
  11549. {
  11550. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  11551. List<Run> runs = new List<Run>();
  11552. foreach (Run run in paragraph.Runs)
  11553. {
  11554. runs.Add(run);
  11555. }
  11556. foreach (Run run in runs)
  11557. {
  11558. foreach (var targetText in targetTextList)
  11559. {
  11560. // 检查文字是否包含指定文字
  11561. if (run.Text.Contains(targetText))
  11562. {
  11563. // 将包含的部分设置为红色
  11564. HighlightText(run, targetText, Color.Red);
  11565. }
  11566. }
  11567. }
  11568. }
  11569. cellIndex++;
  11570. }
  11571. }
  11572. }
  11573. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  11574. if (!Directory.Exists(savePath))
  11575. {
  11576. try
  11577. {
  11578. Directory.CreateDirectory(savePath);
  11579. }
  11580. catch
  11581. {
  11582. }
  11583. }
  11584. string path = savePath + Find.TeamName + "出访日程";
  11585. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  11586. try
  11587. {
  11588. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  11589. string postfix = ".docx";
  11590. if (dto.IsPDF == 1)
  11591. {
  11592. saveFormat = Aspose.Words.SaveFormat.Pdf;
  11593. postfix = ".pdf";
  11594. }
  11595. doc.Save(path + postfix, saveFormat);
  11596. jw = JsonView(true, "导出成功", ftpPath + postfix);
  11597. }
  11598. catch (Exception)
  11599. {
  11600. jw = JsonView(false);
  11601. }
  11602. return Ok(jw);
  11603. }
  11604. /// <summary>
  11605. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  11606. /// </summary>
  11607. /// <param name="num"></param>
  11608. /// <returns></returns>
  11609. string GetNum(string num)
  11610. {
  11611. string str = "";
  11612. switch (num)
  11613. {
  11614. case "1":
  11615. str = "一";
  11616. break;
  11617. case "2":
  11618. str = "二";
  11619. break;
  11620. case "3":
  11621. str = "三";
  11622. break;
  11623. case "4":
  11624. str = "四";
  11625. break;
  11626. case "5":
  11627. str = "五";
  11628. break;
  11629. case "6":
  11630. str = "六";
  11631. break;
  11632. case "7":
  11633. str = "七";
  11634. break;
  11635. case "8":
  11636. str = "八";
  11637. break;
  11638. case "9":
  11639. str = "九";
  11640. break;
  11641. case "10":
  11642. str = "十";
  11643. break;
  11644. case "11":
  11645. str = "十一";
  11646. break;
  11647. case "12":
  11648. str = "十二";
  11649. break;
  11650. case "一":
  11651. str = "1";
  11652. break;
  11653. case "二":
  11654. str = "2";
  11655. break;
  11656. case "三":
  11657. str = "3";
  11658. break;
  11659. case "四":
  11660. str = "4";
  11661. break;
  11662. case "五":
  11663. str = "5";
  11664. break;
  11665. case "六":
  11666. str = "6";
  11667. break;
  11668. case "七":
  11669. str = "7";
  11670. break;
  11671. case "八":
  11672. str = "8";
  11673. break;
  11674. case "九":
  11675. str = "9";
  11676. break;
  11677. case "十":
  11678. str = "10";
  11679. break;
  11680. case "十一":
  11681. str = "11";
  11682. break;
  11683. case "十二":
  11684. str = "12";
  11685. break;
  11686. }
  11687. return str;
  11688. }
  11689. // 高亮包含指定文字的部分
  11690. void HighlightText(Run run, string targetText, Color color)
  11691. {
  11692. string text = run.Text;
  11693. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  11694. if (startIndex >= 0)
  11695. {
  11696. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  11697. // 前部分
  11698. if (startIndex > 0)
  11699. {
  11700. Run beforeRun = (Run)run.Clone(true);
  11701. beforeRun.Text = text.Substring(0, startIndex);
  11702. parentParagraph.InsertBefore(beforeRun, run);
  11703. }
  11704. // 匹配部分
  11705. Run matchRun = (Run)run.Clone(true);
  11706. matchRun.Text = text.Substring(startIndex, targetText.Length);
  11707. matchRun.Font.Color = color;
  11708. parentParagraph.InsertBefore(matchRun, run);
  11709. // 后部分
  11710. if (startIndex + targetText.Length < text.Length)
  11711. {
  11712. Run afterRun = (Run)run.Clone(true);
  11713. afterRun.Text = text.Substring(startIndex + targetText.Length);
  11714. parentParagraph.InsertBefore(afterRun, run);
  11715. }
  11716. // 删除原始Run
  11717. run.Remove();
  11718. }
  11719. }
  11720. #endregion
  11721. #endregion
  11722. #region 团组成本
  11723. /// <summary>
  11724. /// 团组成本数据初始化
  11725. /// </summary>
  11726. /// <param name="dto"></param>
  11727. /// <returns></returns>
  11728. [HttpPost]
  11729. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  11730. {
  11731. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  11732. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  11733. WHEN COUNT(*) >= 0 THEN 'True'
  11734. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  11735. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  11736. ").ToList(); //团组列表
  11737. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  11738. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  11739. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  11740. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  11741. if (groupinfoValue != null)
  11742. {
  11743. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  11744. var spArr = new string[1] { countryArr };
  11745. if (countryArr.Contains("|"))
  11746. {
  11747. spArr = countryArr.Split("|");
  11748. }
  11749. else if (countryArr.Contains("、"))
  11750. {
  11751. spArr = countryArr.Split("、");
  11752. }
  11753. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  11754. {
  11755. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  11756. if (dbQueryCountry != null)
  11757. {
  11758. visaCountryInfoArr.Add(dbQueryCountry);
  11759. }
  11760. }
  11761. }
  11762. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  11763. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  11764. var create = _GroupCostRepository.
  11765. CreateGroupCostByBlackCode(dto.Diid);
  11766. if (groupCost.Count == 0 && create.Code == 0)
  11767. {
  11768. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  11769. }
  11770. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  11771. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  11772. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  11773. groupCostMap = groupCostMap.Select(x =>
  11774. {
  11775. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  11776. {
  11777. x.Date = dataForamt.ToString("yyyy-MM-dd");
  11778. }
  11779. return x;
  11780. }).ToList();
  11781. //GroupCostParameter.Add(new
  11782. // Grp_GroupCostParameter());
  11783. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  11784. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  11785. return Ok(JsonView(new
  11786. {
  11787. groupList,
  11788. groupInfo,
  11789. groupChecks,
  11790. groupCost = groupCostMap,
  11791. hotelNumber,
  11792. GroupCostParameter = GroupCostParameterMap,
  11793. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  11794. {
  11795. x.VisaCountry,
  11796. x.VisaPrice,
  11797. x.Id,
  11798. }).ToList(),
  11799. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  11800. blackCodeIsTrue = create.Code == 0 ? true : false,
  11801. hotelIsTrue = hotelIsTrue,
  11802. }));
  11803. }
  11804. /// <summary>
  11805. /// 团组成本信息保存
  11806. /// </summary>
  11807. /// <param name="dto"></param>
  11808. /// <returns></returns>
  11809. [HttpPost]
  11810. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  11811. {
  11812. if (dto.Diid <= 0 || dto.Userid <= 0)
  11813. {
  11814. return Ok(JsonView(false));
  11815. }
  11816. JsonView jw = null;
  11817. bool isTrue = false;
  11818. #region 复制团组成本
  11819. //if (dto.Diid == 2581)
  11820. //{
  11821. // dto.Diid = 2599;
  11822. // dto.CheckBoxs.ForEach(x =>
  11823. // {
  11824. // x.Diid = 2599;
  11825. // });
  11826. // dto.GroupCosts.ForEach(x =>
  11827. // {
  11828. // x.Diid = 2599;
  11829. // });
  11830. // dto.CostTypeHotelNumbers.ForEach(x =>
  11831. // {
  11832. // x.Diid = 2599;
  11833. // });
  11834. // dto.GroupCostParameters.ForEach(x =>
  11835. // {
  11836. // x.DiId = 2599;
  11837. // });
  11838. //}
  11839. #endregion
  11840. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  11841. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  11842. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  11843. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  11844. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  11845. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  11846. try
  11847. {
  11848. _sqlSugar.BeginTran();
  11849. isTrue = await _GroupCostRepository.
  11850. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  11851. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  11852. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  11853. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  11854. _sqlSugar.CommitTran();
  11855. jw = JsonView(true, "保存成功!", isTrue);
  11856. }
  11857. catch (Exception)
  11858. {
  11859. _sqlSugar.RollbackTran();
  11860. jw = JsonView(false);
  11861. }
  11862. return Ok(jw);
  11863. }
  11864. /// <summary>
  11865. /// 司兼导数据
  11866. /// </summary>
  11867. /// <param name="dto"></param>
  11868. /// <returns></returns>
  11869. [HttpPost]
  11870. public IActionResult GetCarGuides(CarGuidesDto dto)
  11871. {
  11872. JsonView jw = null;
  11873. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  11874. jw = JsonView(true, "获取成功!", Data);
  11875. return Ok(jw);
  11876. }
  11877. /// <summary>
  11878. /// 导游数据
  11879. /// </summary>
  11880. /// <param name="dto"></param>
  11881. /// <returns></returns>
  11882. [HttpPost]
  11883. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  11884. {
  11885. JsonView jw = null;
  11886. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  11887. // 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
  11888. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  11889. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  11890. jw = JsonView(true, "获取成功!", Data);
  11891. return Ok(jw);
  11892. }
  11893. /// <summary>
  11894. /// 成本车数据
  11895. /// </summary>
  11896. /// <param name="dto"></param>
  11897. /// <returns></returns>
  11898. [HttpPost]
  11899. public IActionResult GetCarInfo(CarGuidesDto dto)
  11900. {
  11901. JsonView jw = null;
  11902. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  11903. jw = JsonView(true, "获取成功!", Data);
  11904. return Ok(jw);
  11905. }
  11906. /// <summary>
  11907. /// 景点数据
  11908. /// </summary>
  11909. /// <param name="dto"></param>
  11910. /// <returns></returns>
  11911. [HttpPost]
  11912. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  11913. {
  11914. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  11915. return Ok(JsonView(true, "获取成功!", Data));
  11916. }
  11917. /// <summary>
  11918. /// 成本通知
  11919. /// </summary>
  11920. /// <param name="dto"></param>
  11921. /// <returns></returns>
  11922. [HttpPost]
  11923. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  11924. {
  11925. if (dto.Diid < 0)
  11926. {
  11927. return Ok(JsonView(false));
  11928. }
  11929. JsonView jw = null;
  11930. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  11931. if (GroupCostParameter != null)
  11932. {
  11933. int IsShare = 0;
  11934. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  11935. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  11936. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  11937. string msg = string.Empty;
  11938. if (isTrue)
  11939. {
  11940. if (IsShare == 0)
  11941. {
  11942. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  11943. }
  11944. else
  11945. {
  11946. #region 企微通知对应岗位用户
  11947. try
  11948. {
  11949. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  11950. }
  11951. catch (Exception ex)
  11952. {
  11953. }
  11954. #endregion
  11955. msg = "通知成功,其他模块操作人员可见此成本信息!";
  11956. }
  11957. jw = JsonView(isTrue, msg, new { IsShare });
  11958. }
  11959. else
  11960. {
  11961. msg = "修改失败!";
  11962. jw = JsonView(isTrue, msg);
  11963. }
  11964. }
  11965. else
  11966. {
  11967. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  11968. }
  11969. return Ok(jw);
  11970. }
  11971. /// <summary>
  11972. /// 导出报价单
  11973. /// </summary>
  11974. /// <param name="dto"></param>
  11975. /// <returns></returns>
  11976. [HttpPost]
  11977. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  11978. {
  11979. if (dto.Diid == 0)
  11980. {
  11981. return Ok(JsonView(false, "请传递团组id"));
  11982. }
  11983. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  11984. if (deleInfo.Code != 0)
  11985. {
  11986. return Ok(JsonView(false, "团组信息查询失败!"));
  11987. }
  11988. var di = deleInfo.Data as DelegationInfoWebView;
  11989. if (di != null)
  11990. {
  11991. di.TeamName = di.TeamName.Replace("|", "、");
  11992. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  11993. //文件名
  11994. string strFileName = di.TeamName + "-收款账单.doc";
  11995. //获取模板
  11996. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  11997. //载入模板
  11998. Document doc = new Document(tmppath);
  11999. decimal TotalPrice = 0.00M;
  12000. string itemStr = string.Empty;
  12001. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  12002. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12003. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12004. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  12005. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  12006. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  12007. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  12008. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  12009. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  12010. foreach (var cost in groupCostType)
  12011. {
  12012. var List = cost.ToList();
  12013. if (cost.Key == "A")
  12014. {
  12015. foreach (var ListItem in List)
  12016. {
  12017. if (ListItem.number > 0)
  12018. {
  12019. if (ListItem.code.Contains("TBR"))
  12020. {
  12021. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12022. }
  12023. else
  12024. {
  12025. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12026. }
  12027. TotalPrice += (ListItem.number * ListItem.price);
  12028. }
  12029. }
  12030. }
  12031. else
  12032. {
  12033. itemStr = itemStr.Insert(0, "A段\r\n");
  12034. itemStr += "B段\r\n";
  12035. foreach (var ListItem in List)
  12036. {
  12037. if (ListItem.number > 0)
  12038. {
  12039. if (ListItem.code.Contains("TBR"))
  12040. {
  12041. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12042. }
  12043. else
  12044. {
  12045. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12046. }
  12047. TotalPrice += (ListItem.number * ListItem.price);
  12048. }
  12049. }
  12050. }
  12051. }
  12052. #region 替换Word模板书签内容
  12053. Dictionary<string, string> marks = new Dictionary<string, string>();
  12054. marks.Add("To", di.ClientUnit);//付款方
  12055. marks.Add("ToTel", di.TellPhone);//付款方电话
  12056. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  12057. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  12058. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  12059. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  12060. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  12061. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  12062. marks.Add("PayItemContent", itemStr);//详细信息
  12063. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  12064. #endregion
  12065. ////注
  12066. //if (doc.Range.Bookmarks["Attention"] != null)
  12067. //{
  12068. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  12069. // mark.Text = frList[0].Attention;
  12070. //}
  12071. foreach (var item in marks.Keys)
  12072. {
  12073. if (doc.Range.Bookmarks[item] != null)
  12074. {
  12075. Bookmark mark = doc.Range.Bookmarks[item];
  12076. mark.Text = marks[item];
  12077. }
  12078. }
  12079. byte[] bytes = null;
  12080. using (MemoryStream stream = new MemoryStream())
  12081. {
  12082. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  12083. bytes = stream.ToArray();
  12084. }
  12085. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  12086. return Ok(JsonView(true, "", new
  12087. {
  12088. Data = bytes,
  12089. strFileName,
  12090. }));
  12091. }
  12092. else
  12093. {
  12094. return Ok(JsonView(false, "团组信息不存在!"));
  12095. }
  12096. }
  12097. /// <summary>
  12098. /// 导出团组成本
  12099. /// </summary>
  12100. /// <param name="dto"></param>
  12101. /// <returns></returns>
  12102. [HttpPost]
  12103. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  12104. {
  12105. var jw = JsonView(false);
  12106. if (dto.Diid == 0)
  12107. {
  12108. return Ok(JsonView(false, "请传递团组id"));
  12109. }
  12110. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12111. if (deleInfo.Code != 0)
  12112. {
  12113. return Ok(JsonView(false, "团组信息查询失败!"));
  12114. }
  12115. var di = deleInfo.Data as DelegationInfoWebView;
  12116. if (di == null)
  12117. {
  12118. return Ok(JsonView(false, "团组信息查询失败!"));
  12119. }
  12120. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  12121. WorkbookDesigner designer = new WorkbookDesigner();
  12122. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  12123. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  12124. for (int i = 0; i < List_GC.Count; i++)
  12125. {
  12126. GroupCost_Excel gc = new GroupCost_Excel();
  12127. gc.Id = List_GC[i].Id;
  12128. gc.Diid = List_GC[i].Diid.ToString();
  12129. gc.DAY = List_GC[i].DAY;
  12130. string week = "";
  12131. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  12132. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  12133. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  12134. gc.ITIN = List_GC[i].ITIN;
  12135. gc.CarType = List_GC[i].CarType;
  12136. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  12137. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  12138. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  12139. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  12140. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  12141. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  12142. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  12143. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  12144. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  12145. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  12146. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  12147. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  12148. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12149. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12150. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  12151. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  12152. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  12153. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  12154. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  12155. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  12156. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  12157. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  12158. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  12159. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  12160. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  12161. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  12162. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  12163. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  12164. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  12165. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  12166. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  12167. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  12168. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  12169. List_GC1.Add(gc);
  12170. }
  12171. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  12172. dt.TableName = "TB";
  12173. //报表标题等不用dt的值
  12174. designer.SetDataSource("TeamName", dto.title.TeamName);
  12175. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  12176. designer.SetDataSource("Tax", dto.title.Tax);
  12177. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  12178. designer.SetDataSource("Currency", dto.title.Currency);
  12179. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  12180. designer.SetDataSource("Rate", dto.title.Rate);
  12181. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  12182. var Aparams = hotels.Find(x => x.Type == "Default");
  12183. if (Aparams == null)
  12184. {
  12185. return Ok(jw);
  12186. }
  12187. //酒店数量
  12188. var txtSGRNumber = Aparams.SGR.ToString();
  12189. var txtTBRNumber = Aparams.TBR.ToString();
  12190. var txtJSESNumber = Aparams.JSES.ToString();
  12191. var txtSUITENumbe = Aparams.SUITE.ToString();
  12192. if (dto.costType == "B")
  12193. {
  12194. Aparams = hotels.Find(x => x.Type == "A");
  12195. var Bparams = hotels.Find(x => x.Type == "B");
  12196. if (Aparams == null || Bparams == null)
  12197. {
  12198. return Ok(jw);
  12199. }
  12200. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  12201. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  12202. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  12203. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  12204. }
  12205. designer.SetDataSource("SGRNumber", txtSGRNumber);
  12206. designer.SetDataSource("TBRNumber", txtTBRNumber);
  12207. designer.SetDataSource("JSESNumber", txtJSESNumber);
  12208. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  12209. var ws = designer.Workbook.Worksheets[0];
  12210. int Row = List_GC.Count;
  12211. int startIndex = 11;
  12212. int HideRows = 0;
  12213. List<int> hideRowsList = new List<int>();
  12214. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  12215. #region A段left数据
  12216. var left = dto.leftInfo.Find(x => x.Type == "A");
  12217. if (left == null)
  12218. {
  12219. return Ok(jw);
  12220. }
  12221. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  12222. if (leftBindData != null)
  12223. {
  12224. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  12225. designer.SetDataSource("VisaRS", leftBindData.rs);
  12226. designer.SetDataSource("VisaXS", leftBindData.xs);
  12227. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12228. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12229. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12230. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12231. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12232. }
  12233. else
  12234. {
  12235. hideRowsList.Add(Row + startIndex + HideRows);
  12236. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12237. }
  12238. HideRows += 2;
  12239. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  12240. if (leftBindData != null)
  12241. {
  12242. designer.SetDataSource("BXDRCB", leftBindData.cb);
  12243. designer.SetDataSource("BXRS", leftBindData.rs);
  12244. designer.SetDataSource("BXXS", leftBindData.xs);
  12245. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12246. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12247. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12248. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12249. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12250. }
  12251. else
  12252. {
  12253. hideRowsList.Add(Row + startIndex + HideRows);
  12254. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12255. }
  12256. HideRows += 2;
  12257. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12258. if (leftBindData != null)
  12259. {
  12260. designer.SetDataSource("HSDRCB", leftBindData.cb);
  12261. designer.SetDataSource("HSRS", leftBindData.rs);
  12262. designer.SetDataSource("HSXS", leftBindData.xs);
  12263. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12264. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12265. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12266. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12267. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12268. }
  12269. else
  12270. {
  12271. hideRowsList.Add(Row + startIndex + HideRows);
  12272. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12273. }
  12274. HideRows += 2;
  12275. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12276. if (leftBindData != null)
  12277. {
  12278. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  12279. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  12280. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  12281. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12282. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12283. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12284. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12285. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12286. }
  12287. else
  12288. {
  12289. hideRowsList.Add(Row + startIndex + HideRows);
  12290. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12291. }
  12292. HideRows += 2;
  12293. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12294. if (leftBindData != null)
  12295. {
  12296. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  12297. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  12298. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  12299. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12300. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12301. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12302. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12303. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12304. }
  12305. else
  12306. {
  12307. hideRowsList.Add(Row + startIndex + HideRows);
  12308. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12309. }
  12310. HideRows += 2;
  12311. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12312. if (leftBindData != null)
  12313. {
  12314. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  12315. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  12316. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  12317. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12318. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12319. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12320. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12321. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12322. }
  12323. else
  12324. {
  12325. hideRowsList.Add(Row + startIndex + HideRows);
  12326. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12327. }
  12328. HideRows += 2;
  12329. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12330. if (leftBindData != null)
  12331. {
  12332. ////TBR
  12333. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  12334. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  12335. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  12336. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12337. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12338. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12339. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12340. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12341. }
  12342. else
  12343. {
  12344. hideRowsList.Add(Row + startIndex + HideRows);
  12345. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12346. }
  12347. HideRows += 2;
  12348. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12349. if (leftBindData != null)
  12350. {
  12351. ////SGR
  12352. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  12353. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  12354. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  12355. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12356. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12357. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12358. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12359. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12360. }
  12361. else
  12362. {
  12363. hideRowsList.Add(Row + startIndex + HideRows);
  12364. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12365. }
  12366. HideRows += 2;
  12367. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12368. if (leftBindData != null)
  12369. {
  12370. ////JS/ES
  12371. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  12372. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  12373. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  12374. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12375. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12376. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12377. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12378. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12379. }
  12380. else
  12381. {
  12382. hideRowsList.Add(Row + startIndex + HideRows);
  12383. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12384. }
  12385. HideRows += 2;
  12386. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12387. if (leftBindData != null)
  12388. {
  12389. ////SUITE
  12390. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  12391. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  12392. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  12393. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12394. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12395. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12396. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12397. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12398. }
  12399. else
  12400. {
  12401. hideRowsList.Add(Row + startIndex + HideRows);
  12402. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12403. }
  12404. HideRows += 2;
  12405. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12406. if (leftBindData != null)
  12407. {
  12408. designer.SetDataSource("DJDRCB", leftBindData.cb);
  12409. designer.SetDataSource("DJRS", leftBindData.rs);
  12410. designer.SetDataSource("DJXS", leftBindData.xs);
  12411. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12412. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12413. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12414. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12415. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12416. }
  12417. else
  12418. {
  12419. hideRowsList.Add(Row + startIndex + HideRows);
  12420. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12421. }
  12422. HideRows += 2;
  12423. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12424. if (leftBindData != null)
  12425. {
  12426. designer.SetDataSource("HCPCB", leftBindData.cb);
  12427. designer.SetDataSource("HCPRS", leftBindData.rs);
  12428. designer.SetDataSource("HCPXS", leftBindData.xs);
  12429. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12430. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12431. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12432. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12433. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12434. }
  12435. else
  12436. {
  12437. hideRowsList.Add(Row + startIndex + HideRows);
  12438. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12439. }
  12440. HideRows += 2;
  12441. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12442. if (leftBindData != null)
  12443. {
  12444. designer.SetDataSource("CPCB", leftBindData.cb);
  12445. designer.SetDataSource("CPRS", leftBindData.rs);
  12446. designer.SetDataSource("CPXS", leftBindData.xs);
  12447. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12448. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12449. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12450. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12451. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12452. }
  12453. else
  12454. {
  12455. hideRowsList.Add(Row + startIndex + HideRows);
  12456. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12457. }
  12458. HideRows += 2;
  12459. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12460. if (leftBindData != null)
  12461. {
  12462. designer.SetDataSource("GWDRCD", leftBindData.cb);
  12463. designer.SetDataSource("GWRS", leftBindData.rs);
  12464. designer.SetDataSource("GWXS", leftBindData.xs);
  12465. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12466. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12467. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12468. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12469. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12470. }
  12471. else
  12472. {
  12473. hideRowsList.Add(Row + startIndex + HideRows);
  12474. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12475. }
  12476. HideRows += 2;
  12477. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12478. if (leftBindData != null)
  12479. {
  12480. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  12481. designer.SetDataSource("LYJRS", leftBindData.rs);
  12482. designer.SetDataSource("LYJXS", leftBindData.xs);
  12483. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12484. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12485. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12486. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12487. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12488. }
  12489. else
  12490. {
  12491. hideRowsList.Add(Row + startIndex + HideRows);
  12492. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12493. }
  12494. #endregion
  12495. #region A段Right信息
  12496. var right = dto.rightInfo.Find(x => x.Type == "A");
  12497. if (right == null)
  12498. {
  12499. return Ok(jw);
  12500. }
  12501. HideRows += 4;
  12502. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12503. if (rightBindData != null)
  12504. {
  12505. //经济舱 + 双人间 TBR
  12506. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  12507. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  12508. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12509. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  12510. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12511. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12512. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12513. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12514. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12515. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12516. }
  12517. else
  12518. {
  12519. hideRowsList.Add(Row + startIndex + HideRows);
  12520. }
  12521. HideRows += 2;
  12522. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12523. if (rightBindData != null)
  12524. {
  12525. //经济舱 + 单人间 SGR
  12526. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  12527. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  12528. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12529. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  12530. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12531. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12532. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12533. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12534. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12535. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12536. }
  12537. else
  12538. {
  12539. hideRowsList.Add(Row + startIndex + HideRows);
  12540. }
  12541. HideRows += 2;
  12542. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12543. if (rightBindData != null)
  12544. {
  12545. //公务舱 + 单人间 SGR
  12546. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  12547. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  12548. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12549. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  12550. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12551. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12552. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12553. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12554. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12555. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12556. }
  12557. else
  12558. {
  12559. hideRowsList.Add(Row + startIndex + HideRows);
  12560. }
  12561. HideRows += 2;
  12562. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12563. if (rightBindData != null)
  12564. {
  12565. //公务舱 + 小套房 JSES
  12566. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  12567. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  12568. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12569. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  12570. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12571. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12572. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12573. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12574. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12575. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12576. }
  12577. else
  12578. {
  12579. hideRowsList.Add(Row + startIndex + HideRows);
  12580. }
  12581. HideRows += 2;
  12582. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12583. if (rightBindData != null)
  12584. {
  12585. //公务舱 + 小套房 JSES
  12586. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  12587. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  12588. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12589. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  12590. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12591. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12592. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12593. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12594. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12595. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12596. }
  12597. else
  12598. {
  12599. hideRowsList.Add(Row + startIndex + HideRows);
  12600. }
  12601. HideRows += 2;
  12602. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12603. if (rightBindData != null)
  12604. {
  12605. //经济舱 + 大套房
  12606. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  12607. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  12608. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12609. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  12610. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12611. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12612. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12613. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12614. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12615. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12616. }
  12617. else
  12618. {
  12619. hideRowsList.Add(Row + startIndex + HideRows);
  12620. }
  12621. HideRows += 2;
  12622. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12623. if (rightBindData != null)
  12624. {
  12625. //头等舱 + 小套房 JSES
  12626. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  12627. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  12628. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12629. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  12630. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12631. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12632. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12633. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12634. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12635. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12636. }
  12637. else
  12638. {
  12639. hideRowsList.Add(Row + startIndex + HideRows);
  12640. }
  12641. HideRows += 2;
  12642. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12643. if (rightBindData != null)
  12644. {
  12645. //头等舱 + 大套房
  12646. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  12647. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  12648. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12649. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  12650. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12651. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12652. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12653. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12654. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12655. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12656. }
  12657. else
  12658. {
  12659. hideRowsList.Add(Row + startIndex + HideRows);
  12660. }
  12661. #endregion
  12662. #region B段标题清空
  12663. designer.SetDataSource("CostBDRCB", "");
  12664. designer.SetDataSource("CostBRS", "");
  12665. designer.SetDataSource("CostBXS", "");
  12666. designer.SetDataSource("CostBZCB", "");
  12667. designer.SetDataSource("CostBDRBJ", "");
  12668. designer.SetDataSource("CostBZBJ", "");
  12669. designer.SetDataSource("CostBDRLR", "");
  12670. designer.SetDataSource("CostBZLR", "");
  12671. designer.SetDataSource("CostBDRCBOM", "");
  12672. designer.SetDataSource("CostBRSOM", "");
  12673. designer.SetDataSource("CostBZCBOM", "");
  12674. designer.SetDataSource("CostBDRBJOM", "");
  12675. designer.SetDataSource("CostBZBJOM", "");
  12676. designer.SetDataSource("CostBDRLROM", "");
  12677. designer.SetDataSource("CostBZLROM", "");
  12678. #endregion
  12679. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  12680. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  12681. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  12682. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  12683. designer.SetDataSource("DJName", "地接(CNY)");
  12684. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  12685. designer.SetDataSource("CPName", "地接-船票(CNY)");
  12686. designer.SetDataSource("GWName", "公务(CNY)");
  12687. designer.SetDataSource("YQHName", "邀请函(CNY)");
  12688. designer.SetDataSource("LYJName", "零用金(CNY)");
  12689. designer.SetDataSource("HSName", "核酸检测(CNY)");
  12690. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  12691. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  12692. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  12693. designer.SetDataSource("BXName", "保险(CNY)");
  12694. designer.SetDataSource("VisaName", "签证(CNY)");
  12695. #region B段基本数据
  12696. if (dto.costType == "B")
  12697. {
  12698. left = dto.leftInfo.Find(x => x.Type == "B");
  12699. if (left == null)
  12700. {
  12701. return Ok(jw);
  12702. }
  12703. #region B段left数据
  12704. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12705. if (leftBindData != null)
  12706. {
  12707. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  12708. designer.SetDataSource("BHSRS", leftBindData.rs);
  12709. designer.SetDataSource("BHSXS", leftBindData.xs);
  12710. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12711. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12712. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12713. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12714. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12715. }
  12716. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12717. if (leftBindData != null)
  12718. {
  12719. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  12720. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  12721. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  12722. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12723. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12724. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12725. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12726. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12727. }
  12728. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12729. if (leftBindData != null)
  12730. {
  12731. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  12732. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  12733. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  12734. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12735. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12736. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12737. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12738. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12739. }
  12740. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12741. if (leftBindData != null)
  12742. {
  12743. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  12744. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  12745. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  12746. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12747. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12748. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12749. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12750. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12751. }
  12752. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12753. if (leftBindData != null)
  12754. {
  12755. designer.SetDataSource("BHCPCB", leftBindData.cb);
  12756. designer.SetDataSource("BHCPRS", leftBindData.rs);
  12757. designer.SetDataSource("BHCPXS", leftBindData.xs);
  12758. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12759. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12760. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12761. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12762. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12763. }
  12764. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12765. if (leftBindData != null)
  12766. {
  12767. designer.SetDataSource("BCPCB", leftBindData.cb);
  12768. designer.SetDataSource("BCPRS", leftBindData.rs);
  12769. designer.SetDataSource("BCPXS", leftBindData.xs);
  12770. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12771. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12772. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12773. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12774. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12775. }
  12776. //TBR
  12777. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12778. if (leftBindData != null)
  12779. {
  12780. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  12781. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  12782. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  12783. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12784. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12785. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12786. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12787. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12788. }
  12789. //SGR
  12790. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12791. if (leftBindData != null)
  12792. {
  12793. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  12794. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  12795. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  12796. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12797. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12798. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12799. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12800. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12801. }
  12802. //JS/ES
  12803. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12804. if (leftBindData != null)
  12805. {
  12806. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  12807. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  12808. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  12809. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12810. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12811. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12812. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12813. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12814. }
  12815. //SUITE
  12816. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12817. if (leftBindData != null)
  12818. {
  12819. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  12820. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  12821. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  12822. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12823. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12824. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12825. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12826. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12827. }
  12828. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12829. if (leftBindData != null)
  12830. {
  12831. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  12832. designer.SetDataSource("BDJRS", leftBindData.rs);
  12833. designer.SetDataSource("BDJXS", leftBindData.xs);
  12834. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12835. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12836. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12837. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12838. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12839. }
  12840. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12841. if (leftBindData != null)
  12842. {
  12843. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  12844. designer.SetDataSource("BGWRS", leftBindData.rs);
  12845. designer.SetDataSource("BGWXS", leftBindData.xs);
  12846. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12847. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12848. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12849. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12850. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12851. }
  12852. #region 优化方案
  12853. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  12854. //excelBind.Add("零用金", new {
  12855. //cb="",
  12856. //rs="",
  12857. //xs ="",
  12858. //zcb = "",
  12859. //});
  12860. #endregion
  12861. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12862. if (leftBindData != null)
  12863. {
  12864. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  12865. designer.SetDataSource("BLYJRS", leftBindData.rs);
  12866. designer.SetDataSource("BLYJXS", leftBindData.xs);
  12867. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12868. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12869. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12870. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12871. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12872. }
  12873. #endregion
  12874. #region B段Right信息
  12875. right = dto.rightInfo.Find(x => x.Type == "B");
  12876. if (right == null)
  12877. {
  12878. return Ok(jw);
  12879. }
  12880. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12881. if (rightBindData != null)
  12882. {
  12883. //经济舱 + 双人间 TBR
  12884. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  12885. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  12886. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12887. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  12888. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12889. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12890. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12891. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12892. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12893. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12894. }
  12895. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12896. if (rightBindData != null)
  12897. {
  12898. //经济舱 + 单人间 SGR
  12899. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  12900. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  12901. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12902. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  12903. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12904. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12905. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12906. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12907. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12908. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12909. }
  12910. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12911. if (rightBindData != null)
  12912. {
  12913. //公务舱 + 单人间 SGR
  12914. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  12915. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  12916. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12917. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  12918. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12919. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12920. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12921. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12922. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12923. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12924. }
  12925. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12926. if (rightBindData != null)
  12927. {
  12928. //公务舱 + 小套房 JSES
  12929. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  12930. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  12931. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12932. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  12933. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12934. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12935. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12936. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12937. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12938. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12939. }
  12940. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12941. if (rightBindData != null)
  12942. {
  12943. //公务舱 + 小套房 JSES
  12944. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  12945. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  12946. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12947. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  12948. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12949. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12950. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12951. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12952. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12953. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12954. }
  12955. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12956. if (rightBindData != null)
  12957. {
  12958. //经济舱 + 大套房
  12959. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  12960. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  12961. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12962. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  12963. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12964. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12965. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12966. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12967. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12968. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12969. }
  12970. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12971. if (rightBindData != null)
  12972. {
  12973. //头等舱 + 小套房 JSES
  12974. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  12975. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  12976. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12977. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  12978. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12979. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12980. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12981. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12982. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12983. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12984. }
  12985. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12986. if (rightBindData != null)
  12987. {
  12988. //头等舱 + 大套房
  12989. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  12990. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  12991. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12992. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  12993. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12994. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12995. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12996. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12997. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12998. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12999. }
  13000. #endregion
  13001. #region 标题
  13002. designer.SetDataSource("CostBDRCB", "单人成本");
  13003. designer.SetDataSource("CostBRS", "人数");
  13004. designer.SetDataSource("CostBXS", "系数");
  13005. designer.SetDataSource("CostBZCB", "总成本");
  13006. designer.SetDataSource("CostBDRBJ", "单人报价");
  13007. designer.SetDataSource("CostBZBJ", "总报价");
  13008. designer.SetDataSource("CostBDRLR", "单人利润");
  13009. designer.SetDataSource("CostBZLR", "总利润");
  13010. designer.SetDataSource("CostBDRCBOM", "单人成本");
  13011. designer.SetDataSource("CostBRSOM", "人数");
  13012. designer.SetDataSource("CostBZCBOM", "总成本");
  13013. designer.SetDataSource("CostBDRBJOM", "单人报价");
  13014. designer.SetDataSource("CostBZBJOM", "总报价");
  13015. designer.SetDataSource("CostBDRLROM", "单人利润");
  13016. designer.SetDataSource("CostBZLROM", "总利润");
  13017. #endregion
  13018. }
  13019. #endregion
  13020. designer.SetDataSource("TzZCB2", TzZCB2);
  13021. designer.SetDataSource("TzZBJ2", TzZBJ2);
  13022. designer.SetDataSource("TzZLR2", TzZLR2);
  13023. string[] dataSourceKeys = new string[]
  13024. {
  13025. "VF",
  13026. "TGS",
  13027. "TGOF",
  13028. "TGM",
  13029. "TGA",
  13030. "TGTF",
  13031. "TGEF",
  13032. "CFM",
  13033. "CFOF",
  13034. "B",
  13035. "L",
  13036. "D",
  13037. "TBR",
  13038. "SGR",
  13039. "JSES",
  13040. "Suite",
  13041. "TV",
  13042. "1L",
  13043. "IF",
  13044. "EF",
  13045. "BRF",
  13046. "TE",
  13047. "TGT",
  13048. "DRVT",
  13049. "PC",
  13050. "TLF",
  13051. "ECT"
  13052. };
  13053. foreach (var item in dataSourceKeys)
  13054. {
  13055. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  13056. if (find != null)
  13057. {
  13058. designer.SetDataSource(item, find.text);
  13059. }
  13060. else
  13061. {
  13062. designer.SetDataSource(item, 0);
  13063. }
  13064. }
  13065. designer.SetDataSource(dt);
  13066. //根据数据源处理生成报表内容
  13067. designer.Process();
  13068. designer.Workbook.Worksheets[0].Name = "清单";
  13069. Worksheet sheet = designer.Workbook.Worksheets[0];
  13070. foreach (var Rowindex in hideRowsList)
  13071. {
  13072. ws.Cells.HideRows(Rowindex, 2);
  13073. }
  13074. byte[] bytes = null;
  13075. string strFileName = di.TeamName + "-团组-成本.xls";
  13076. using (MemoryStream stream = new MemoryStream())
  13077. {
  13078. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  13079. bytes = stream.ToArray();
  13080. }
  13081. return Ok(JsonView(true, "", new
  13082. {
  13083. Data = bytes,
  13084. strFileName,
  13085. }));
  13086. }
  13087. /// <summary>
  13088. /// 导出客户报表
  13089. /// </summary>
  13090. /// <returns></returns>
  13091. [HttpPost]
  13092. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  13093. {
  13094. var jw = JsonView(false);
  13095. if (dto.Diid == 0)
  13096. {
  13097. return Ok(JsonView(false, "请传递团组id"));
  13098. }
  13099. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13100. if (deleInfo.Code != 0)
  13101. {
  13102. return Ok(JsonView(false, "团组信息查询失败!"));
  13103. }
  13104. var di = deleInfo.Data as DelegationInfoWebView;
  13105. if (di == null)
  13106. {
  13107. return Ok(JsonView(false, "团组信息查询失败!"));
  13108. }
  13109. //文件名
  13110. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  13111. //获取模板
  13112. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  13113. //载入模板
  13114. Document doc = new Document(tmppath);
  13115. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  13116. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  13117. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  13118. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  13119. var AParameter = ParameterList.Find(x => x.CostType == "A");
  13120. var BParameter = ParameterList.Find(x => x.CostType == "B");
  13121. if (AParameter == null)
  13122. {
  13123. return Ok(JsonView(false, "系数不存在!"));
  13124. }
  13125. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  13126. , TzAirDesc, TzZCost;
  13127. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  13128. = TzAirDesc = TzZCost = string.Empty;
  13129. TzNumber = AParameter.CostTypenumber.ToString();
  13130. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  13131. CarGuides1 = dto.CarGuides1;
  13132. Meal = dto.Meal;
  13133. SubsidizedMeals = dto.SubsidizedMeals;
  13134. NightRepair = dto.NightRepair;
  13135. AttractionsTickets = dto.AttractionsTickets;
  13136. MiscellaneousFees = dto.MiscellaneousFees;
  13137. ATip = dto.ATip;
  13138. TzHotelDesc = "";
  13139. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  13140. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  13141. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  13142. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  13143. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  13144. TzAirDesc = "";
  13145. TzZCost = dto.TzZCost;
  13146. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  13147. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  13148. var index = 1;
  13149. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  13150. foreach (var item in TzHotelDescArr)
  13151. {
  13152. if (AinfoArr != null)
  13153. {
  13154. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13155. if (Ainfo != null)
  13156. {
  13157. if (int.Parse(Ainfo.rs) <= 0)
  13158. {
  13159. continue;
  13160. }
  13161. var hotelText = string.Empty;
  13162. switch (item)
  13163. {
  13164. case "SGR":
  13165. hotelText = "单人间";
  13166. break;
  13167. case "JSES":
  13168. hotelText = "小套房";
  13169. break;
  13170. case "SUITE":
  13171. hotelText = "套房";
  13172. break;
  13173. case "TBR":
  13174. hotelText = "双人间";
  13175. break;
  13176. }
  13177. if (item != "TBR")
  13178. {
  13179. 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";
  13180. }
  13181. else
  13182. {
  13183. 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";
  13184. }
  13185. index++;
  13186. }
  13187. }
  13188. }
  13189. index = 1;
  13190. foreach (var item in TzAirDescArr)
  13191. {
  13192. if (AinfoArr != null)
  13193. {
  13194. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13195. if (Ainfo != null)
  13196. {
  13197. if (int.Parse(Ainfo.rs) <= 0)
  13198. {
  13199. continue;
  13200. }
  13201. 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";
  13202. index++;
  13203. }
  13204. }
  13205. }
  13206. if (dto.costType == "B")
  13207. {
  13208. if (BParameter == null)
  13209. {
  13210. return Ok(JsonView(false, "B段系数不存在!"));
  13211. }
  13212. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  13213. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  13214. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  13215. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  13216. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  13217. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  13218. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  13219. foreach (var item in TzHotelDescArr)
  13220. {
  13221. if (AinfoArr != null)
  13222. {
  13223. TzHotelDesc += "B段信息 \r\n";
  13224. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13225. if (Ainfo != null)
  13226. {
  13227. if (int.Parse(Ainfo.rs) <= 0)
  13228. {
  13229. continue;
  13230. }
  13231. var hotelText = string.Empty;
  13232. switch (item)
  13233. {
  13234. case "SGR":
  13235. hotelText = "单人间";
  13236. break;
  13237. case "JSES":
  13238. hotelText = "小套房";
  13239. break;
  13240. case "SUITE":
  13241. hotelText = "套房";
  13242. break;
  13243. case "TBR":
  13244. hotelText = "双人间";
  13245. break;
  13246. }
  13247. if (item != "TBR")
  13248. {
  13249. 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";
  13250. }
  13251. else
  13252. {
  13253. 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";
  13254. }
  13255. index++;
  13256. }
  13257. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  13258. }
  13259. }
  13260. index = 1;
  13261. foreach (var item in TzAirDescArr)
  13262. {
  13263. if (AinfoArr != null)
  13264. {
  13265. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13266. if (Ainfo != null)
  13267. {
  13268. if (int.Parse(Ainfo.rs) <= 0)
  13269. {
  13270. continue;
  13271. }
  13272. 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";
  13273. index++;
  13274. }
  13275. }
  13276. }
  13277. }
  13278. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  13279. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  13280. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  13281. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  13282. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  13283. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  13284. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  13285. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  13286. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  13287. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  13288. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  13289. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  13290. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  13291. DickeyValue.Add("Visa", Visa); // 签证单人报价
  13292. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  13293. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  13294. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  13295. DickeyValue.Add("TzZCost", TzZCost);
  13296. foreach (var key in DickeyValue.Keys)
  13297. {
  13298. if (doc.Range.Bookmarks[key] != null)
  13299. {
  13300. Bookmark mark = doc.Range.Bookmarks[key];
  13301. mark.Text = DickeyValue[key];
  13302. }
  13303. }
  13304. byte[] bytes = null;
  13305. string strFileName = di.TeamName + "-客户报价.doc";
  13306. using (MemoryStream stream = new MemoryStream())
  13307. {
  13308. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13309. bytes = stream.ToArray();
  13310. }
  13311. return Ok(JsonView(true, "", new
  13312. {
  13313. Data = bytes,
  13314. strFileName,
  13315. }));
  13316. }
  13317. /// <summary>
  13318. /// 团组成本 各模块(酒店,地接,机票)成本提示
  13319. /// </summary>
  13320. /// <param name="dto"></param>
  13321. /// <returns></returns>
  13322. [HttpPost]
  13323. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13324. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  13325. {
  13326. try
  13327. {
  13328. #region 参数验证
  13329. if (dto.DiId < 0)
  13330. {
  13331. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  13332. }
  13333. List<int> cTableIds = new List<int>() {
  13334. 76 ,//酒店预订
  13335. 77 ,//行程
  13336. 79 ,//车/导游地接
  13337. 80 ,//签证
  13338. 81 ,//邀请/公务活
  13339. 82 ,//团组客户保险
  13340. 85 ,//机票预订
  13341. 98 ,//其他款项
  13342. 285 ,//收款退还
  13343. 751 ,//酒店早餐
  13344. 1015 // 超支费用
  13345. };
  13346. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  13347. {
  13348. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  13349. }
  13350. #endregion
  13351. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  13352. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  13353. if (_GroupCostParameters.Count <= 0)
  13354. {
  13355. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  13356. }
  13357. if (_GroupCostParameters[0].IsShare == 0)
  13358. {
  13359. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  13360. }
  13361. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13362. //处理date为空问题
  13363. if (_GroupCosts.Count > 0)
  13364. {
  13365. for (int i = 0; i < _GroupCosts.Count; i++)
  13366. {
  13367. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  13368. {
  13369. if (i > 0)
  13370. {
  13371. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  13372. }
  13373. }
  13374. }
  13375. }
  13376. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  13377. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  13378. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  13379. string currCode = "";
  13380. #region currCode 验证
  13381. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  13382. if (isInt)
  13383. {
  13384. var currData = currDatas.Find(it => it.Id == intCurrency);
  13385. if (currData != null)
  13386. {
  13387. currCode = currData.Name;
  13388. }
  13389. }
  13390. else
  13391. {
  13392. currCode = _GroupCostParameters[0].Currency.Trim();
  13393. }
  13394. #endregion
  13395. //op,酒店单段模式存储
  13396. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  13397. {
  13398. CurrencyCode = currCode,
  13399. Rate = _GroupCostParameters[0].Rate,
  13400. CostType = _GroupCostParameters[0].CostType,
  13401. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  13402. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  13403. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  13404. };
  13405. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  13406. if (_GroupCostParameters.Count == 2)
  13407. {
  13408. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  13409. }
  13410. foreach (var item in _GroupCostParameters)
  13411. {
  13412. decimal _rate = 1;
  13413. decimal _rate1 = item.Rate;
  13414. decimal _scale = 1;
  13415. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  13416. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  13417. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  13418. //if (userInfo != null)
  13419. //{
  13420. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  13421. // {
  13422. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  13423. // {
  13424. // _scale = 1.00M;
  13425. // }
  13426. // }
  13427. //}
  13428. #endregion
  13429. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  13430. {
  13431. CurrencyCode = currCode,
  13432. Rate = _rate1,
  13433. CostType = item.CostType,
  13434. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  13435. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  13436. CostTypeNumber = item.CostTypenumber
  13437. };
  13438. if (_GroupCostParameters.Count > 1)
  13439. {
  13440. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  13441. }
  13442. else
  13443. {
  13444. modulePromptInfo.CostTypeNumber = item.LYJRS;
  13445. }
  13446. if (dto.CTable == 79)//
  13447. {
  13448. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  13449. modulePromptInfo.TotalCost = item.DJCB;
  13450. }
  13451. List<string> costTypes = new List<string>() { "A", "B" };
  13452. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  13453. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  13454. if (_GroupCostsDuplicates.Count() == 1)
  13455. {
  13456. _GroupCostsTypeData = _GroupCosts;
  13457. }
  13458. else
  13459. {
  13460. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  13461. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  13462. }
  13463. /*
  13464. * 76 酒店预订
  13465. * 77 行程
  13466. * 79 车/导游地接
  13467. * 80 签证
  13468. * 81 邀请/公务活动
  13469. * 82 团组客户保险
  13470. * 85 机票预订
  13471. * 98 其他款项
  13472. * 285 收款退还
  13473. * 751 酒店早餐
  13474. * 1015 超支费用
  13475. */
  13476. switch (dto.CTable)
  13477. {
  13478. case 76: // 酒店预订
  13479. _ModuleSubPromptInfo.AddRange(
  13480. _GroupCostsTypeData.Select(it => new
  13481. {
  13482. it.DAY,
  13483. it.Date,
  13484. it.ACCON,
  13485. it.ITIN,
  13486. it.SGR,
  13487. it.TBR,
  13488. it.JS_ES,
  13489. it.Suite
  13490. })
  13491. );
  13492. break;
  13493. case 79: // 车/导游地接
  13494. _ModuleSubPromptInfo.AddRange(
  13495. _GroupCostsTypeData.Select(it => new
  13496. {
  13497. Date = it.Date, //日期
  13498. CarFee = it.CarCost * _rate * _scale, //车费用
  13499. CarType = it.CarType, //车型
  13500. DriverFee = it.CFS * _rate * _scale, //司机工资
  13501. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  13502. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  13503. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  13504. GuideFee = it.TGS * _rate * _scale, //导游费用
  13505. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  13506. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  13507. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  13508. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  13509. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  13510. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  13511. Breakfast = it.B * _rate * _scale, //早餐费
  13512. Lunch = it.L * _rate * _scale, //午餐费
  13513. Dinner = it.D * _rate * _scale, //晚餐费
  13514. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  13515. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  13516. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  13517. TicketFee = it.EF * _rate * _scale, //门票费
  13518. TicketRemark = it.EFR, //门票费描述
  13519. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  13520. TravelSupplies = it.TE * _rate * _scale, //出行物资
  13521. SpentCash = it.PC * _rate * _scale, //零用金
  13522. LeadersFee = it.TLF * _rate * _scale, //领队费
  13523. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  13524. })
  13525. );
  13526. break;
  13527. case 85: // 机票
  13528. List<dynamic> datas = new List<dynamic>();
  13529. datas.Add(
  13530. new
  13531. {
  13532. AirType = "经济舱",
  13533. AirNum = item.JJCRS,
  13534. AirDRCB = item.JJCCB,
  13535. AirZCB = (item.JJCRS * item.JJCCB)
  13536. }
  13537. );
  13538. datas.Add(
  13539. new
  13540. {
  13541. AirType = "公务舱",
  13542. AirNum = item.GWCRS,
  13543. AirDRCB = item.GWCCB,
  13544. AirZCB = (item.GWCRS * item.GWCCB)
  13545. }
  13546. );
  13547. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13548. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  13549. modulePromptInfo.Data = new
  13550. {
  13551. airFeeData = datas,
  13552. airInitData = initDatas
  13553. };
  13554. _ModulePromptInfos.Add(modulePromptInfo);
  13555. break;
  13556. default:
  13557. break;
  13558. }
  13559. }
  13560. if (dto.CTable != 85)
  13561. {
  13562. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  13563. _ModulePromptInfos.Add(_ModulePromptInfo);
  13564. }
  13565. _view.ModulePromptInfos = _ModulePromptInfos;
  13566. return Ok(JsonView(true, "操作成功!", _view));
  13567. }
  13568. catch (Exception ex)
  13569. {
  13570. return Ok(JsonView(false, ex.Message));
  13571. }
  13572. }
  13573. /// <summary>
  13574. /// 根据黑屏代码重新生成行程
  13575. /// </summary>
  13576. /// <param name="dto"></param>
  13577. /// <returns></returns>
  13578. [HttpPost]
  13579. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  13580. {
  13581. var jw = JsonView(false);
  13582. var Create = _GroupCostRepository.
  13583. CreateGroupCostByBlackCode(dto.Diid);
  13584. jw.Msg = Create.Msg;
  13585. if (Create.Code == 0)
  13586. {
  13587. jw.Code = 200;
  13588. jw.Data = new
  13589. {
  13590. groupCost = Create.Data,
  13591. blackCodeIsTrue = true
  13592. };
  13593. }
  13594. else
  13595. {
  13596. jw.Code = 400;
  13597. jw.Data = new
  13598. {
  13599. groupCost = Create.Data,
  13600. blackCodeIsTrue = false,
  13601. };
  13602. }
  13603. return Ok(jw);
  13604. }
  13605. /// <summary>
  13606. /// 成本获取OP历史车费用
  13607. /// </summary>
  13608. /// <param name="dto"></param>
  13609. /// <returns></returns>
  13610. [HttpPost]
  13611. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  13612. {
  13613. var jw = JsonView(false);
  13614. try
  13615. {
  13616. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  13617. //获取现有所有车的数据
  13618. if (!dto.Param.IsNullOrWhiteSpace())
  13619. {
  13620. string sql = $@"
  13621. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  13622. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  13623. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  13624. 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
  13625. AND gctggr.ServiceEndTime is not NULL
  13626. ORDER by gctggrc.id DESC
  13627. ";
  13628. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  13629. var numeberResult = await Task.Run(() =>
  13630. {
  13631. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  13632. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  13633. return numberArr;
  13634. });
  13635. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  13636. foreach (var item in numeberResult)
  13637. {
  13638. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  13639. {
  13640. Country = "数据异常!",
  13641. City = string.Empty,
  13642. };
  13643. item.Area = find.Country + " " + find.City;
  13644. }
  13645. dbResult.AddRange(numeberResult);
  13646. if (dto.Param.Contains("、"))
  13647. {
  13648. var sp = dto.Param.Split("、");
  13649. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13650. .Where(x =>
  13651. {
  13652. return System.Array.Exists(sp, e =>
  13653. {
  13654. bool where = false;
  13655. if (x.Area != null)
  13656. {
  13657. where = x.Area.Contains(e);
  13658. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13659. {
  13660. return false;
  13661. }
  13662. }
  13663. if (x.PriceName != null && !where)
  13664. {
  13665. where = x.PriceName.Contains(e);
  13666. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13667. {
  13668. return false;
  13669. }
  13670. }
  13671. return where;
  13672. });
  13673. }).ToList();
  13674. }
  13675. else
  13676. {
  13677. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13678. .Where(x =>
  13679. {
  13680. bool where = false;
  13681. if (x.Area != null)
  13682. {
  13683. where = x.Area.Contains(dto.Param);
  13684. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13685. {
  13686. return false;
  13687. }
  13688. }
  13689. if (x.PriceName != null && !where)
  13690. {
  13691. where = x.PriceName.Contains(dto.Param);
  13692. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13693. {
  13694. return false;
  13695. }
  13696. }
  13697. return where;
  13698. }
  13699. )
  13700. .ToList();
  13701. }
  13702. }
  13703. var view = dbResult.Select(x =>
  13704. {
  13705. decimal dp = 0.00M;
  13706. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  13707. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  13708. if (string.IsNullOrWhiteSpace(x.DatePrice))
  13709. {
  13710. if (startB && endB)
  13711. {
  13712. var timesp = endD.Subtract(startD);
  13713. if ((timesp.Days + 1) != 0)
  13714. {
  13715. dp = x.Price / (timesp.Days + 1);
  13716. }
  13717. }
  13718. }
  13719. else
  13720. {
  13721. dp = x.Price;
  13722. }
  13723. return new
  13724. {
  13725. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  13726. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  13727. x.Area,
  13728. x.id,
  13729. price = x.Price.ToString("F2"),
  13730. x.PriceName,
  13731. x.PriceContent,
  13732. x.TeamName,
  13733. x.DatePrice,
  13734. dayPrice = dp.ToString("F2"),
  13735. };
  13736. }).OrderByDescending(x => x.id).ToList();
  13737. jw = JsonView(true, "获取成功!", view);
  13738. }
  13739. catch (Exception e)
  13740. {
  13741. jw = JsonView(false, e.Message);
  13742. }
  13743. return Ok(jw);
  13744. }
  13745. #endregion
  13746. #region 酒店预订 新 雷怡 2023-12-28 17:45
  13747. /// <summary>
  13748. /// 酒店预订
  13749. /// 酒店费用列表 根据团组Id查询
  13750. /// </summary>
  13751. /// <param name="_dto"></param>
  13752. /// <returns></returns>
  13753. [HttpPost]
  13754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13755. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  13756. {
  13757. #region 参数验证
  13758. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13759. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13760. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13761. #region 团组操作权限验证 76 酒店预定模块
  13762. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13763. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13764. #endregion
  13765. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13766. #region 页面操作权限验证
  13767. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13768. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13769. #endregion
  13770. #endregion
  13771. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  13772. }
  13773. /// <summary>
  13774. /// 酒店预订
  13775. /// 基础数据
  13776. /// </summary>
  13777. /// <param name="_dto"></param>
  13778. /// <returns></returns>
  13779. [HttpPost]
  13780. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13781. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  13782. {
  13783. #region 参数验证
  13784. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13785. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13786. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13787. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13788. #region 页面操作权限验证
  13789. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13790. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13791. #endregion
  13792. #region 团组操作权限验证 76 酒店预定模块
  13793. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13794. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13795. #endregion
  13796. #endregion
  13797. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  13798. }
  13799. /// <summary>
  13800. /// 酒店预订
  13801. /// 创建 入住卷号码
  13802. /// </summary>
  13803. /// <param name="_dto"></param>
  13804. /// <returns></returns>
  13805. [HttpPost]
  13806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13807. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  13808. {
  13809. #region 参数验证
  13810. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13811. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13812. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13813. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13814. #region 页面操作权限验证
  13815. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13816. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13817. #endregion
  13818. #region 团组操作权限验证 76 酒店预定模块
  13819. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13820. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13821. #endregion
  13822. #endregion
  13823. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  13824. if (data.Code != 0)
  13825. {
  13826. return Ok(JsonView(false, data.Msg));
  13827. }
  13828. return Ok(JsonView(true, data.Msg, data.Data));
  13829. }
  13830. /// <summary>
  13831. /// 酒店预订
  13832. /// 详情
  13833. /// </summary>
  13834. /// <param name="_dto"></param>
  13835. /// <returns></returns>
  13836. [HttpPost]
  13837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13838. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  13839. {
  13840. #region 参数验证
  13841. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  13842. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13843. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  13844. #region 团组操作权限验证 76 酒店预定模块
  13845. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13846. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13847. #endregion
  13848. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13849. #region 页面操作权限验证
  13850. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13851. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13852. #endregion
  13853. #endregion
  13854. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  13855. }
  13856. /// <summary>
  13857. /// 酒店预订
  13858. /// Add Or Edit
  13859. /// </summary>
  13860. /// <param name="_dto"></param>
  13861. /// <returns></returns>
  13862. [HttpPost]
  13863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13864. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  13865. {
  13866. #region 参数验证
  13867. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13868. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13869. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13870. #region 团组操作权限验证 76 酒店预定模块
  13871. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13872. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13873. #endregion
  13874. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13875. #region 页面操作权限验证
  13876. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13877. if (_dto.Id == 0) // Add
  13878. {
  13879. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13880. }
  13881. else if (_dto.Id > 1) // Edit
  13882. {
  13883. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  13884. }
  13885. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  13886. #endregion
  13887. #endregion
  13888. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  13889. if (_view.Code != 200)
  13890. {
  13891. return Ok(_view);
  13892. }
  13893. #region 成本无酒店价格数据进入超支
  13894. _sqlSugar.BeginTran();
  13895. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  13896. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  13897. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  13898. for (int i = 0; i < groupCost.Count; i++)
  13899. {
  13900. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  13901. {
  13902. groupCost[i].Date = groupCost[i - 1].Date;
  13903. }
  13904. }
  13905. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  13906. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  13907. List<Fin_GroupExtraCostDto_OP>();
  13908. if (start_Bool && end_Bool)
  13909. {
  13910. while (start_Time < end_Time)
  13911. {
  13912. foreach (var item in groupCost_Grp)
  13913. {
  13914. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  13915. {
  13916. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  13917. {
  13918. extraCostList.Add(new
  13919. Fin_GroupExtraCostDto_OP
  13920. {
  13921. Area = _dto.AreaId,
  13922. coefficient = 1.5M,
  13923. createUser = _dto.UserId,
  13924. currency = _dto.CardPriceCurrency,
  13925. diId = _dto.DiId,
  13926. ManagerConfirm = 0,
  13927. SupervisorConfirm = 0,
  13928. SYsupervisorConfirm = 0,
  13929. editType = 1,
  13930. PortType = 1,
  13931. price = _dto.CardPrice,
  13932. PriceCount = 1,
  13933. priceType = 1027,
  13934. priceDetailType = 1044,
  13935. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  13936. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  13937. });
  13938. }
  13939. }
  13940. }
  13941. start_Time = start_Time.AddDays(1);
  13942. }
  13943. }
  13944. if (extraCostList.Any())
  13945. {
  13946. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  13947. }
  13948. _sqlSugar.CommitTran();
  13949. #endregion
  13950. #region 应用推送
  13951. try
  13952. {
  13953. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  13954. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  13955. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  13956. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  13957. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  13958. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  13959. var diId = _dto.DiId;
  13960. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13961. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13962. #region 操作记录
  13963. var opInfo = new Crm_TableOperationRecord()
  13964. {
  13965. TableName = "Grp_HotelReservations",
  13966. PortType = _dto.PortType,
  13967. DataId = hotelId,
  13968. CreateUserId = _dto.UserId
  13969. };
  13970. //var opStatus = OperationEnum.NoOperation;
  13971. if (_dto.Id < 1) //添加操作
  13972. {
  13973. opInfo.OperationItem = OperationEnum.Add;
  13974. }
  13975. else if (_dto.Id > 0)
  13976. {
  13977. opInfo.OperationItem = OperationEnum.Edit;
  13978. }
  13979. string opRemark = string.Empty;
  13980. if (ccpInfo != null)
  13981. {
  13982. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  13983. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  13984. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  13985. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  13986. }
  13987. opInfo.Remark = opRemark;
  13988. await _tableorRep.AddAsync(opInfo);
  13989. #endregion
  13990. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  13991. //2024-10-21 新增LZ UID
  13992. var userIds = new List<int>() { 21 };
  13993. string title = $"费用审核";
  13994. string content = "";
  13995. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13996. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13997. try
  13998. {
  13999. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  14000. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  14001. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  14002. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  14003. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  14004. }
  14005. catch (Exception ex)
  14006. {
  14007. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  14008. }
  14009. }
  14010. catch (Exception ex)
  14011. {
  14012. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  14013. }
  14014. try
  14015. {
  14016. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14017. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14018. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14019. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14020. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14021. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14022. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14023. //自动审核
  14024. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  14025. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  14026. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  14027. //2024-10-21 新增LZ UID
  14028. var userIds = new List<int>() { 21 };
  14029. string title = $"系统通知";
  14030. var diId = _dto.DiId;
  14031. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14032. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14033. string content = "";
  14034. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14035. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14036. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14037. }
  14038. catch (Exception ex)
  14039. {
  14040. }
  14041. #endregion
  14042. return Ok(_view);
  14043. }
  14044. /// <summary>
  14045. /// 酒店自动审核测试
  14046. /// Add Or Edit
  14047. /// </summary>
  14048. /// <param name="diid"></param>
  14049. /// <param name="dataId"></param>
  14050. /// <returns></returns>
  14051. [HttpPost]
  14052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14053. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  14054. {
  14055. #region 应用推送
  14056. try
  14057. {
  14058. //自动审核
  14059. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  14060. }
  14061. catch (Exception ex)
  14062. {
  14063. return Ok(JsonView(false, "操作失败"));
  14064. }
  14065. #endregion
  14066. return Ok(JsonView(false, "操作成功"));
  14067. }
  14068. /// <summary>
  14069. /// 酒店预订
  14070. /// Del
  14071. /// </summary>
  14072. /// <param name="_dto"></param>
  14073. /// <returns></returns>
  14074. [HttpPost]
  14075. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14076. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  14077. {
  14078. #region 参数验证
  14079. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14080. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14081. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14082. #region 团组操作权限验证 76 酒店预定模块
  14083. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14084. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14085. #endregion
  14086. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14087. #region 页面操作权限验证
  14088. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14089. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14090. #endregion
  14091. #endregion
  14092. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  14093. #region 操作记录
  14094. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  14095. {
  14096. TableName = "Grp_HotelReservations",
  14097. PortType = _dto.PortType,
  14098. OperationItem = OperationEnum.Del,
  14099. DataId = _dto.Id,
  14100. CreateUserId = _dto.UserId
  14101. });
  14102. #endregion
  14103. return Ok(data);
  14104. }
  14105. /// <summary>
  14106. /// 酒店预订
  14107. /// 生成VOUCHER
  14108. /// 2024.05.06 之前版本
  14109. /// </summary>
  14110. /// <param name="_dto"></param>
  14111. /// <returns></returns>
  14112. [HttpPost]
  14113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14114. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  14115. {
  14116. try
  14117. {
  14118. #region 参数验证
  14119. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14120. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14121. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14122. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  14123. #region 团组操作权限验证 76 酒店预定模块
  14124. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14125. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14126. #endregion
  14127. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14128. #region 页面操作权限验证
  14129. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14130. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14131. #endregion
  14132. #endregion
  14133. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  14134. //判断数据是否完整
  14135. if (hr != null)
  14136. {
  14137. if (!string.IsNullOrEmpty(hr.DetermineNo))
  14138. {
  14139. string strFileName = "HotelStatement/";
  14140. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14141. if (dele != null)
  14142. strFileName += dele.TourCode;
  14143. //载入模板
  14144. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  14145. Document doc = new Document(sss);
  14146. DocumentBuilder builder = new DocumentBuilder(doc);
  14147. #region 替换Word模板书签内容
  14148. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  14149. //入住卷预定号码
  14150. if (doc.Range.Bookmarks["VNO"] != null)
  14151. {
  14152. Bookmark mark = doc.Range.Bookmarks["VNO"];
  14153. mark.Text = hr.CheckNumber;
  14154. }
  14155. //酒店时间
  14156. if (doc.Range.Bookmarks["Date"] != null)
  14157. {
  14158. Bookmark mark = doc.Range.Bookmarks["Date"];
  14159. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14160. }
  14161. //团号
  14162. if (doc.Range.Bookmarks["TNo"] != null)
  14163. {
  14164. Bookmark mark = doc.Range.Bookmarks["TNo"];
  14165. mark.Text = dele.TourCode;
  14166. }
  14167. //预定号码
  14168. if (doc.Range.Bookmarks["BookingId"] != null)
  14169. {
  14170. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  14171. mark.Text = hr.ReservationsNo;
  14172. }
  14173. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  14174. {
  14175. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  14176. mark.Text = hr.DetermineNo;
  14177. }
  14178. //酒店城市
  14179. if (doc.Range.Bookmarks["City"] != null)
  14180. {
  14181. Bookmark mark = doc.Range.Bookmarks["City"];
  14182. mark.Text = hr.City;
  14183. }
  14184. //酒店名称
  14185. if (doc.Range.Bookmarks["HName"] != null)
  14186. {
  14187. Bookmark mark = doc.Range.Bookmarks["HName"];
  14188. mark.Text = hr.HotelName;
  14189. }
  14190. //酒店地址
  14191. if (doc.Range.Bookmarks["Address"] != null)
  14192. {
  14193. Bookmark mark = doc.Range.Bookmarks["Address"];
  14194. mark.Text = hr.HotelAddress;
  14195. }
  14196. //酒店电话
  14197. if (doc.Range.Bookmarks["Tel"] != null)
  14198. {
  14199. Bookmark mark = doc.Range.Bookmarks["Tel"];
  14200. mark.Text = hr.HotelTel;
  14201. }
  14202. //酒店传真
  14203. if (doc.Range.Bookmarks["Fax"] != null)
  14204. {
  14205. Bookmark mark = doc.Range.Bookmarks["Fax"];
  14206. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  14207. {
  14208. mark.Text = hr.HotelFax;
  14209. }
  14210. }
  14211. //入住时间
  14212. if (doc.Range.Bookmarks["CIn"] != null)
  14213. {
  14214. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14215. Bookmark mark = doc.Range.Bookmarks["CIn"];
  14216. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  14217. }
  14218. //退房时间
  14219. if (doc.Range.Bookmarks["COut"] != null)
  14220. {
  14221. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14222. Bookmark mark = doc.Range.Bookmarks["COut"];
  14223. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14224. }
  14225. //客户名称
  14226. if (doc.Range.Bookmarks["GName"] != null)
  14227. {
  14228. string guestName = "";
  14229. string[] clients = new string[] { };
  14230. if (hr.GuestName.Contains(","))
  14231. {
  14232. clients = hr.GuestName.Split(",");
  14233. }
  14234. else
  14235. {
  14236. clients = new string[] { hr.GuestName };
  14237. }
  14238. List<int> clientIds_int = new List<int>();
  14239. if (clients.Length > 0)
  14240. {
  14241. foreach (var item in clients)
  14242. {
  14243. if (item.IsNumeric())
  14244. {
  14245. clientIds_int.Add(int.Parse(item));
  14246. }
  14247. }
  14248. }
  14249. if (clientIds_int.Count > 0)
  14250. {
  14251. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  14252. foreach (var client in _clientDatas)
  14253. {
  14254. //男
  14255. if (client.Sex == 0) guestName += $"Mr.";
  14256. //女
  14257. else if (client.Sex == 1) guestName += $"Ms.";
  14258. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  14259. {
  14260. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  14261. }
  14262. //guestName += $"{client.Pinyin},";
  14263. }
  14264. if (guestName.Length > 0)
  14265. {
  14266. guestName = guestName.Substring(0, guestName.Length - 1);
  14267. }
  14268. }
  14269. else
  14270. {
  14271. guestName = hr.GuestName;
  14272. }
  14273. Bookmark mark = doc.Range.Bookmarks["GName"];
  14274. mark.Text = guestName;
  14275. }
  14276. //房间介绍
  14277. if (doc.Range.Bookmarks["ROOM"] != null)
  14278. {
  14279. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  14280. mark.Text = hr.RoomExplanation;
  14281. }
  14282. //报价描述
  14283. if (doc.Range.Bookmarks["NOTE"] != null)
  14284. {
  14285. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  14286. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  14287. if (ss != null)
  14288. mark.Text = ss.Name;
  14289. }
  14290. //入住时间
  14291. if (doc.Range.Bookmarks["CheckIn"] != null)
  14292. {
  14293. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14294. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  14295. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14296. }
  14297. //退房时间
  14298. if (doc.Range.Bookmarks["CheckOut"] != null)
  14299. {
  14300. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14301. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  14302. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14303. }
  14304. //日期
  14305. if (doc.Range.Bookmarks["DT"] != null)
  14306. {
  14307. Bookmark mark = doc.Range.Bookmarks["DT"];
  14308. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14309. }
  14310. //名称
  14311. if (doc.Range.Bookmarks["VName"] != null)
  14312. {
  14313. Bookmark mark = doc.Range.Bookmarks["VName"];
  14314. mark.Text = hr.HotelName;
  14315. }
  14316. //号码
  14317. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  14318. {
  14319. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  14320. mark.Text = hr.CheckNumber;
  14321. }
  14322. #endregion
  14323. strFileName += "VOUCHER.doc";
  14324. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14325. doc.Save(fileDir);
  14326. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14327. return Ok(JsonView(true, "操作成功!", Url));
  14328. }
  14329. else
  14330. {
  14331. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  14332. }
  14333. }
  14334. else
  14335. {
  14336. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  14337. }
  14338. }
  14339. catch (Exception ex)
  14340. {
  14341. return Ok(JsonView(false, ex.Message));
  14342. }
  14343. }
  14344. /// <summary>
  14345. /// 酒店预订
  14346. /// 生成VOUCHER
  14347. /// 2024.05.06 之后版本
  14348. /// </summary>
  14349. /// <param name="_dto"></param>
  14350. /// <returns></returns>
  14351. [HttpPost]
  14352. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14353. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  14354. {
  14355. #region 参数验证
  14356. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14357. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14358. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14359. #region 团组操作权限验证 76 酒店预定模块
  14360. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14361. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14362. #endregion
  14363. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14364. #region 页面操作权限验证
  14365. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14366. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14367. #endregion
  14368. #endregion
  14369. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  14370. //判断数据是否完整
  14371. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14372. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14373. string strFileName = "HotelStatement/";
  14374. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14375. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  14376. #region 数据处理
  14377. List<int> guestIds = new List<int>();
  14378. //int index = 0;
  14379. foreach (var item in hrDtas)
  14380. {
  14381. if (item.GuestName.Contains(","))
  14382. {
  14383. string[] guestIdArr = item.GuestName.Split(',');
  14384. foreach (var guestIdStr in guestIdArr)
  14385. {
  14386. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  14387. if (guestBool)
  14388. {
  14389. guestIds.Add(guestId);
  14390. }
  14391. }
  14392. }
  14393. else guestNames += item.GuestName;
  14394. var voucherInfo = new HotelVoucherInfoView()
  14395. {
  14396. HotelName = item.HotelName,
  14397. CheckInDate = item.CheckInDate,
  14398. CheckOutDate = item.CheckOutDate,
  14399. ConfirmationNumber = item.DetermineNo.Trim(),
  14400. RoomType = item.RoomExplanation
  14401. };
  14402. vouchers.Add(voucherInfo);
  14403. }
  14404. if (guestIds.Count > 0)
  14405. {
  14406. guestIds = guestIds.Distinct().ToList();
  14407. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  14408. if (guestDatas.Count > 0)
  14409. {
  14410. guestNames = "";
  14411. foreach (var guest in guestDatas)
  14412. {
  14413. string guestName = "";
  14414. if (guest.Sex == 0) guestName += @"MR.";
  14415. else if (guest.Sex == 1) guestName += @"MS.";
  14416. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14417. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14418. guestNames += @$"{guestName.Trim()}、";
  14419. }
  14420. if (guestNames.Length > 0)
  14421. {
  14422. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14423. }
  14424. }
  14425. }
  14426. #endregion
  14427. //载入模板
  14428. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  14429. Document doc = new Document(sss);
  14430. DocumentBuilder builder = new DocumentBuilder(doc);
  14431. if (doc.Range.Bookmarks["GuestName"] != null)
  14432. {
  14433. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  14434. mark.Text = guestNames;
  14435. }
  14436. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14437. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  14438. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  14439. for (int i = 1; i <= vouchers.Count; i++)
  14440. {
  14441. HotelVoucherInfoView hviv = vouchers[i - 1];
  14442. builder.MoveToCell(0, i, 0, 0);
  14443. builder.Write(hviv.HotelName);
  14444. builder.MoveToCell(0, i, 1, 0);
  14445. builder.Write(hviv.CheckInDate);
  14446. builder.MoveToCell(0, i, 2, 0);
  14447. builder.Write(hviv.CheckOutDate);
  14448. builder.MoveToCell(0, i, 3, 0);
  14449. builder.Write(hviv.RoomType);
  14450. builder.MoveToCell(0, i, 4, 0);
  14451. builder.Write(hviv.ConfirmationNumber);
  14452. }
  14453. //删除多余行
  14454. int currRowIndex = vouchers.Count + 1;
  14455. int delRows = 21 - currRowIndex;
  14456. if (delRows > 0)
  14457. {
  14458. for (int i = 0; i < delRows; i++)
  14459. {
  14460. table.Rows.RemoveAt(currRowIndex);
  14461. //cultivateRowIndex++;
  14462. }
  14463. }
  14464. strFileName += "VOUCHER.docx";
  14465. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14466. doc.Save(fileDir);
  14467. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14468. return Ok(JsonView(true, "操作成功!", Url));
  14469. }
  14470. /// <summary>
  14471. /// 酒店预订
  14472. /// 生成VOUCHER 批量生成
  14473. /// New
  14474. /// </summary>
  14475. /// <param name="_dto"></param>
  14476. /// <returns></returns>
  14477. [HttpPost]
  14478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14479. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  14480. {
  14481. #region 参数验证
  14482. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14483. if (_dto.PageId < 1) _dto.PageId = 28;
  14484. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14485. #region 团组操作权限验证 76 酒店预定模块
  14486. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14487. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14488. #endregion
  14489. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14490. #region 页面操作权限验证
  14491. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14492. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14493. #endregion
  14494. #endregion
  14495. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  14496. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  14497. .OrderBy(x => x.CheckInDate)
  14498. .ToListAsync();
  14499. //判断数据是否完整
  14500. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14501. string strFileName = "HotelStatement/";
  14502. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14503. if (dele != null)
  14504. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  14505. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  14506. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  14507. .Where(it => it.IsDel == 0)
  14508. .ToListAsync();
  14509. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  14510. for (int i = 0; i < hrDtas.Count; i++)
  14511. {
  14512. string guestNames = string.Empty;
  14513. List<int> guestIds = new List<int>();
  14514. var item = hrDtas[i];
  14515. //处理客户姓名
  14516. if (item.GuestName.Contains(","))
  14517. {
  14518. string[] guestIdArr = item.GuestName.Split(',');
  14519. foreach (var guestIdStr in guestIdArr)
  14520. if (int.TryParse(guestIdStr, out int guestId))
  14521. guestIds.Add(guestId);
  14522. }
  14523. else
  14524. {
  14525. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  14526. if (guestIdBool)
  14527. {
  14528. guestIds.Add(guestId);
  14529. }
  14530. //NaN
  14531. if (item.GuestName.Contains("NaN"))
  14532. {
  14533. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  14534. }
  14535. }
  14536. if (guestIds.Count > 0)
  14537. {
  14538. guestIds = guestIds.Distinct().ToList();
  14539. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  14540. if (guestDatas1.Count > 0)
  14541. {
  14542. guestNames = "";
  14543. foreach (var guest in guestDatas1)
  14544. {
  14545. string guestName = "";
  14546. if (guest.Sex == 0) guestName += @"MR.";
  14547. else if (guest.Sex == 1) guestName += @"MS.";
  14548. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14549. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14550. guestNames += @$"{guestName.Trim()}、";
  14551. }
  14552. if (guestNames.Length > 0)
  14553. {
  14554. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14555. }
  14556. }
  14557. }
  14558. //if (!string.IsNullOrEmpty(guestNames))
  14559. //{
  14560. hrDtas[i].GuestName = guestNames;
  14561. //}
  14562. }
  14563. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  14564. Document doc = new Document();
  14565. DocumentBuilder builder = new DocumentBuilder(doc);
  14566. try
  14567. {
  14568. builder.MoveToDocumentStart();
  14569. foreach (var item in hrDtas)
  14570. {
  14571. //标题
  14572. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14573. builder.ParagraphFormat.LineSpacing = 1;
  14574. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14575. builder.ParagraphFormat.Style.Font.Size = 9;
  14576. builder.ParagraphFormat.Style.Font.Bold = true;
  14577. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14578. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  14579. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14580. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14581. builder.ParagraphFormat.LineSpacing = 1;
  14582. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14583. builder.ParagraphFormat.Style.Font.Size = 9;
  14584. builder.ParagraphFormat.Style.Font.Bold = true;
  14585. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  14586. builder.StartTable();
  14587. // 设置边框颜色
  14588. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  14589. //设置边框样式
  14590. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  14591. //表格
  14592. #region 第一行
  14593. builder.InsertCell();
  14594. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14595. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14596. //builder.CellFormat.AllowAutoFit = false;
  14597. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14598. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14599. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14600. builder.CellFormat.WrapText = true; //自动换行
  14601. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14602. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  14603. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14604. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14605. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14606. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14607. builder.Write("TOUR NO:");
  14608. builder.InsertCell();
  14609. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14610. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14611. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14612. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14613. builder.ParagraphFormat.Style.Font.Bold = false;
  14614. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14615. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14616. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14617. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14618. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14619. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14620. builder.Write($"{dele?.TourCode ?? "-"}");
  14621. builder.InsertCell();
  14622. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14623. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14624. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14625. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14626. builder.ParagraphFormat.Style.Font.Bold = false;
  14627. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14628. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14629. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14630. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14631. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14632. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14633. builder.Write($"CITY:");
  14634. builder.InsertCell();
  14635. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14636. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14637. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14638. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14639. builder.ParagraphFormat.Style.Font.Bold = false;
  14640. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14641. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14642. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14643. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14644. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14645. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14646. builder.Write($"{item.City}");
  14647. builder.EndRow();
  14648. #endregion
  14649. #region 第二行
  14650. builder.InsertCell();
  14651. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14652. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14653. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14654. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14655. builder.ParagraphFormat.Style.Font.Bold = false;
  14656. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14657. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14658. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14659. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14660. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14661. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14662. builder.Write("CONFIRMATION NO:");
  14663. builder.InsertCell();
  14664. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14665. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14666. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14667. builder.ParagraphFormat.Style.Font.Bold = false;
  14668. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14669. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14670. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14671. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14672. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14673. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14674. builder.CellFormat.VerticalMerge = CellMerge.None;
  14675. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14676. builder.Write($"{item.DetermineNo}");
  14677. builder.InsertCell();
  14678. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14679. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14680. builder.InsertCell();
  14681. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14682. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14683. builder.EndRow();
  14684. #endregion
  14685. #region 第三行
  14686. builder.InsertCell();
  14687. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14688. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14689. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14690. builder.ParagraphFormat.Style.Font.Bold = false;
  14691. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14692. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14693. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14694. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14695. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14696. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14697. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14698. builder.Write($"HOTEL NAME:");
  14699. builder.InsertCell();
  14700. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14701. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14702. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14703. builder.ParagraphFormat.Style.Font.Bold = false;
  14704. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14705. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14706. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14707. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14708. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14709. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14710. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14711. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14712. builder.Write($"{item.HotelName}");
  14713. builder.InsertCell();
  14714. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14715. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14716. builder.InsertCell();
  14717. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14718. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14719. builder.EndRow();
  14720. #endregion
  14721. #region 第四行
  14722. builder.InsertCell();
  14723. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14724. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14725. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14726. builder.ParagraphFormat.Style.Font.Bold = false;
  14727. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14728. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14729. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14730. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14731. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14732. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14733. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14734. builder.Write($"HOTEL ADDRESS:");
  14735. builder.InsertCell();
  14736. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14737. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14738. builder.ParagraphFormat.Style.Font.Size = 8;
  14739. builder.ParagraphFormat.Style.Font.Bold = false;
  14740. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14741. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14742. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14743. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14744. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14745. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14746. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14747. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14748. builder.Write($"{item.HotelAddress}");
  14749. builder.InsertCell();
  14750. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14751. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14752. builder.InsertCell();
  14753. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14754. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14755. builder.EndRow();
  14756. #endregion
  14757. #region 第五行
  14758. builder.InsertCell();
  14759. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14760. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14761. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14762. builder.ParagraphFormat.Style.Font.Bold = false;
  14763. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14764. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14765. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14766. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14767. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14768. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14769. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14770. builder.Write("TEL:");
  14771. builder.InsertCell();
  14772. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14773. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14774. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14775. builder.ParagraphFormat.Style.Font.Bold = false;
  14776. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14777. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14778. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14779. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14780. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14781. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14782. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14783. builder.Write($"{item.HotelTel}");
  14784. builder.InsertCell();
  14785. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14786. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14787. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14788. builder.ParagraphFormat.Style.Font.Bold = false;
  14789. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14790. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14791. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14792. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14793. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14794. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14795. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14796. builder.Write($"FAX:");
  14797. builder.InsertCell();
  14798. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14799. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14800. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14801. builder.ParagraphFormat.Style.Font.Bold = false;
  14802. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14803. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14804. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14805. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14806. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14807. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14808. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14809. builder.Write($"{item.HotelFax}");
  14810. builder.EndRow();
  14811. #endregion
  14812. #region 第六行
  14813. builder.InsertCell();
  14814. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14815. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14816. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14817. builder.ParagraphFormat.Style.Font.Bold = false;
  14818. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14819. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14820. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14821. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14822. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14823. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14824. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14825. builder.Write("CHECK IN:");
  14826. builder.InsertCell();
  14827. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14828. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14829. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14830. builder.ParagraphFormat.Style.Font.Bold = false;
  14831. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14832. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14833. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14834. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14835. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14836. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14837. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14838. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  14839. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14840. builder.Write($"{checkInStr}");
  14841. builder.InsertCell();
  14842. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14843. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14844. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14845. builder.ParagraphFormat.Style.Font.Bold = false;
  14846. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14847. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14848. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14849. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14850. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14851. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14852. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14853. builder.Write($"CHECK OUT:");
  14854. builder.InsertCell();
  14855. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14856. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14857. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14858. builder.ParagraphFormat.Style.Font.Bold = false;
  14859. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14860. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14861. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14862. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14863. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14864. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14865. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14866. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  14867. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  14868. builder.Write($"{checkOutStr}");
  14869. builder.EndRow();
  14870. #endregion
  14871. #region 第七行
  14872. builder.InsertCell();
  14873. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14874. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14875. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14876. builder.ParagraphFormat.Style.Font.Bold = false;
  14877. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14878. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14879. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14880. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14881. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14882. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14883. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14884. builder.Write($"GUEST NAME:");
  14885. builder.InsertCell();
  14886. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14887. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14888. builder.ParagraphFormat.Style.Font.Size = 8;
  14889. builder.ParagraphFormat.Style.Font.Bold = false;
  14890. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14891. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14892. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14893. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14894. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14895. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14896. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14897. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14898. builder.Write($"{item.GuestName}");
  14899. builder.InsertCell();
  14900. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14901. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14902. builder.InsertCell();
  14903. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14904. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14905. builder.EndRow();
  14906. #endregion
  14907. #region 第八行
  14908. builder.InsertCell();
  14909. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14910. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14911. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14912. builder.ParagraphFormat.Style.Font.Bold = false;
  14913. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14914. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14915. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14916. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14917. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14918. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14919. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14920. builder.Write($"ROOM TYPE:");
  14921. builder.InsertCell();
  14922. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14923. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14924. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14925. builder.ParagraphFormat.Style.Font.Bold = false;
  14926. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14927. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14928. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14929. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14930. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14931. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14932. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14933. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14934. builder.Write($"{item.RoomExplanation}");
  14935. builder.InsertCell();
  14936. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14937. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14938. builder.InsertCell();
  14939. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14940. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14941. builder.EndRow();
  14942. #endregion
  14943. #region 第九行
  14944. builder.InsertCell();
  14945. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14946. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14947. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14948. builder.ParagraphFormat.Style.Font.Bold = false;
  14949. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14950. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14951. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14952. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14953. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14954. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14955. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14956. builder.Write($"NOTE:");
  14957. builder.InsertCell();
  14958. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14959. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14960. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14961. builder.ParagraphFormat.Style.Font.Bold = false;
  14962. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14963. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14964. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14965. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14966. 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.");
  14967. builder.InsertCell();
  14968. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14969. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14970. builder.InsertCell();
  14971. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14972. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14973. builder.EndRow();
  14974. #endregion
  14975. builder.EndTable();
  14976. //换行
  14977. builder.Writeln("");
  14978. builder.Writeln("");
  14979. }
  14980. #region 获取文档中的所有表格 设置文字自适应
  14981. // 获取文档中的所有表格。
  14982. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14983. {
  14984. // 遍历表格中的所有行。
  14985. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14986. {
  14987. foreach (Cell cell in row.Cells)
  14988. {
  14989. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  14990. cellFormat.Width = 0;
  14991. }
  14992. }
  14993. }
  14994. #endregion
  14995. #region 设置页眉
  14996. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  14997. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  14998. if (System.IO.File.Exists(voucherHeaderPath))
  14999. {
  15000. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  15001. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  15002. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  15003. Shape shape = builder.InsertImage(imageBytes);
  15004. // 调整图片位置
  15005. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  15006. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  15007. shape.Top = 50; // 将图片距离页眉上边缘的距离
  15008. shape.Left = 0; // 将图片距离页面左边缘的距离
  15009. shape.Width = 81; // 设置图片宽度
  15010. shape.Height = 36; // 设置图片高度
  15011. }
  15012. //靠右
  15013. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  15014. //// 设置页脚上下边距
  15015. //builder.PageSetup.HeaderDistance = 42;
  15016. // 添加页眉线
  15017. Aspose.Words.Border borderHeader = null;
  15018. try
  15019. {
  15020. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  15021. }
  15022. catch (Exception e)
  15023. {
  15024. // TODO Auto-generated catch block
  15025. //e.printStackTrace();
  15026. }
  15027. borderHeader.Shadow = true;
  15028. borderHeader.DistanceFromText = 2;
  15029. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  15030. #endregion
  15031. }
  15032. catch (Exception ex)
  15033. {
  15034. }
  15035. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15036. doc.Save(fileDir);
  15037. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15038. return Ok(JsonView(true, "操作成功!", Url));
  15039. }
  15040. /// <summary>
  15041. /// 酒店预订
  15042. /// 生成 预定成本 Excel
  15043. /// </summary>
  15044. /// <param name="_dto"></param>
  15045. /// <returns></returns>
  15046. [HttpPost]
  15047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15048. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  15049. {
  15050. #region 参数验证
  15051. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  15052. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  15053. if (!vadalitorRes.IsValid)
  15054. {
  15055. var errors = new StringBuilder();
  15056. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  15057. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  15058. }
  15059. #region 团组操作权限验证 76 酒店预定模块
  15060. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15061. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15062. #endregion
  15063. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15064. #region 页面操作权限验证
  15065. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15066. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15067. #endregion
  15068. #endregion
  15069. decimal _rate = 1.00M;
  15070. string _currency = string.Empty;
  15071. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  15072. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15073. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  15074. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15075. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  15076. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  15077. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  15078. if (_GroupCostParameter == null)
  15079. {
  15080. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  15081. bool isIntType = int.TryParse(_currency, out int currId);
  15082. if (isIntType)
  15083. {
  15084. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15085. }
  15086. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15087. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15088. if (currInfo == null)
  15089. {
  15090. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15091. }
  15092. else _rate = currInfo.Rate;
  15093. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  15094. {
  15095. _rate = _GroupCostParameter.Rate;
  15096. }
  15097. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15098. //string strFileName = "HotelStatement/";
  15099. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15100. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15101. var rateDatas = new List<dynamic>();
  15102. #region 数据处理
  15103. foreach (var item in hrDtas)
  15104. {
  15105. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15106. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15107. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15108. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15109. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15110. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  15111. {
  15112. continue;
  15113. }
  15114. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15115. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  15116. string singleRoomFeeStr = string.Empty,
  15117. doubleRoomFeeStr = string.Empty,
  15118. suiteRoomFeeStr = string.Empty,
  15119. otherRoomFeeStr = string.Empty,
  15120. payMoneyStr = string.Empty,
  15121. cardPriceStr = string.Empty;
  15122. if (roomCurr.Equals("CNY"))
  15123. {
  15124. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  15125. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15126. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15127. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15128. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15129. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  15130. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  15131. }
  15132. else
  15133. {
  15134. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15135. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15136. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15137. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15138. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15139. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15140. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15141. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15142. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15143. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15144. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  15145. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  15146. if (ccpPaymentCurrency.Equals("CNY"))
  15147. {
  15148. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  15149. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15150. }
  15151. else
  15152. {
  15153. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  15154. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  15155. }
  15156. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  15157. if (hotelcardPriceCurrency.Equals("CNY"))
  15158. {
  15159. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15160. }
  15161. else
  15162. {
  15163. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  15164. }
  15165. }
  15166. string breakfastPriceStr = string.Empty,
  15167. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15168. governmentRentStr = string.Empty,
  15169. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15170. cityTaxStr = string.Empty,
  15171. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15172. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  15173. if (!string.IsNullOrEmpty(breakfastCurrency1))
  15174. {
  15175. if (breakfastCurrency1.Equals("CNY"))
  15176. {
  15177. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15178. }
  15179. else
  15180. {
  15181. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  15182. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  15183. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  15184. }
  15185. }
  15186. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15187. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  15188. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  15189. {
  15190. if (governmentRentCurrency.Equals("CNY"))
  15191. {
  15192. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15193. }
  15194. else
  15195. {
  15196. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  15197. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  15198. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  15199. }
  15200. }
  15201. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15202. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  15203. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  15204. {
  15205. if (cityTaxStrCurrency1.Equals("CNY"))
  15206. {
  15207. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15208. }
  15209. else
  15210. {
  15211. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  15212. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  15213. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  15214. }
  15215. }
  15216. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15217. int payDId = roomInfo?.PayDId ?? 0;
  15218. pcfds.Add(new HotelReservations_PCFD_View()
  15219. {
  15220. City = item.City,
  15221. HotelName = item.HotelName,
  15222. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15223. // SingleRoomCount = item.SingleRoomCount,
  15224. SingleRoomPrice = singleRoomFeeStr,
  15225. // DoubleRoomCount = item.DoubleRoomCount,
  15226. DoubleRoomPrice = doubleRoomFeeStr,
  15227. //SuiteRoomCount = item.SuiteRoomCount,
  15228. SuiteRoomPrice = suiteRoomFeeStr,
  15229. OtherRoomPrice = otherRoomFeeStr,
  15230. //OtherRoomCount = item.OtherRoomCount,
  15231. BreakfastPrice = breakfastPriceStr,
  15232. GovernmentRent = governmentRentStr,
  15233. CityTax = cityTaxStr,
  15234. RoomExplanation = item.RoomExplanation,
  15235. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15236. PayTime = roomInfo?.ConsumptionDate,
  15237. BankNo = roomInfo?.BankNo,
  15238. PayMoney = payMoneyStr,
  15239. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15240. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15241. CardPrice = cardPriceStr,
  15242. Remark = ccpInfo.Remark
  15243. });
  15244. }
  15245. #endregion
  15246. //载入模板
  15247. WorkbookDesigner designer = new WorkbookDesigner();
  15248. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15249. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15250. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15251. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15252. var rateDatas1 = rateDatas.Distinct();
  15253. var rateStr = string.Empty;
  15254. foreach (var item in rateDatas1)
  15255. {
  15256. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  15257. }
  15258. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  15259. designer.SetDataSource("Opertor", userInfo.CnName);
  15260. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15261. dt.TableName = "ViewMyHotelReservations";
  15262. designer.SetDataSource(dt);
  15263. designer.Process();
  15264. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15265. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15266. designer.Workbook.Save(serverPath);
  15267. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15268. #region 删除指定行
  15269. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15270. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15271. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15272. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15273. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15274. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15275. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15276. cssIndex = dt.Columns["CityTax"].Ordinal,
  15277. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15278. remarkIndex = dt.Columns["Remark"].Ordinal;
  15279. //删除指定列
  15280. foreach (DataRow item in dt.Rows)
  15281. {
  15282. string singleStr = item["SingleRoomPrice"].ToString();
  15283. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15284. if (containsDigitButNotZero1) singleDel = false;
  15285. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15286. string doubleStr = item["DoubleRoomPrice"].ToString();
  15287. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15288. if (containsDigitButNotZero2) doubleDel = false;
  15289. string suiteStr = item["SuiteRoomPrice"].ToString();
  15290. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15291. if (containsDigitButNotZero3) suiteDel = false;
  15292. string otherStr = item["OtherRoomPrice"].ToString();
  15293. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15294. if (containsDigitButNotZero4) otherDel = false;
  15295. string zcStr = item["BreakfastPrice"].ToString();
  15296. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15297. if (containsDigitButNotZero5) zcDel = false;
  15298. string dsStr = item["GovernmentRent"].ToString();
  15299. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15300. if (containsDigitButNotZero6) dsDel = false;
  15301. string cssStr = item["CityTax"].ToString();
  15302. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15303. if (containsDigitButNotZero7) cssDel = false;
  15304. string cpStr = item["ConsumptionPatterns"].ToString();
  15305. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15306. string remarkStr = item["Remark"].ToString();
  15307. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15308. }
  15309. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15310. DeleteColumn(serverPath, cpIndex, cpDel);
  15311. DeleteColumn(serverPath, dsIndex, dsDel);
  15312. DeleteColumn(serverPath, cssIndex, cssDel);
  15313. DeleteColumn(serverPath, zcIndex, zcDel);
  15314. DeleteColumn(serverPath, otherIndex, otherDel);
  15315. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15316. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15317. DeleteColumn(serverPath, singleIndex, singleDel);
  15318. #endregion
  15319. //只保留第一个表格
  15320. DeleteSheet(serverPath);
  15321. return Ok(JsonView(true, "操作成功", url = rst));
  15322. }
  15323. else
  15324. {
  15325. _currency = _GroupCostParameter.Currency;
  15326. bool isIntType = int.TryParse(_currency, out int currId);
  15327. if (isIntType)
  15328. {
  15329. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15330. }
  15331. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15332. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15333. if (currInfo == null)
  15334. {
  15335. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15336. }
  15337. if (!_currency.ToUpper().Equals("CNY"))
  15338. {
  15339. _rate = _GroupCostParameter.Rate;
  15340. }
  15341. _rate = currInfo.Rate;
  15342. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15343. //string strFileName = "HotelStatement/";
  15344. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15345. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15346. #region 数据处理
  15347. foreach (var item in hrDtas)
  15348. {
  15349. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15350. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15351. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15352. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15353. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15354. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15355. string singleRoomFeeStr = string.Empty,
  15356. doubleRoomFeeStr = string.Empty,
  15357. suiteRoomFeeStr = string.Empty,
  15358. otherRoomFeeStr = string.Empty,
  15359. payMoneyStr = string.Empty,
  15360. cardPriceStr = string.Empty;
  15361. if (roomCurr.Equals(_currency))
  15362. {
  15363. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  15364. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  15365. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  15366. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  15367. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  15368. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  15369. }
  15370. else
  15371. {
  15372. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15373. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15374. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15375. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15376. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15377. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15378. }
  15379. string breakfastPriceStr = string.Empty,
  15380. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15381. governmentRentStr = string.Empty,
  15382. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15383. cityTaxStrStr = string.Empty,
  15384. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15385. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  15386. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  15387. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  15388. int payDId = roomInfo?.PayDId ?? 0;
  15389. pcfds.Add(new HotelReservations_PCFD_View()
  15390. {
  15391. City = item.City,
  15392. HotelName = item.HotelName,
  15393. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15394. // SingleRoomCount = item.SingleRoomCount,
  15395. SingleRoomPrice = singleRoomFeeStr,
  15396. // DoubleRoomCount = item.DoubleRoomCount,
  15397. DoubleRoomPrice = doubleRoomFeeStr,
  15398. //SuiteRoomCount = item.SuiteRoomCount,
  15399. SuiteRoomPrice = suiteRoomFeeStr,
  15400. OtherRoomPrice = otherRoomFeeStr,
  15401. //OtherRoomCount = item.OtherRoomCount,
  15402. BreakfastPrice = breakfastPriceStr,
  15403. GovernmentRent = governmentRentStr,
  15404. CityTax = cityTaxStrStr,
  15405. RoomExplanation = item.RoomExplanation,
  15406. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15407. PayTime = roomInfo?.ConsumptionDate,
  15408. BankNo = roomInfo?.BankNo,
  15409. PayMoney = payMoneyStr,
  15410. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15411. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15412. CardPrice = cardPriceStr,
  15413. Remark = ccpInfo.Remark
  15414. });
  15415. }
  15416. #endregion
  15417. //载入模板
  15418. WorkbookDesigner designer = new WorkbookDesigner();
  15419. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15420. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15421. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15422. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15423. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  15424. designer.SetDataSource("Opertor", userInfo.CnName);
  15425. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15426. dt.TableName = "ViewMyHotelReservations";
  15427. designer.SetDataSource(dt);
  15428. designer.Process();
  15429. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15430. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15431. designer.Workbook.Save(serverPath);
  15432. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15433. #region 删除指定行
  15434. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15435. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15436. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15437. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15438. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15439. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15440. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15441. cssIndex = dt.Columns["CityTax"].Ordinal,
  15442. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15443. remarkIndex = dt.Columns["Remark"].Ordinal;
  15444. //删除指定列
  15445. foreach (DataRow item in dt.Rows)
  15446. {
  15447. string singleStr = item["SingleRoomPrice"].ToString();
  15448. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15449. if (containsDigitButNotZero1) singleDel = false;
  15450. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15451. string doubleStr = item["DoubleRoomPrice"].ToString();
  15452. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15453. if (containsDigitButNotZero2) doubleDel = false;
  15454. string suiteStr = item["SuiteRoomPrice"].ToString();
  15455. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15456. if (containsDigitButNotZero3) suiteDel = false;
  15457. string otherStr = item["OtherRoomPrice"].ToString();
  15458. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15459. if (containsDigitButNotZero4) otherDel = false;
  15460. string zcStr = item["BreakfastPrice"].ToString();
  15461. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15462. if (containsDigitButNotZero5) zcDel = false;
  15463. string dsStr = item["GovernmentRent"].ToString();
  15464. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15465. if (containsDigitButNotZero6) dsDel = false;
  15466. string cssStr = item["CityTax"].ToString();
  15467. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15468. if (containsDigitButNotZero7) cssDel = false;
  15469. string cpStr = item["ConsumptionPatterns"].ToString();
  15470. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15471. string remarkStr = item["Remark"].ToString();
  15472. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15473. }
  15474. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15475. DeleteColumn(serverPath, cpIndex, cpDel);
  15476. DeleteColumn(serverPath, dsIndex, dsDel);
  15477. DeleteColumn(serverPath, cssIndex, cssDel);
  15478. DeleteColumn(serverPath, zcIndex, zcDel);
  15479. DeleteColumn(serverPath, otherIndex, otherDel);
  15480. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15481. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15482. DeleteColumn(serverPath, singleIndex, singleDel);
  15483. #endregion
  15484. //只保留第一个表格
  15485. DeleteSheet(serverPath);
  15486. return Ok(JsonView(true, "操作成功", url = rst));
  15487. }
  15488. //return Ok(JsonView(false));
  15489. }
  15490. /// <summary>
  15491. /// 删除指定列
  15492. /// </summary>
  15493. /// <param name="file"></param>
  15494. /// <param name="columnIndex"></param>
  15495. /// <param name="isDel"></param>
  15496. private void DeleteColumn(string file, int columnIndex, bool isDel)
  15497. {
  15498. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15499. //wb.Save(file);
  15500. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  15501. if (sheet1 != null)
  15502. {
  15503. if (isDel)
  15504. {
  15505. Cells cells = sheet1.Cells;
  15506. cells.DeleteColumn(columnIndex);
  15507. }
  15508. }
  15509. wb.Save(file);
  15510. }
  15511. /// <summary>
  15512. /// 删除sheet
  15513. /// </summary>
  15514. /// <param name="file"></param>
  15515. /// <param name="sheetName"></param>
  15516. private void DeleteSheet(string file, string sheetName = "")
  15517. {
  15518. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15519. //wb.Save(file);
  15520. List<string> sheets = new List<string>();
  15521. foreach (var item in wb.Worksheets)
  15522. {
  15523. sheets.Add(item.Name);
  15524. }
  15525. if (sheets.Count > 0)
  15526. {
  15527. sheets.RemoveAt(0);//不删除第一个sheet
  15528. foreach (var item in sheets)
  15529. {
  15530. wb.Worksheets.RemoveAt(item);
  15531. }
  15532. }
  15533. wb.Save(file);
  15534. }
  15535. /// <summary>
  15536. /// 酒店预订
  15537. /// 确认单
  15538. /// </summary>
  15539. /// <param name="_dto"></param>
  15540. /// <returns></returns>
  15541. [HttpPost]
  15542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15543. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  15544. {
  15545. try
  15546. {
  15547. #region 参数验证
  15548. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15549. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15550. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15551. #region 团组操作权限验证 76 酒店预定模块
  15552. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15553. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15554. #endregion
  15555. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15556. #region 页面操作权限验证
  15557. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15558. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15559. #endregion
  15560. #endregion
  15561. //团组信息
  15562. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  15563. //酒店数据
  15564. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  15565. if (listhoteldata.Count < 0)
  15566. {
  15567. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  15568. }
  15569. //利datatable存储
  15570. DataTable dt = new DataTable();
  15571. dt.Columns.Add("CheckInDate", typeof(string));
  15572. dt.Columns.Add("City", typeof(string));
  15573. dt.Columns.Add("Hotel", typeof(string));
  15574. dt.Columns.Add("Room", typeof(string));
  15575. for (int i = 0; i < listhoteldata.Count; i++)
  15576. {
  15577. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  15578. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  15579. while (dayStart < dayEnd)
  15580. {
  15581. string temp = "";
  15582. DataRow row = dt.NewRow();
  15583. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  15584. row["City"] = listhoteldata[i].City;
  15585. row["Hotel"] = listhoteldata[i].HotelName;
  15586. if (listhoteldata[i].SingleRoomCount > 0)
  15587. {
  15588. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  15589. }
  15590. if (listhoteldata[i].DoubleRoomCount > 0)
  15591. {
  15592. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  15593. }
  15594. if (listhoteldata[i].SuiteRoomCount > 0)
  15595. {
  15596. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  15597. }
  15598. if (listhoteldata[i].OtherRoomCount > 0)
  15599. {
  15600. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  15601. }
  15602. row["Room"] = temp;
  15603. dt.Rows.Add(row);
  15604. dayStart = dayStart.AddDays(1);
  15605. }
  15606. }
  15607. Dictionary<string, string> dic = new Dictionary<string, string>();
  15608. dic.Add("Dele", di.TeamName);
  15609. dic.Add("City", di.VisitCountry);
  15610. //模板路径
  15611. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  15612. //载入模板
  15613. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  15614. DocumentBuilder builder = new DocumentBuilder(doc);
  15615. foreach (var key in dic.Keys)
  15616. {
  15617. builder.MoveToBookmark(key);
  15618. builder.Write(dic[key]);
  15619. }
  15620. //获取word里所有表格
  15621. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15622. //获取所填表格的序数
  15623. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  15624. var rowStart = tableOne.Rows[0]; //获取第1行
  15625. //循环赋值
  15626. for (int i = 0; i < dt.Rows.Count; i++)
  15627. {
  15628. builder.MoveToCell(0, i + 1, 0, 0);
  15629. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  15630. builder.MoveToCell(0, i + 1, 1, 0);
  15631. builder.Write(dt.Rows[i]["City"].ToString());
  15632. builder.MoveToCell(0, i + 1, 2, 0);
  15633. builder.Write(dt.Rows[i]["Hotel"].ToString());
  15634. builder.MoveToCell(0, i + 1, 3, 0);
  15635. builder.Write(dt.Rows[i]["Room"].ToString());
  15636. }
  15637. //删除多余行
  15638. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  15639. {
  15640. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  15641. }
  15642. string strFileName = di.TeamName + "酒店确认单.doc";
  15643. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  15644. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  15645. return Ok(JsonView(true, "成功", url));
  15646. }
  15647. catch (Exception ex)
  15648. {
  15649. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  15650. }
  15651. }
  15652. #endregion
  15653. #region 团组状态
  15654. /// <summary>
  15655. /// 团组状态列表 Page
  15656. /// </summary>
  15657. /// <param name="dto">团组列表请求dto</param>
  15658. /// <returns></returns>
  15659. [HttpPost]
  15660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15661. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  15662. {
  15663. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15664. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  15665. {
  15666. string sqlWhere = string.Empty;
  15667. if (dto.IsSure == 0) //未完成
  15668. {
  15669. sqlWhere += string.Format(@" And IsSure = 0");
  15670. }
  15671. else if (dto.IsSure == 1) //已完成
  15672. {
  15673. sqlWhere += string.Format(@" And IsSure = 1");
  15674. }
  15675. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  15676. {
  15677. string tj = dto.SearchCriteria;
  15678. 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}%')",
  15679. tj, tj, tj, tj, tj);
  15680. }
  15681. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  15682. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  15683. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  15684. From (
  15685. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  15686. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  15687. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  15688. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  15689. From Grp_DelegationInfo gdi
  15690. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  15691. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  15692. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  15693. Where gdi.IsDel = 0 {0}
  15694. ) temp ", sqlWhere);
  15695. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  15696. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  15697. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  15698. }
  15699. else
  15700. {
  15701. return Ok(JsonView(false, "查询失败"));
  15702. }
  15703. }
  15704. /// <summary>
  15705. /// 团组状态
  15706. /// 设置操作完成
  15707. /// </summary>
  15708. /// <param name="dto">团组列表请求dto</param>
  15709. /// <returns></returns>
  15710. [HttpPost]
  15711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15712. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  15713. {
  15714. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15715. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  15716. {
  15717. Id = dto.Id,
  15718. IsSure = 1
  15719. };
  15720. var result = await _sqlSugar.Updateable(_DelegationInfo)
  15721. .UpdateColumns(it => new { it.IsSure })
  15722. .WhereColumns(it => new { it.Id })
  15723. .ExecuteCommandAsync();
  15724. if (result > 0)
  15725. {
  15726. return Ok(JsonView(true, "操作完成!"));
  15727. }
  15728. return Ok(JsonView(false, "操作失败!"));
  15729. }
  15730. #endregion
  15731. #region 保险费用录入
  15732. /// <summary>
  15733. /// 根据团组Id查询保险费用列表
  15734. /// </summary>
  15735. /// <param name="dto"></param>
  15736. /// <returns></returns>
  15737. [HttpPost]
  15738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15739. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  15740. {
  15741. Result groupData = await _customersRep.CustomersByDiId(dto);
  15742. if (groupData.Code != 0)
  15743. {
  15744. return Ok(JsonView(false, groupData.Msg));
  15745. }
  15746. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15747. }
  15748. /// <summary>
  15749. /// 根据保险费用Id查询保险费用详细
  15750. /// </summary>
  15751. /// <param name="dto"></param>
  15752. /// <returns></returns>
  15753. [HttpPost]
  15754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15755. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  15756. {
  15757. try
  15758. {
  15759. Result groupData = await _customersRep.CustomersById(dto);
  15760. if (groupData.Code != 0)
  15761. {
  15762. return Ok(JsonView(false, groupData.Msg));
  15763. }
  15764. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15765. }
  15766. catch (Exception ex)
  15767. {
  15768. return Ok(JsonView(false, ex.Message));
  15769. }
  15770. }
  15771. /// <summary>
  15772. /// 保险费用录入页面初始化绑定
  15773. /// </summary>
  15774. /// <param name="dto"></param>
  15775. /// <returns></returns>
  15776. [HttpPost]
  15777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15778. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  15779. {
  15780. try
  15781. {
  15782. Result groupData = await _customersRep.CustomersInitialize(dto);
  15783. if (groupData.Code != 0)
  15784. {
  15785. return Ok(JsonView(false, groupData.Msg));
  15786. }
  15787. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15788. }
  15789. catch (Exception ex)
  15790. {
  15791. return Ok(JsonView(false, ex.Message));
  15792. }
  15793. }
  15794. /// <summary>
  15795. /// 保险费用操作(Status:1.新增,2.修改)
  15796. /// </summary>
  15797. /// <param name="dto"></param>
  15798. /// <returns></returns>
  15799. [HttpPost]
  15800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15801. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  15802. {
  15803. Result groupData = await _customersRep.OpCustomers(dto);
  15804. if (groupData.Code != 0)
  15805. {
  15806. return Ok(JsonView(false, groupData.Msg));
  15807. }
  15808. #region 应用推送
  15809. try
  15810. {
  15811. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  15812. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  15813. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  15814. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  15815. //自动审核
  15816. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  15817. //2024-10-21 新增LZ UID
  15818. var userIds = new List<int>() { 21 };
  15819. string title = $"系统通知";
  15820. var diId = dto.DiId;
  15821. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15822. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15823. string content = "";
  15824. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15825. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15826. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  15827. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  15828. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  15829. }
  15830. catch (Exception ex)
  15831. {
  15832. }
  15833. #endregion
  15834. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15835. }
  15836. /// <summary>
  15837. /// 保险文件上传
  15838. /// </summary>
  15839. /// <param name="file"></param>
  15840. /// <returns></returns>
  15841. [HttpPost]
  15842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15843. public async Task<IActionResult> UploadCus(IFormFile file)
  15844. {
  15845. try
  15846. {
  15847. if (file != null)
  15848. {
  15849. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15850. //文件名称
  15851. string projectFileName = file.FileName;
  15852. //上传的文件的路径
  15853. string filePath = "";
  15854. if (!Directory.Exists(fileDir))
  15855. {
  15856. Directory.CreateDirectory(fileDir);
  15857. }
  15858. //上传的文件的路径
  15859. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  15860. using (FileStream fs = System.IO.File.Create(filePath))
  15861. {
  15862. file.CopyTo(fs);
  15863. fs.Flush();
  15864. }
  15865. return Ok(JsonView(true, "上传成功!", projectFileName));
  15866. }
  15867. else
  15868. {
  15869. return Ok(JsonView(false, "上传失败!"));
  15870. }
  15871. }
  15872. catch (Exception ex)
  15873. {
  15874. return Ok(JsonView(false, "程序错误!"));
  15875. throw;
  15876. }
  15877. }
  15878. /// <summary>
  15879. /// 保险删除指定文件
  15880. /// </summary>
  15881. /// <param name="dto"></param>
  15882. /// <returns></returns>
  15883. [HttpPost]
  15884. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15885. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  15886. {
  15887. try
  15888. {
  15889. string filePath = "";
  15890. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15891. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  15892. //int id = 0;
  15893. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  15894. // 删除该文件
  15895. try
  15896. {
  15897. System.IO.File.Delete(filePath);
  15898. 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()
  15899. {
  15900. Attachment = "",
  15901. }).ExecuteCommandAsync();
  15902. if (result != 0)
  15903. {
  15904. return Ok(JsonView(true, "成功!"));
  15905. }
  15906. else
  15907. {
  15908. return Ok(JsonView(false, "失败!"));
  15909. }
  15910. }
  15911. catch (Exception)
  15912. {
  15913. 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()
  15914. {
  15915. Attachment = "",
  15916. }).ExecuteCommandAsync();
  15917. if (result != 0)
  15918. {
  15919. return Ok(JsonView(true, "成功!"));
  15920. }
  15921. else
  15922. {
  15923. return Ok(JsonView(false, "失败!"));
  15924. }
  15925. }
  15926. }
  15927. catch (Exception ex)
  15928. {
  15929. return Ok(JsonView(false, "程序错误!"));
  15930. throw;
  15931. }
  15932. }
  15933. /// <summary>
  15934. /// 保险费用操作(删除)
  15935. /// </summary>
  15936. /// <param name="dto"></param>
  15937. /// <returns></returns>
  15938. [HttpPost]
  15939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15940. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  15941. {
  15942. try
  15943. {
  15944. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  15945. if (!res)
  15946. {
  15947. return Ok(JsonView(false, "删除失败"));
  15948. }
  15949. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  15950. {
  15951. IsDel = 1,
  15952. DeleteUserId = dto.DeleteUserId,
  15953. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  15954. }).ExecuteCommandAsync();
  15955. return Ok(JsonView(true, "删除成功!"));
  15956. }
  15957. catch (Exception ex)
  15958. {
  15959. return Ok(JsonView(false, "程序错误!"));
  15960. throw;
  15961. }
  15962. }
  15963. #endregion
  15964. #region 接团客户名单 PageId 104
  15965. /// <summary>
  15966. /// 接团客户名单
  15967. /// 迁移数据(慎用!)
  15968. /// </summary>
  15969. /// <returns></returns>
  15970. [HttpPost]
  15971. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15972. public async Task<IActionResult> PostTourClientListChange()
  15973. {
  15974. try
  15975. {
  15976. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  15977. //var groupClinetData1
  15978. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  15979. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  15980. int updateCount = 0;
  15981. if (oldOAClientList.Count > 0)
  15982. {
  15983. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  15984. _sqlSugar.BeginTran();
  15985. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  15986. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  15987. foreach (var item in oldOAClientList)
  15988. {
  15989. int comId = 0;
  15990. string format = "yyyy-MM-dd HH:mm:ss";
  15991. string data11 = "1990-01-01 00:00";
  15992. var data1 = IsValidDate(item.OPdate, format);
  15993. if (data1) data11 = item.OPdate;
  15994. //客户公司验证
  15995. if (!string.IsNullOrEmpty(item.Company))
  15996. {
  15997. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  15998. if (clientComInfo == null) // add
  15999. {
  16000. var addInfo = new Crm_CustomerCompany()
  16001. {
  16002. CompanyAbbreviation = "",
  16003. CompanyFullName = item.Company,
  16004. Address = "",
  16005. PostCodes = "",
  16006. LastedOpUserId = item.OPer,
  16007. LastedOpDt = Convert.ToDateTime(data11),
  16008. CreateUserId = item.OPer,
  16009. CreateTime = Convert.ToDateTime(data11),
  16010. IsDel = 0
  16011. };
  16012. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  16013. if (comId1 > 0) comId = comId1;
  16014. }
  16015. else comId = clientComInfo.Id;
  16016. }
  16017. //客户人员验证
  16018. int clientId = 0;
  16019. string name = item.LastName + item.Name;
  16020. if (!string.IsNullOrEmpty(name))
  16021. {
  16022. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  16023. if (clientInfo == null)
  16024. {
  16025. DateTime? dateTime = null;
  16026. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  16027. if (isDt) dateTime = birthDayDt;
  16028. var addInfo1 = new Crm_DeleClient()
  16029. {
  16030. CrmCompanyId = comId,
  16031. DiId = -1,
  16032. LastName = item.LastName,
  16033. FirstName = item.Name,
  16034. OldName = "",
  16035. Pinyin = item.Pinyin,
  16036. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  16037. Marriage = 0,
  16038. Phone = item.Phone,
  16039. Job = item.Job,
  16040. BirthDay = dateTime
  16041. };
  16042. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  16043. if (clientId1 > 0) clientId = clientId1;
  16044. }
  16045. else clientId = clientInfo.Id;
  16046. }
  16047. if (clientId < 1)
  16048. {
  16049. continue;
  16050. }
  16051. int airType = 0;
  16052. if (item.AirType == "超经舱") airType = 459;
  16053. else if (item.AirType == "公务舱") airType = 458;
  16054. else if (item.AirType == "经济舱") airType = 460;
  16055. else if (item.AirType == "其他") airType = 565;
  16056. else if (item.AirType == "头等舱") airType = 457;
  16057. var _TourClientListEntity = new Grp_TourClientList()
  16058. {
  16059. DiId = item.Diid,
  16060. ClientId = clientId,
  16061. CreateUserId = item.OPer,
  16062. CreateTime = Convert.ToDateTime(data11),
  16063. Remark = item.Remark,
  16064. IsDel = item.Isdel,
  16065. ShippingSpaceTypeId = airType,
  16066. ShippingSpaceSpecialNeeds = item.AirRemark,
  16067. HotelSpecialNeeds = item.RoomType
  16068. };
  16069. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  16070. if (_TourClientList > 0)
  16071. {
  16072. updateCount++;
  16073. }
  16074. }
  16075. _sqlSugar.CommitTran();
  16076. }
  16077. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  16078. }
  16079. catch (Exception ex)
  16080. {
  16081. _sqlSugar.RollbackTran();
  16082. return Ok(JsonView(false, ex.Message));
  16083. }
  16084. //return Ok(JsonView(true));
  16085. }
  16086. private bool IsValidDate(string dateString, string format)
  16087. {
  16088. DateTime dateValue;
  16089. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  16090. return valid;
  16091. }
  16092. /// <summary>
  16093. /// 接团客户名单
  16094. /// 根据团组Id查询List
  16095. /// </summary>
  16096. /// <param name="_dto"></param>
  16097. /// <returns></returns>
  16098. [HttpPost]
  16099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16100. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  16101. {
  16102. #region 参数验证
  16103. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  16104. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  16105. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  16106. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16107. #region 页面操作权限验证
  16108. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16109. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16110. #endregion
  16111. #endregion
  16112. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  16113. if (viewData.Code != 0)
  16114. {
  16115. return Ok(JsonView(false, viewData.Msg));
  16116. }
  16117. return Ok(JsonView(viewData.Data));
  16118. }
  16119. /// <summary>
  16120. /// 接团客户名单
  16121. /// 基础数据 Init
  16122. /// </summary>
  16123. /// <param name="_dto"></param>
  16124. /// <returns></returns>
  16125. [HttpPost]
  16126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16127. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  16128. {
  16129. #region 参数验证
  16130. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16131. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16132. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16133. #region 页面操作权限验证
  16134. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16135. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16136. #endregion
  16137. #endregion
  16138. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  16139. }
  16140. /// <summary>
  16141. /// 接团客户名单
  16142. /// 根据 Id查询 Details
  16143. /// </summary>
  16144. /// <param name="_dto"></param>
  16145. /// <returns></returns>
  16146. [HttpPost]
  16147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16148. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  16149. {
  16150. #region 参数验证
  16151. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16152. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16153. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16154. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16155. #region 页面操作权限验证
  16156. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16157. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16158. #endregion
  16159. #endregion
  16160. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  16161. if (viewData.Code != 0)
  16162. {
  16163. return Ok(JsonView(false, viewData.Msg));
  16164. }
  16165. return Ok(JsonView(viewData.Data));
  16166. }
  16167. /// <summary>
  16168. /// 接团客户名单
  16169. /// Add Or Edit
  16170. /// </summary>
  16171. /// <param name="_dto"></param>
  16172. /// <returns></returns>
  16173. [HttpPost]
  16174. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16175. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  16176. {
  16177. #region 参数验证
  16178. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16179. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16180. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16181. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16182. #region 页面操作权限验证
  16183. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16184. if (_dto.Id == 0) //添加
  16185. {
  16186. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16187. }
  16188. else if (_dto.Id >= 0) //修改
  16189. {
  16190. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16191. }
  16192. #endregion
  16193. #endregion
  16194. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  16195. if (viewData.Code != 0)
  16196. {
  16197. return Ok(JsonView(false, viewData.Msg));
  16198. }
  16199. return Ok(JsonView(true));
  16200. }
  16201. /// <summary>
  16202. /// 接团客户名单
  16203. /// json字符串 AddMultiple(添加多个)
  16204. /// </summary>
  16205. /// <param name="_dto"></param>
  16206. /// <returns></returns>
  16207. [HttpPost]
  16208. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16209. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  16210. {
  16211. #region 参数验证
  16212. string jsonLabel = _dto.JsonLabel;
  16213. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16214. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16215. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16216. #region 页面操作权限验证
  16217. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16218. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16219. #endregion
  16220. #endregion
  16221. var request = new TourClientListAddMultipleDto();
  16222. request.DiId = _dto.DiId;
  16223. request.UserId = _dto.UserId;
  16224. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  16225. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  16226. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  16227. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  16228. var infos = new List<TourClientListInfo>();
  16229. foreach (var data in datas)
  16230. {
  16231. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  16232. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  16233. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  16234. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  16235. {
  16236. continue;
  16237. }
  16238. infos.Add(new TourClientListInfo()
  16239. {
  16240. IsAccompany = 1,
  16241. LastName = lastName,
  16242. FirstName = firstName,
  16243. Pinyin = lastNameEn + @"/" + firstNameEn,
  16244. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  16245. CompanyFullName = data.CompanyFullName,
  16246. Job = data.Job
  16247. });
  16248. }
  16249. if (infos.Any())
  16250. {
  16251. var viewData = await _tourClientListRep._AddMultiple(request);
  16252. if (viewData.Code != 0)
  16253. {
  16254. return Ok(JsonView(false, viewData.Msg));
  16255. }
  16256. return Ok(JsonView(true));
  16257. }
  16258. return Ok(JsonView(false));
  16259. }
  16260. /// <summary>
  16261. /// 接团客户名单
  16262. /// AddMultiple(添加多个)
  16263. /// </summary>
  16264. /// <param name="_dto"></param>
  16265. /// <returns></returns>
  16266. [HttpPost]
  16267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16268. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  16269. {
  16270. #region 参数验证
  16271. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16272. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16273. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16274. #region 页面操作权限验证
  16275. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16276. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16277. #endregion
  16278. #endregion
  16279. var viewData = await _tourClientListRep._AddMultiple(_dto);
  16280. if (viewData.Code != 0)
  16281. {
  16282. return Ok(JsonView(false, viewData.Msg));
  16283. }
  16284. return Ok(JsonView(true));
  16285. }
  16286. /// <summary>
  16287. /// 接团客户名单
  16288. /// Del
  16289. /// </summary>
  16290. /// <param name="_dto"></param>
  16291. /// <returns></returns>
  16292. [HttpPost]
  16293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16294. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  16295. {
  16296. #region 参数验证
  16297. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16298. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16299. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16300. #region 页面操作权限验证
  16301. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16302. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16303. #endregion
  16304. #endregion
  16305. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  16306. if (viewData.Code != 0)
  16307. {
  16308. return Ok(JsonView(false, viewData.Msg));
  16309. }
  16310. return Ok(JsonView(true));
  16311. }
  16312. /// <summary>
  16313. /// 接团客户名单
  16314. /// 文件下载 客户名单
  16315. /// </summary>
  16316. /// <param name="_dto"></param>
  16317. /// <returns></returns>
  16318. [HttpPost]
  16319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16320. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  16321. {
  16322. #region 参数验证
  16323. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16324. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16325. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  16326. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16327. #region 页面操作权限验证
  16328. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16329. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16330. #endregion
  16331. #endregion
  16332. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  16333. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  16334. From Grp_TourClientList tcl
  16335. Left Join
  16336. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  16337. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  16338. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  16339. From Crm_DeleClient dc
  16340. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  16341. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  16342. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  16343. Where dc.IsDel = 0) temp
  16344. On temp.DcId =tcl.ClientId
  16345. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  16346. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  16347. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  16348. //载入模板
  16349. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  16350. if (_dto.Language == 1)
  16351. {
  16352. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  16353. }
  16354. //载入模板
  16355. var doc = new Document(tempPath);
  16356. DocumentBuilder builder = new DocumentBuilder(doc);
  16357. //获取word里所有表格
  16358. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16359. //获取所填表格的序数
  16360. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16361. var rowStart = tableOne.Rows[0]; //获取第1行
  16362. if (_dto.Language == 0)
  16363. {
  16364. //循环赋值
  16365. for (int i = 0; i < DcList.Count; i++)
  16366. {
  16367. EncryptionProcessor.DecryptProperties(DcList[i]);
  16368. builder.MoveToCell(0, i + 1, 0, 0);
  16369. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  16370. builder.MoveToCell(0, i + 1, 1, 0);
  16371. int sex = DcList[i].Sex;
  16372. string sexStr = string.Empty;
  16373. if (sex == 0) sexStr = "男";
  16374. else if (sex == 1) sexStr = "女";
  16375. else sexStr = "未设置";
  16376. builder.Write(sexStr);
  16377. builder.MoveToCell(0, i + 1, 2, 0);
  16378. string birthDay = DcList[i].BirthDay;
  16379. string birthDayStr = string.Empty;
  16380. if (!string.IsNullOrEmpty(birthDay))
  16381. {
  16382. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  16383. }
  16384. builder.Write(birthDayStr);
  16385. builder.MoveToCell(0, i + 1, 3, 0);
  16386. string company = "";
  16387. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16388. {
  16389. company = DcList[i].CompanyFullName.ToString();
  16390. }
  16391. builder.Write(company);
  16392. builder.MoveToCell(0, i + 1, 4, 0);
  16393. builder.Write(DcList[i].Job);
  16394. }
  16395. }
  16396. else if (_dto.Language == 1)
  16397. {
  16398. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  16399. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  16400. List<string> transArrayStr = new List<string>();
  16401. string transStrRes1 = "";
  16402. for (int i = 0; i < DcList.Count; i++)
  16403. {
  16404. var dc = DcList[i];
  16405. EncryptionProcessor.DecryptProperties(dc);
  16406. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  16407. if (dc.Job.Equals("暂无")) dc.Job = "-";
  16408. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  16409. if (DcList.Count - 1 == i) transStrRes1 += str1;
  16410. else transStrRes1 += $"{str1}|";
  16411. }
  16412. //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";
  16413. string transStrRes = "";
  16414. if (transStrRes1.Length > 0)
  16415. {
  16416. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  16417. }
  16418. //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
  16419. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  16420. //List<string> transArray = new List<string> { };
  16421. List<TranslateInfo> transArray = new List<TranslateInfo>();
  16422. if (transStrRes.Contains("|"))
  16423. {
  16424. string[] transArray1 = transStrRes.Split('|');
  16425. if (transArray1.Length > 0)
  16426. {
  16427. foreach (var item in transArray1)
  16428. {
  16429. if (item.Contains("&"))
  16430. {
  16431. string[] transArray2 = item.Split('&');
  16432. int index = 0;
  16433. string companyName = "", job = "";
  16434. if (transArray2.Length > 0)
  16435. {
  16436. bool success = int.TryParse(transArray2[0].Trim(), out index);
  16437. if (1 < transArray2.Length) companyName = transArray2[1];
  16438. if (2 < transArray2.Length) job = transArray2[2];
  16439. }
  16440. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  16441. }
  16442. }
  16443. }
  16444. }
  16445. //循环赋值
  16446. for (int i = 0; i < DcList.Count; i++)
  16447. {
  16448. string PYName = "";
  16449. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  16450. {
  16451. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  16452. string PY_First = DcList[i].Pinyin.Split('/')[1];
  16453. PYName = PY_First + " " + PY_Last;
  16454. }
  16455. else
  16456. {
  16457. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  16458. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  16459. PYName = PY_First + " " + PY_Last;
  16460. }
  16461. builder.MoveToCell(0, i + 1, 0, 0);
  16462. builder.Write(PYName);
  16463. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  16464. builder.MoveToCell(0, i + 1, 1, 0);
  16465. builder.Write(sex);
  16466. DateTime birthDt;
  16467. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  16468. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  16469. builder.MoveToCell(0, i + 1, 2, 0);
  16470. builder.Write(birthday);
  16471. string company = string.Empty, job = string.Empty;
  16472. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  16473. if (dcTransInfo != null)
  16474. {
  16475. company = dcTransInfo.CompanyName;
  16476. job = dcTransInfo.Job;
  16477. }
  16478. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16479. {
  16480. //查询对照表
  16481. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  16482. if (tempCec != null)
  16483. {
  16484. company = tempCec.enName;
  16485. }
  16486. //翻译
  16487. else
  16488. {
  16489. }
  16490. }
  16491. builder.MoveToCell(0, i + 1, 3, 0);
  16492. builder.Write(company);
  16493. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  16494. {
  16495. //查询对照表
  16496. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  16497. if (tempPec != null)
  16498. {
  16499. job = tempPec.enName;
  16500. }
  16501. //翻译
  16502. else
  16503. {
  16504. }
  16505. }
  16506. builder.MoveToCell(0, i + 1, 4, 0);
  16507. builder.Write(job);
  16508. }
  16509. }
  16510. //删除多余行
  16511. while (tableOne.Rows.Count > DcList.Count + 1)
  16512. {
  16513. tableOne.Rows.RemoveAt(DcList.Count + 1);
  16514. }
  16515. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  16516. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  16517. doc.Save(fileDir);
  16518. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  16519. return Ok(JsonView(true, "操作成功!", Url));
  16520. }
  16521. private class TranslateInfo
  16522. {
  16523. public int Index { get; set; }
  16524. public string CompanyName { get; set; }
  16525. public string Job { get; set; }
  16526. }
  16527. #endregion
  16528. #region 团组倒推表
  16529. /// <summary>
  16530. /// 倒推表基础数据
  16531. /// Init
  16532. /// </summary>
  16533. /// <returns></returns>
  16534. [HttpPost]
  16535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16536. public async Task<IActionResult> PostInvertedListInit()
  16537. {
  16538. var viewData = await _invertedListRep._Init();
  16539. if (viewData.Code != 0)
  16540. {
  16541. return Ok(JsonView(false, viewData.Msg));
  16542. }
  16543. return Ok(JsonView(viewData.Data));
  16544. }
  16545. /// <summary>
  16546. /// 倒推表
  16547. /// Info
  16548. /// </summary>
  16549. /// <param name="dto"></param>
  16550. /// <returns></returns>
  16551. [HttpPost]
  16552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16553. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  16554. {
  16555. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  16556. if (viewData.Code != 0)
  16557. {
  16558. return Ok(JsonView(false, viewData.Msg));
  16559. }
  16560. return Ok(JsonView(viewData.Data));
  16561. }
  16562. /// <summary>
  16563. /// 倒推表
  16564. /// Create
  16565. /// </summary>
  16566. /// <param name="dto"></param>
  16567. /// <returns></returns>
  16568. [HttpPost]
  16569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16570. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  16571. {
  16572. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  16573. if (viewData.Code != 0)
  16574. {
  16575. return Ok(JsonView(false, viewData.Msg));
  16576. }
  16577. return Ok(JsonView(viewData.Data));
  16578. }
  16579. /// <summary>
  16580. /// 倒推表
  16581. /// Update
  16582. /// </summary>
  16583. /// <param name="dto"></param>
  16584. /// <returns></returns>
  16585. [HttpPost]
  16586. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16587. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  16588. {
  16589. var viewData = await _invertedListRep._Update(dto);
  16590. if (viewData.Code != 0)
  16591. {
  16592. return Ok(JsonView(false, viewData.Msg));
  16593. }
  16594. return Ok(JsonView(viewData.Data));
  16595. }
  16596. /// <summary>
  16597. /// 倒推表
  16598. /// File Download
  16599. /// </summary>
  16600. /// <param name="dto"></param>
  16601. /// <returns></returns>
  16602. [HttpPost]
  16603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16604. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  16605. {
  16606. var info2 = await _invertedListRep._Info(1, dto.DiId);
  16607. if (info2.Code != 0)
  16608. {
  16609. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  16610. }
  16611. var info1 = info2.Data as InvertedListInfoView;
  16612. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  16613. string teamName = "";
  16614. if (info != null) teamName = info.TeamName;
  16615. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  16616. var doc = new Document();
  16617. var builder = new DocumentBuilder(doc);
  16618. #region old insert
  16619. ////载入模板
  16620. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  16621. //Document doc = new Document(tempPath);
  16622. //DocumentBuilder builder = new DocumentBuilder(doc);
  16623. //利用键值对存放数据
  16624. //Dictionary<string, string> dic = new Dictionary<string, string>();
  16625. //dic.Add("TeamName", teamName);
  16626. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  16627. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  16628. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  16629. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  16630. //dic.Add("SQRemark", info1.ApprovalRemark);
  16631. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  16632. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  16633. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  16634. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  16635. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  16636. //dic.Add("QZRemark", info1.VisaInformationRemark);
  16637. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  16638. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  16639. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  16640. //dic.Add("CQRemark", info1.IssueVisaRemark);
  16641. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  16642. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  16643. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  16644. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  16645. //#region 填充word模板书签内容
  16646. //foreach (var key in dic.Keys)
  16647. //{
  16648. // builder.MoveToBookmark(key);
  16649. // builder.Write(dic[key]);
  16650. //}
  16651. //#endregion
  16652. #endregion
  16653. #region New Insert
  16654. string titleFont = $"仿宋",
  16655. contentFont = $"仿宋";
  16656. var fontColor = Color.FromArgb(64, 64, 64);
  16657. //设置标题 团组名称
  16658. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  16659. builder.Font.Name = titleFont;
  16660. builder.Font.Color = fontColor;
  16661. builder.Font.Size = 12;
  16662. builder.Font.Bold = true;
  16663. builder.Writeln(teamName);
  16664. //设置副标题 团组出访时间
  16665. builder.Font.Size = 12;
  16666. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  16667. builder.Writeln();
  16668. var backgroundColor = Color.FromArgb(199, 199, 199);
  16669. var table = builder.StartTable();
  16670. builder.InsertCell();
  16671. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  16672. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  16673. builder.CellFormat.Borders.LineWidth = 1;
  16674. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  16675. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  16676. builder.RowFormat.Height = 40;
  16677. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  16678. builder.Font.Name = contentFont;
  16679. builder.Font.Size = 12;
  16680. builder.Font.Bold = true;
  16681. builder.Font.Color = fontColor;
  16682. builder.Write("时间");
  16683. builder.InsertCell();
  16684. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  16685. builder.Write("流程");
  16686. builder.InsertCell();
  16687. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  16688. builder.Write("说明");
  16689. builder.EndRow();
  16690. //报批资料准备
  16691. if (info1.IsSelectedAirportd)
  16692. {
  16693. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  16694. }
  16695. //报批/提供送签资料
  16696. if (info1.IsSelectedApprovalData)
  16697. {
  16698. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  16699. }
  16700. //出批件护照办理
  16701. if (info1.IsSelectedIssueApproval)
  16702. {
  16703. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  16704. }
  16705. //签证资料准备
  16706. if (info1.IsSelectedVisaInfo)
  16707. {
  16708. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  16709. }
  16710. //送签
  16711. if (info1.IsSelectedSendVisa)
  16712. {
  16713. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  16714. }
  16715. //出签
  16716. if (info1.IsSelectedIssueVisa)
  16717. {
  16718. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  16719. }
  16720. //机票
  16721. if (info1.IsSelectedAirTicket)
  16722. {
  16723. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  16724. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  16725. }
  16726. //酒店
  16727. if (info1.IsSelectedHotel)
  16728. {
  16729. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  16730. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  16731. }
  16732. //开行前会
  16733. if (info1.IsSelectedPreTripMeeting)
  16734. {
  16735. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  16736. }
  16737. //送机
  16738. if (info1.IsSelectedAirportdDropOff)
  16739. {
  16740. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  16741. }
  16742. builder.EndTable();
  16743. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  16744. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  16745. for (int i = 0; i < table.Rows.Count; i++)
  16746. {
  16747. var row = table.Rows[i];
  16748. //设置宽度
  16749. row.Cells[0].CellFormat.Width = 20.00;
  16750. row.Cells[1].CellFormat.Width = 30.00;
  16751. row.Cells[2].CellFormat.Width = 50.00;
  16752. if (i != 0)
  16753. {
  16754. //边框设置
  16755. InvertedListFileDownloadSetBorders(row.Cells, 0);
  16756. InvertedListFileDownloadSetBorders(row.Cells, 1);
  16757. InvertedListFileDownloadSetBorders(row.Cells, 2);
  16758. }
  16759. }
  16760. #region 页脚插入图片
  16761. // 创建页脚
  16762. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  16763. doc.FirstSection.HeadersFooters.Add(footer);
  16764. Paragraph para = new Paragraph(doc);
  16765. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  16766. footer.AppendChild(para);
  16767. builder.MoveTo(para);
  16768. string imagePath = "./Images/FMGJ_Log.png";
  16769. builder.InsertImage(imagePath);
  16770. #endregion
  16771. #endregion
  16772. var fileDir = AppSettingsHelper.Get("WordBasePath");
  16773. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  16774. string filePath = fileDir + $@"InvertedList/{fileName}";
  16775. doc.Save(filePath);
  16776. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  16777. return Ok(JsonView(true, "操作成功!", Url));
  16778. }
  16779. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime,string content,string reamrk)
  16780. {
  16781. var fontColor = Color.FromArgb(64, 64, 64);
  16782. builder.InsertCell();
  16783. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  16784. builder.RowFormat.Height = 40;
  16785. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  16786. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  16787. builder.Font.Name = fontName;
  16788. builder.Font.Size = 8;
  16789. builder.Font.Bold = true;
  16790. builder.Font.Color = fontColor;
  16791. builder.Write(dateTime);
  16792. builder.InsertCell();
  16793. builder.Font.Size = 9;
  16794. builder.Font.Bold = true;
  16795. builder.Font.Color = fontColor;
  16796. builder.Write(content);
  16797. builder.InsertCell();
  16798. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  16799. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  16800. builder.Font.Size = 9;
  16801. builder.Font.Bold = false;
  16802. builder.Font.Color = fontColor;
  16803. builder.Write(reamrk);
  16804. builder.EndRow();
  16805. }
  16806. private void InvertedListFileDownloadSetBorders(CellCollection cell,int index)
  16807. {
  16808. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  16809. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  16810. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  16811. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  16812. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  16813. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  16814. }
  16815. #endregion
  16816. #region 会务倒推表
  16817. /// <summary>
  16818. /// 会务倒推表
  16819. /// Init
  16820. /// </summary>
  16821. /// <returns></returns>
  16822. [HttpPost]
  16823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16824. public async Task<IActionResult> InforRetrogressTableInit()
  16825. {
  16826. var groupData = await _groupRepository.PostShareGroupInfos(1);
  16827. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  16828. return Ok(JsonView(false, groupData.Msg));
  16829. }
  16830. /// <summary>
  16831. /// 会务倒推表
  16832. /// ExcelDownload
  16833. /// </summary>
  16834. /// <param name="dto"></param>
  16835. /// <returns></returns>
  16836. [HttpPost]
  16837. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  16838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16839. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  16840. {
  16841. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  16842. var validatorRes = await validator.ValidateAsync(dto);
  16843. if (!validatorRes.IsValid)
  16844. {
  16845. StringBuilder sb = new StringBuilder();
  16846. foreach (var item in validatorRes.Errors)
  16847. {
  16848. sb.AppendLine(item.ErrorMessage);
  16849. }
  16850. return Ok(JsonView(false, sb.ToString()));
  16851. }
  16852. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  16853. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  16854. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  16855. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  16856. #region Excel
  16857. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  16858. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  16859. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  16860. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  16861. var fileNamePrefix = string.Empty;
  16862. if (days >= 30)
  16863. {
  16864. tempPath += $"会务工作倒推进度表(30天).xlsx";
  16865. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  16866. }
  16867. else if (days < 30 && days > 7)
  16868. {
  16869. tempPath += $"会务工作倒推进度表(15天).xlsx";
  16870. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  16871. }
  16872. else if (days <= 7)
  16873. {
  16874. tempPath += $"会务工作倒推进度表(7天).xlsx";
  16875. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  16876. }
  16877. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  16878. fileName = CommonFun.ValidFileName(fileName);
  16879. //载入模板
  16880. WorkbookDesigner designer = new WorkbookDesigner();
  16881. designer.Workbook = new Workbook(tempPath);
  16882. designer.Process();
  16883. if (!Directory.Exists(savePath))
  16884. {
  16885. Directory.CreateDirectory(savePath);
  16886. }
  16887. string serverPath = $"{savePath}{fileName}";
  16888. designer.Workbook.Save(serverPath);
  16889. string rst = $"{servicePath}{ftpPath}{fileName}";
  16890. #endregion
  16891. return Ok(JsonView(new { url = rst }));
  16892. }
  16893. #endregion
  16894. #region 三公签证费用(签证费、代办费)
  16895. /// <summary>
  16896. /// 三公签证费用(签证费、代办费)
  16897. /// List
  16898. /// </summary>
  16899. /// <returns></returns>
  16900. [HttpPost]
  16901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16902. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  16903. {
  16904. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  16905. if (_view.Code != 0)
  16906. {
  16907. return Ok(JsonView(false, _view.Msg));
  16908. }
  16909. return Ok(JsonView(true, "操作成功!", _view.Data));
  16910. }
  16911. /// <summary>
  16912. /// 三公签证费用(签证费、代办费)
  16913. /// Add Or Update
  16914. /// </summary>
  16915. /// <returns></returns>
  16916. [HttpPost]
  16917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16918. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  16919. {
  16920. var _view = await _visaFeeInfoRep._Update(_dto);
  16921. if (_view.Code != 0)
  16922. {
  16923. return Ok(JsonView(false, _view.Msg));
  16924. }
  16925. return Ok(JsonView(true, _view.Msg));
  16926. }
  16927. #endregion
  16928. #region 酒店询价
  16929. /// <summary>
  16930. /// 酒店询价
  16931. /// Init
  16932. /// </summary>
  16933. /// <returns></returns>
  16934. [HttpPost]
  16935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16936. public async Task<IActionResult> PostHotelInquiryInit()
  16937. {
  16938. var res = await _hotelInquiryRep._Init();
  16939. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16940. return Ok(JsonView(true, res.Msg, res.Data));
  16941. }
  16942. /// <summary>
  16943. /// 酒店询价
  16944. /// page Item
  16945. /// </summary>
  16946. /// <param name="_dto"></param>
  16947. /// <returns></returns>
  16948. [HttpPost]
  16949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16950. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  16951. {
  16952. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  16953. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16954. var view = res.Data as PageDataViewBase;
  16955. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  16956. }
  16957. /// <summary>
  16958. /// 酒店询价
  16959. /// info
  16960. /// </summary>
  16961. /// <param name="_dto"></param>
  16962. /// <returns></returns>
  16963. [HttpPost]
  16964. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16965. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  16966. {
  16967. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  16968. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16969. return Ok(JsonView(true, res.Msg, res.Data));
  16970. }
  16971. /// <summary>
  16972. /// 酒店询价
  16973. /// Add Or Edit
  16974. /// </summary>
  16975. /// <param name="_dto"></param>
  16976. /// <returns></returns>
  16977. [HttpPost]
  16978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16979. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  16980. {
  16981. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  16982. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16983. return Ok(JsonView(true, res.Msg, res.Data));
  16984. }
  16985. /// <summary>
  16986. /// 酒店询价
  16987. /// Del
  16988. /// </summary>
  16989. /// <param name="_dto"></param>
  16990. /// <returns></returns>
  16991. [HttpPost]
  16992. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16993. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  16994. {
  16995. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  16996. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16997. return Ok(JsonView(true, res.Msg, res.Data));
  16998. }
  16999. #endregion
  17000. #region 下载匹配op行程单
  17001. /// <summary>
  17002. /// 匹配op行程单
  17003. /// Init
  17004. /// </summary>
  17005. /// <param name="dto">团组列表请求dto</param>
  17006. /// <returns></returns>
  17007. [HttpPost]
  17008. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17009. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  17010. {
  17011. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17012. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  17013. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  17014. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  17015. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  17016. .Where(it => it.IsDel == 0)
  17017. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  17018. .OrderByDescending(it => it.CreateUserId)
  17019. .ToList();
  17020. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  17021. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17022. var diids = groupInfos.Select(it => it.Id).ToList();
  17023. List<string> countrys = new List<string>();
  17024. foreach (var item in country)
  17025. {
  17026. var data = _groupRepository.FormartTeamName(item);
  17027. var dataArray = _groupRepository.GroupSplitCountry(data);
  17028. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17029. }
  17030. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  17031. List<string> areaArray = new List<string>(); //GetGroupCityLine
  17032. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  17033. foreach (var item in areaItem)
  17034. {
  17035. string areaStr = item.Value;
  17036. if (!string.IsNullOrEmpty(areaStr))
  17037. {
  17038. string[] str1 = areaStr.Split("-");
  17039. if (str1.Length > 0)
  17040. {
  17041. areaArray.AddRange(str1);
  17042. }
  17043. }
  17044. }
  17045. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  17046. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  17047. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  17048. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  17049. .ToList();
  17050. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  17051. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  17052. .Where(it => countriesIds.Contains(it.Id))
  17053. .Select(it => new { it.Id, Name = it.Name_CN })
  17054. .ToList();
  17055. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  17056. .Select(it => it.TeamName).ToList();
  17057. stopwatch.Stop();
  17058. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  17059. }
  17060. ///// <summary>
  17061. ///// 匹配op行程单
  17062. ///// Init 查询区域数据
  17063. ///// </summary>
  17064. ///// <param name="dto">团组列表请求dto</param>
  17065. ///// <returns></returns>
  17066. //[HttpPost]
  17067. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17068. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  17069. //{
  17070. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17071. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  17072. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  17073. // if (string.IsNullOrEmpty(countriesDataStr))
  17074. // {
  17075. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  17076. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  17077. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  17078. // }
  17079. // else
  17080. // {
  17081. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  17082. // }
  17083. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  17084. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  17085. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  17086. // List<dynamic> childList = new List<dynamic>();
  17087. // int parentId = dto.CountriesId;
  17088. // if (provinceData.Count > 1)
  17089. // {
  17090. // foreach (var item1 in provinceData)
  17091. // {
  17092. // List<dynamic> childList1 = new List<dynamic>();
  17093. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  17094. // foreach (var item2 in citiesData1)
  17095. // {
  17096. // List<dynamic> childList2 = new List<dynamic>();
  17097. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17098. // foreach (var item3 in countiesData1)
  17099. // {
  17100. // childList2.Add(new
  17101. // {
  17102. // id = item3.Id,
  17103. // parentId = item2.Id,
  17104. // level = "district",
  17105. // name = item3.Name_CN,
  17106. // });
  17107. // }
  17108. // childList1.Add(new
  17109. // {
  17110. // id = item2.Id,
  17111. // parentId = item1.Id,
  17112. // level = "city",
  17113. // name = item2.Name_CN,
  17114. // childList = childList2
  17115. // });
  17116. // }
  17117. // childList.Add(new
  17118. // {
  17119. // id = item1.Id,
  17120. // parentId = parentId,
  17121. // level = "province",
  17122. // name = item1.Name_CN,
  17123. // childList = childList1
  17124. // });
  17125. // }
  17126. // //城市
  17127. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  17128. // foreach (var item2 in citiesData2)
  17129. // {
  17130. // List<dynamic> childList22 = new List<dynamic>();
  17131. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17132. // foreach (var item3 in countiesData1)
  17133. // {
  17134. // childList22.Add(new
  17135. // {
  17136. // id = item3.Id,
  17137. // parentId = item2.Id,
  17138. // level = "district",
  17139. // name = item3.Name_CN,
  17140. // });
  17141. // }
  17142. // childList.Add(new
  17143. // {
  17144. // id = item2.Id,
  17145. // parentId = parentId,
  17146. // level = "city",
  17147. // name = item2.Name_CN,
  17148. // childList = childList22
  17149. // });
  17150. // }
  17151. // }
  17152. // else
  17153. // {
  17154. // foreach (var item2 in citiesData)
  17155. // {
  17156. // string cname = item2.Name_CN;
  17157. // List<dynamic> childList1 = new List<dynamic>();
  17158. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17159. // foreach (var item3 in countiesData1)
  17160. // {
  17161. // childList1.Add(new
  17162. // {
  17163. // Id = item3.Id,
  17164. // parentId = item2.Id,
  17165. // level = "district",
  17166. // name = item3.Name_CN
  17167. // });
  17168. // }
  17169. // childList.Add(new
  17170. // {
  17171. // id = item2.Id,
  17172. // parentId = parentId,
  17173. // level = "city",
  17174. // name = item2.Name_CN,
  17175. // childList = childList1
  17176. // });
  17177. // }
  17178. // }
  17179. // stopwatch.Stop();
  17180. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  17181. //}
  17182. /// <summary>
  17183. /// 匹配op行程单
  17184. /// 接团信息列表 Page
  17185. /// </summary>
  17186. /// <param name="dto">团组列表请求dto</param>
  17187. /// <returns></returns>
  17188. [HttpPost]
  17189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17190. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  17191. {
  17192. var swatch = new Stopwatch();
  17193. swatch.Start();
  17194. #region 参数验证
  17195. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17196. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17197. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17198. #region 页面操作权限验证
  17199. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17200. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  17201. #endregion
  17202. #endregion
  17203. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17204. {
  17205. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  17206. //string sqlWhere = "";
  17207. if (!string.IsNullOrEmpty(dto.Country))
  17208. {
  17209. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  17210. }
  17211. if (!string.IsNullOrEmpty(dto.Area))
  17212. {
  17213. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  17214. }
  17215. if (!string.IsNullOrEmpty(dto.TeamName))
  17216. {
  17217. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  17218. }
  17219. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  17220. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  17221. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  17222. swatch.Stop();
  17223. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  17224. }
  17225. else
  17226. {
  17227. return Ok(JsonView(false, "查询失败"));
  17228. }
  17229. }
  17230. /// <summary>
  17231. /// 匹配op行程单
  17232. /// 行程单下载
  17233. /// </summary>
  17234. /// <param name="dto">团组列表请求dto</param>
  17235. /// <returns></returns>
  17236. [HttpPost]
  17237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17238. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  17239. {
  17240. #region 参数验证
  17241. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17242. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17243. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17244. #region 页面操作权限验证
  17245. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17246. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  17247. #endregion
  17248. #endregion
  17249. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17250. {
  17251. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  17252. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  17253. }
  17254. else
  17255. {
  17256. return Ok(JsonView(false, "下载失败!"));
  17257. }
  17258. }
  17259. #endregion
  17260. #region 国家信息 数据 注释
  17261. //[HttpPost]
  17262. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  17263. //{
  17264. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  17265. // foreach (var item in dto)
  17266. // {
  17267. // infos.Add(new Grp_GroupsTaskAssignment()
  17268. // {
  17269. // DIId = item,
  17270. // CTId = 82,
  17271. // UId = 248,
  17272. // IsEnable = 1,
  17273. // CreateUserId = 233,
  17274. // CreateTime = DateTime.Now,
  17275. // IsDel = 0
  17276. // });
  17277. // infos.Add(new Grp_GroupsTaskAssignment()
  17278. // {
  17279. // DIId = item,
  17280. // CTId = 82,
  17281. // UId = 286,
  17282. // IsEnable = 1,
  17283. // CreateUserId = 233,
  17284. // CreateTime = DateTime.Now,
  17285. // IsDel = 0
  17286. // });
  17287. // }
  17288. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  17289. // return Ok("操作成功");
  17290. //}
  17291. //public class paramJsonDto
  17292. //{
  17293. // public List<CountriesInfo> str { get; set; }
  17294. //}
  17295. //[HttpPost]
  17296. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  17297. //{
  17298. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  17299. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  17300. // List<Sys_Cities> cities = new List<Sys_Cities>();
  17301. // List<Sys_Cities> districts = new List<Sys_Cities>();
  17302. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17303. // _sqlSugar.BeginTran();
  17304. // int countitiesIndex = 0;
  17305. // foreach (var item in dto.str)
  17306. // {
  17307. // dynamic data = item.c;
  17308. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  17309. // if (data != null)
  17310. // {
  17311. // countitiesIndex++;
  17312. // foreach (var item1 in data)
  17313. // {
  17314. // string cnname = item1.cn;
  17315. // string enname = item1.en;
  17316. // Sys_Cities provinceInfo = new Sys_Cities()
  17317. // {
  17318. // CountriesId = countriesId,
  17319. // Name_CN = cnname,
  17320. // Name_EN = enname,
  17321. // ParentId = 0,
  17322. // IsCapital = 1,
  17323. // CreateUserId = 208,
  17324. // CreateTime = DateTime.Now,
  17325. // IsDel = 0
  17326. // };
  17327. // if (item1.lv == "province") //省份
  17328. // {
  17329. // provinceInfo.Level = 1;
  17330. // int provinceId = 0;
  17331. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  17332. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  17333. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17334. // var data1 = item1.c;
  17335. // foreach (var item2 in data1)
  17336. // {
  17337. // if (item2.lv == "city")
  17338. // {
  17339. // string citycnname = item2.cn;
  17340. // string cityenname = item2.en;
  17341. // Sys_Cities cityInfo = new Sys_Cities()
  17342. // {
  17343. // CountriesId = countriesId,
  17344. // ParentId = provinceId,
  17345. // Level = 2,
  17346. // Name_CN = citycnname,
  17347. // Name_EN = cityenname,
  17348. // IsCapital = 1,
  17349. // CreateUserId = 208,
  17350. // CreateTime = DateTime.Now,
  17351. // IsDel = 0
  17352. // };
  17353. // if (item2.c != null)
  17354. // {
  17355. // int cityId = 0;
  17356. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  17357. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17358. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  17359. // foreach (var item3 in item2.c)
  17360. // {
  17361. // if (item3.lv == "district")
  17362. // {
  17363. // var districtInfo = new Sys_Cities()
  17364. // {
  17365. // CountriesId = countriesId,
  17366. // Name_CN = item3.cn,
  17367. // Name_EN = item3.en,
  17368. // Level = 3,
  17369. // ParentId = cityId,
  17370. // IsCapital = 1,
  17371. // CreateUserId = 208,
  17372. // CreateTime = DateTime.Now,
  17373. // IsDel = 0
  17374. // };
  17375. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17376. // //{
  17377. // districts.Add(districtInfo);
  17378. // //}
  17379. // }
  17380. // }
  17381. // }
  17382. // else
  17383. // {
  17384. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  17385. // //{
  17386. // cities.Add(cityInfo);
  17387. // //}
  17388. // }
  17389. // }
  17390. // }
  17391. // }
  17392. // else if (item1.lv == "city")//城市
  17393. // {
  17394. // provinceInfo.Level = 2;
  17395. // if (item1.c != null)
  17396. // {
  17397. // int cityId = 0;
  17398. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  17399. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17400. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17401. // foreach (var item3 in item1.c)
  17402. // {
  17403. // if (item3.lv == "district")
  17404. // {
  17405. // var districtInfo = new Sys_Cities()
  17406. // {
  17407. // CountriesId = countriesId,
  17408. // Name_CN = item3.cn,
  17409. // Name_EN = item3.en,
  17410. // Level = 3,
  17411. // ParentId = cityId,
  17412. // IsCapital = 1,
  17413. // CreateUserId = 208,
  17414. // CreateTime = DateTime.Now,
  17415. // IsDel = 0
  17416. // };
  17417. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17418. // //{
  17419. // districts.Add(districtInfo);
  17420. // //}
  17421. // }
  17422. // }
  17423. // }
  17424. // else
  17425. // {
  17426. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  17427. // //{
  17428. // cities.Add(provinceInfo);
  17429. // //}
  17430. // }
  17431. // }
  17432. // }
  17433. // }
  17434. // }
  17435. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  17436. // cities = cities.Distinct().ToList();
  17437. // districts = districts.Distinct().ToList();
  17438. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  17439. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  17440. // cities.AddRange(districts);
  17441. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  17442. // //_sqlSugar.RollbackTran();
  17443. // _sqlSugar.CommitTran();
  17444. // return Ok(JsonView(false, "操作成功!"));
  17445. //}
  17446. //[HttpPost]
  17447. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  17448. //{
  17449. // List<CountitiesInfo> infos = dto.MyProperty;
  17450. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  17451. // _sqlSugar.BeginTran();
  17452. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17453. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  17454. // foreach (var item in infos)
  17455. // {
  17456. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  17457. // if (countryInfo != null)
  17458. // {
  17459. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  17460. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  17461. // if (cityInfo1 != null)
  17462. // {
  17463. // cityInfo1.IsCapital = 0;
  17464. // cityInfos.Add(cityInfo1);
  17465. // }
  17466. // }
  17467. // }
  17468. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  17469. // .UpdateColumns(it => it.IsCapital)
  17470. // .WhereColumns(it => it.Id)
  17471. // .ExecuteCommand();
  17472. // //_sqlSugar.RollbackTran();
  17473. // _sqlSugar.CommitTran();
  17474. // return Ok(JsonView(false, "操作成功!"));
  17475. //}
  17476. //public class CounrtiesDto
  17477. //{
  17478. // public List<CountitiesInfo> MyProperty { get; set; }
  17479. //}
  17480. //public class CountitiesInfo
  17481. //{
  17482. // /// <summary>
  17483. // /// 圣约翰
  17484. // /// </summary>
  17485. // public string capital_name_chinese { get; set; }
  17486. // /// <summary>
  17487. // ///
  17488. // /// </summary>
  17489. // public string capital_name { get; set; }
  17490. // /// <summary>
  17491. // ///
  17492. // /// </summary>
  17493. // public string country_type { get; set; }
  17494. // /// <summary>
  17495. // /// 安提瓜和巴布达
  17496. // /// </summary>
  17497. // public string country_name_chinese { get; set; }
  17498. // /// <summary>
  17499. // /// 安提瓜和巴布达
  17500. // /// </summary>
  17501. // public string country_name_chinese_short { get; set; }
  17502. // /// <summary>
  17503. // /// 安提瓜和巴布达
  17504. // /// </summary>
  17505. // public string country_name_chinese_UN { get; set; }
  17506. // /// <summary>
  17507. // ///
  17508. // /// </summary>
  17509. // public string country_name_english_abbreviation { get; set; }
  17510. // /// <summary>
  17511. // ///
  17512. // /// </summary>
  17513. // public string country_name_english_formal { get; set; }
  17514. // /// <summary>
  17515. // ///
  17516. // /// </summary>
  17517. // public string country_name_english_UN { get; set; }
  17518. // /// <summary>
  17519. // ///
  17520. // /// </summary>
  17521. // public string continent_name { get; set; }
  17522. // /// <summary>
  17523. // ///
  17524. // /// </summary>
  17525. // public string subregion_name { get; set; }
  17526. // /// <summary>
  17527. // ///
  17528. // /// </summary>
  17529. // public string country_code2 { get; set; }
  17530. // /// <summary>
  17531. // ///
  17532. // /// </summary>
  17533. // public string country_code3 { get; set; }
  17534. // /// <summary>
  17535. // ///
  17536. // /// </summary>
  17537. // public string phone_code { get; set; }
  17538. //}
  17539. //public class CountriesInfo : BasicInfo
  17540. //{
  17541. // public List<CitiesInfo> c { get; set; }
  17542. //}
  17543. //public class CitiesInfo : BasicInfo
  17544. //{
  17545. // public List<AreaInfo> c { get; set; }
  17546. //}
  17547. //public class AreaInfo : BasicInfo
  17548. //{
  17549. // public List<AreaInfo> c { get; set; }
  17550. //}
  17551. //public class BasicInfo
  17552. //{
  17553. // public string code { get; set; }
  17554. // public string cn { get; set; }
  17555. // public string lv { get; set; }
  17556. // public string en { get; set; }
  17557. //}
  17558. #endregion
  17559. #region 查看邀请方
  17560. /// <summary>
  17561. /// 查看邀请方
  17562. /// 邀请方信息 Init
  17563. /// </summary>
  17564. /// <param name="dto"></param>
  17565. /// <returns></returns>
  17566. [HttpPost]
  17567. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17568. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  17569. {
  17570. string sqlWhere = string.Empty;
  17571. if (!string.IsNullOrEmpty(dto.Search))
  17572. {
  17573. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  17574. }
  17575. string sql = string.Format($@"Select
  17576. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  17577. Id,
  17578. UnitName
  17579. From Res_InvitationOfficialActivityData
  17580. Where IsDel = 0
  17581. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  17582. RefAsync<int> total = 0;
  17583. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17584. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  17585. }
  17586. /// <summary>
  17587. /// 查看邀请方
  17588. /// 国家信息 Init
  17589. /// </summary>
  17590. /// <param name="dto"></param>
  17591. /// <returns></returns>
  17592. [HttpPost]
  17593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17594. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  17595. {
  17596. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  17597. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17598. var diids = groupInfos.Select(it => it.Id).ToList();
  17599. List<string> countrys = new List<string>();
  17600. foreach (var item in country)
  17601. {
  17602. var data = _groupRepository.FormartTeamName(item);
  17603. var dataArray = _groupRepository.GroupSplitCountry(data);
  17604. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17605. }
  17606. countrys = countrys.Distinct().ToList();
  17607. for (int i = 0; i < countrys.Count; i++)
  17608. {
  17609. string item = countrys[i];
  17610. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  17611. {
  17612. countrys.Remove(item);
  17613. i--;
  17614. }
  17615. }
  17616. RefAsync<int> total = 0;
  17617. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  17618. .Where(it => countrys.Contains(it.Name_CN))
  17619. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17620. .Select(it => new { id = it.Id, name = it.Name_CN })
  17621. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17622. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17623. }
  17624. /// <summary>
  17625. /// 查看邀请方
  17626. /// 城市信息 Init
  17627. /// </summary>
  17628. /// <param name="dto"></param>
  17629. /// <returns></returns>
  17630. [HttpPost]
  17631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17632. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  17633. {
  17634. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  17635. RefAsync<int> total = 0;
  17636. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  17637. .Where(it => it.CountriesId == dto.CountiesId)
  17638. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17639. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  17640. .Select(it => new { id = it.Id, name = it.Name_CN })
  17641. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17642. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17643. }
  17644. /// <summary>
  17645. /// 查看邀请方
  17646. /// 团组名称 Init
  17647. /// </summary>
  17648. /// <param name="dto"></param>
  17649. /// <returns></returns>
  17650. [HttpPost]
  17651. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17652. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  17653. {
  17654. var watch = new Stopwatch();
  17655. watch.Start();
  17656. RefAsync<int> total = 0;
  17657. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  17658. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  17659. .Where((oa, di) => oa.IsDel == 0)
  17660. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  17661. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  17662. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  17663. .Distinct()
  17664. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17665. watch.Stop();
  17666. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  17667. }
  17668. /// <summary>
  17669. /// 查看邀请方
  17670. /// 团组 & 邀请方信息
  17671. /// </summary>
  17672. /// <param name="dto"></param>
  17673. /// <returns></returns>
  17674. [HttpPost]
  17675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17676. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  17677. {
  17678. var watch = new Stopwatch();
  17679. watch.Start();
  17680. RefAsync<int> total = 0;
  17681. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  17682. .AS("Grp_DelegationInfo")
  17683. .Includes(x => x.InvitingInfos)
  17684. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  17685. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  17686. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  17687. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  17688. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  17689. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  17690. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17691. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  17692. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  17693. infos.ForEach(x =>
  17694. {
  17695. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  17696. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  17697. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  17698. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  17699. });
  17700. watch.Stop();
  17701. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  17702. }
  17703. #endregion
  17704. #region 报批行程
  17705. /// <summary>
  17706. /// 报批行程初始化
  17707. /// </summary>
  17708. /// <param name="dto"></param>
  17709. /// <returns></returns>
  17710. [HttpPost]
  17711. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  17712. {
  17713. const int chiNumber = 5;
  17714. var jw = JsonView(false);
  17715. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  17716. var group = groupList.First();
  17717. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  17718. group = groupList.First(x => x.Id == diid);
  17719. if (group == null)
  17720. {
  17721. jw.Msg = "暂无团组!";
  17722. return Ok(jw);
  17723. }
  17724. var data = new
  17725. {
  17726. groupList = groupList.Select(x => new
  17727. {
  17728. x.TeamName,
  17729. x.Id
  17730. }),
  17731. content = new ArrayList(),
  17732. groupInfo = new
  17733. {
  17734. group.VisitDays,
  17735. group.TourCode,
  17736. group.VisitPNumber,
  17737. group.TeamName,
  17738. group.Id,
  17739. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  17740. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  17741. },
  17742. };
  17743. var resultArr = new ArrayList();
  17744. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  17745. if (content.Count == 0)
  17746. {
  17747. var stay = "-";
  17748. var cityPath = "-";
  17749. //添加城市路径以及住宿地
  17750. //黑屏代码数据
  17751. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  17752. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17753. {
  17754. jw = JsonView(true, "黑屏代码有误!", data);
  17755. return Ok(jw);
  17756. }
  17757. foreach (DataRow row in dtBlack.Rows)
  17758. {
  17759. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17760. {
  17761. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  17762. return Ok(jw);
  17763. }
  17764. }
  17765. //黑屏代码获取时间区间
  17766. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  17767. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  17768. _sqlSugar.BeginTran();
  17769. for (int i = 0; i < timeArr.Count; i++)
  17770. {
  17771. stay = "-";
  17772. cityPath = "-";
  17773. DateTime NewData = DateTime.Parse(timeArr[i]);
  17774. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  17775. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  17776. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  17777. if (tbSelect.Length > 0)
  17778. {
  17779. List<string> threeCodeStr = new List<string>();
  17780. foreach (var item in tbSelect)
  17781. {
  17782. var threeCode = item["Three"].ToString() ?? "";
  17783. if (threeCode.Length == 6)
  17784. {
  17785. var start = threeCode.Substring(0, 3);
  17786. var end = threeCode.Substring(3, 3);
  17787. if (threeCodeStr.Count == 0)
  17788. {
  17789. threeCodeStr.Add(start);
  17790. threeCodeStr.Add(end);
  17791. }
  17792. else
  17793. {
  17794. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  17795. {
  17796. threeCodeStr.Add(end);
  17797. }
  17798. else
  17799. {
  17800. threeCodeStr.Add(start);
  17801. threeCodeStr.Add(end);
  17802. }
  17803. }
  17804. }
  17805. }
  17806. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  17807. var last = threeCodeStr.Last();
  17808. foreach (var item in threeCodeStr)
  17809. {
  17810. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  17811. if (item.Equals(last))
  17812. {
  17813. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  17814. }
  17815. }
  17816. cityPath = cityPath.Trim('-');
  17817. }
  17818. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  17819. appro.Diid = diid ?? -1;
  17820. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  17821. appro.Id = thisId;
  17822. appro.CreateUserId = dto.UserId;
  17823. appro.CreateTime = DateTime.Now;
  17824. content.Add(appro);
  17825. }
  17826. _sqlSugar.CommitTran();
  17827. }
  17828. foreach (var x in content)
  17829. {
  17830. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  17831. if (chiList.Count < chiNumber)
  17832. {
  17833. for (int i = chiList.Count; i < chiNumber; i++)
  17834. {
  17835. chiList.Add(new Grp_ApprovalTravelDetails());
  17836. }
  17837. }
  17838. resultArr.Add(new
  17839. {
  17840. x.Id,
  17841. x.Date,
  17842. x.Diid,
  17843. chiList = chiList.Select(x1 => new
  17844. {
  17845. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  17846. x1.Details,
  17847. x1.ParentId,
  17848. x1.Id
  17849. })
  17850. });
  17851. }
  17852. data = data with
  17853. {
  17854. content = resultArr,
  17855. };
  17856. jw = JsonView(true, "获取成功!", data);
  17857. return Ok(jw);
  17858. }
  17859. /// <summary>
  17860. /// 报批行程删除
  17861. /// </summary>
  17862. /// <param name="dto"></param>
  17863. /// <returns></returns>
  17864. [HttpPost]
  17865. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  17866. {
  17867. var jw = JsonView(false);
  17868. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17869. if (group == null)
  17870. {
  17871. jw.Msg = "团组参数有误!";
  17872. return Ok(jw);
  17873. }
  17874. try
  17875. {
  17876. _sqlSugar.BeginTran();
  17877. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  17878. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  17879. {
  17880. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17881. DeleteUserId = dto.uesrId,
  17882. IsDel = 1
  17883. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  17884. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  17885. {
  17886. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17887. DeleteUserId = dto.uesrId,
  17888. IsDel = 1
  17889. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  17890. _sqlSugar.CommitTran();
  17891. jw = JsonView(true, "删除成功");
  17892. }
  17893. catch (Exception ex)
  17894. {
  17895. jw = JsonView(false, ex.Message);
  17896. }
  17897. return Ok(jw);
  17898. }
  17899. /// <summary>
  17900. /// 报批行程保存
  17901. /// </summary>
  17902. /// <param name="dto"></param>
  17903. /// <returns></returns>
  17904. [HttpPost]
  17905. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  17906. {
  17907. var jw = JsonView(false);
  17908. var Find = dto.Arr.Find(x => x.id == 0);
  17909. if (Find != null)
  17910. {
  17911. jw.Msg = "生成的ID为0!";
  17912. return Ok(jw);
  17913. }
  17914. foreach (var item in dto.Arr)
  17915. {
  17916. foreach (var chi in item.chiList)
  17917. {
  17918. if (chi.parentId == 0)
  17919. {
  17920. chi.parentId = item.id;
  17921. }
  17922. }
  17923. }
  17924. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  17925. _sqlSugar.BeginTran();
  17926. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  17927. {
  17928. var parentIds = dto.Arr.Select(x => x.id).ToList();
  17929. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  17930. {
  17931. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17932. DeleteUserId = dto.UserId,
  17933. IsDel = 1
  17934. }).ExecuteCommand();
  17935. }
  17936. try
  17937. {
  17938. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  17939. {
  17940. CreateTime = DateTime.Now,
  17941. CreateUserId = dto.UserId,
  17942. Details = x.details,
  17943. ParentId = x.parentId,
  17944. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17945. Remark = "",
  17946. IsDel = 0
  17947. }).ToList()).ExecuteCommand();
  17948. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  17949. {
  17950. Id = x.id,
  17951. Details = x.details,
  17952. ParentId = x.parentId,
  17953. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17954. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  17955. {
  17956. Details = x.Details,
  17957. ParentId = x.ParentId,
  17958. Time = x.Time
  17959. }).ExecuteCommand();
  17960. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  17961. {
  17962. Id = x.id,
  17963. Date = x.date,
  17964. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  17965. {
  17966. Date = x.Date
  17967. }).ExecuteCommand();
  17968. _sqlSugar.CommitTran();
  17969. jw = JsonView(true, "保存成功!");
  17970. }
  17971. catch (Exception ex)
  17972. {
  17973. _sqlSugar.RollbackTran();
  17974. jw = JsonView(false, "保存失败!" + ex.Message);
  17975. }
  17976. return Ok(jw);
  17977. }
  17978. /// <summary>
  17979. /// 报批行程生成
  17980. /// </summary>
  17981. /// <param name="dto"></param>
  17982. /// <returns></returns>
  17983. [HttpPost]
  17984. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  17985. {
  17986. var jw = JsonView(false);
  17987. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17988. if (group == null)
  17989. {
  17990. jw.Msg = "暂无该团组!";
  17991. return Ok(jw);
  17992. }
  17993. //黑屏代码数据
  17994. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  17995. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17996. {
  17997. jw.Msg = "黑屏代码有误!";
  17998. return Ok(jw);
  17999. }
  18000. foreach (DataRow row in dtBlack.Rows)
  18001. {
  18002. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18003. {
  18004. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  18005. return Ok(jw);
  18006. }
  18007. }
  18008. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  18009. var resultArr = new ArrayList();
  18010. if (officialActivitiesArr.Count == 0)
  18011. {
  18012. jw.Msg = "暂无公务出访信息!";
  18013. return Ok(jw);
  18014. }
  18015. try
  18016. {
  18017. _sqlSugar.BeginTran();
  18018. DeleteApprovalJourney(new
  18019. Domain.Dtos.Groups.DeleteApprovalJourney
  18020. {
  18021. Diid = dto.Diid,
  18022. uesrId = dto.Userid
  18023. });
  18024. var stay = "-";
  18025. var cityPath = "-";
  18026. //添加城市路径以及住宿地
  18027. //黑屏代码获取时间区间
  18028. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18029. var empty = "【未收入该三字码!请机票同事录入】";
  18030. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18031. for (int i = 0; i < timeArr.Count; i++)
  18032. {
  18033. stay = "-";
  18034. cityPath = "-";
  18035. var chiarr = new List<Grp_ApprovalTravelDetails>();
  18036. DateTime NewData = DateTime.Parse(timeArr[i]);
  18037. 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();
  18038. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18039. if (tbSelect.Length > 0)
  18040. {
  18041. List<string> threeCodeStr = new List<string>();
  18042. bool isTrade = false;
  18043. string trip = string.Empty;
  18044. var rowLast = tbSelect.Last();
  18045. var rowFirst = tbSelect.First();
  18046. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  18047. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  18048. var takeOffTime = DateTime.Parse(timeArr[i]);
  18049. var fallToTime = DateTime.Parse(timeArr[i]);
  18050. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  18051. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  18052. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  18053. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  18054. foreach (var item in tbSelect)
  18055. {
  18056. var start = string.Empty;
  18057. var end = string.Empty;
  18058. var threeCode = item["Three"].ToString() ?? "";
  18059. if (threeCode.Length == 6)
  18060. {
  18061. start = threeCode.Substring(0, 3);
  18062. end = threeCode.Substring(3, 3);
  18063. if (threeCodeStr.Count == 0)
  18064. {
  18065. threeCodeStr.Add(start);
  18066. threeCodeStr.Add(end);
  18067. }
  18068. else
  18069. {
  18070. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18071. {
  18072. threeCodeStr.Add(end);
  18073. }
  18074. else
  18075. {
  18076. threeCodeStr.Add(start);
  18077. threeCodeStr.Add(end);
  18078. }
  18079. }
  18080. }
  18081. //处理机票信息
  18082. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  18083. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  18084. if (start_Object == null)
  18085. {
  18086. start_Object = new Res_ThreeCode()
  18087. {
  18088. AirPort = empty,
  18089. AirPort_En = empty,
  18090. City = empty,
  18091. Country = empty,
  18092. Four = empty,
  18093. Three = empty,
  18094. };
  18095. }
  18096. if (end_Object == null)
  18097. {
  18098. end_Object = new Res_ThreeCode()
  18099. {
  18100. AirPort = empty,
  18101. AirPort_En = empty,
  18102. City = empty,
  18103. Country = empty,
  18104. Four = empty,
  18105. Three = empty,
  18106. };
  18107. }
  18108. //机型判断
  18109. string airModel = item["AirModel"].ToString();
  18110. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  18111. string flightTime = item["FlightTime"].ToString();
  18112. if (flightTime!.Contains(":"))
  18113. {
  18114. flightTime = flightTime.Replace(":", "小时");
  18115. flightTime += "分钟";
  18116. }
  18117. if (flightTime.Contains("H"))
  18118. {
  18119. flightTime = flightTime.Replace("H", "小时");
  18120. }
  18121. if (flightTime.Contains("M"))
  18122. {
  18123. flightTime = flightTime.Replace("M", "分钟");
  18124. }
  18125. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  18126. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  18127. {
  18128. flightTime = flightDataTime.Hour > 0
  18129. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  18130. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  18131. ? flightDataTime.Minute.ToString() + "分钟" : "";
  18132. }
  18133. //航班号
  18134. string flightcode = item["Fliagtcode"].ToString();
  18135. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  18136. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  18137. if (aircompany == null)
  18138. {
  18139. aircompany = new Res_AirCompany
  18140. {
  18141. CnName = hsEmpty,
  18142. EnName = hsEmpty,
  18143. ShortCode = hsEmpty,
  18144. };
  18145. }
  18146. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  18147. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  18148. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  18149. if (isTrade)
  18150. {
  18151. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  18152. }
  18153. else
  18154. {
  18155. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  18156. }
  18157. }
  18158. chiarr.Add(new Grp_ApprovalTravelDetails
  18159. {
  18160. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  18161. CreateTime = DateTime.Now,
  18162. CreateUserId = dto.Userid,
  18163. ParentId = 0,
  18164. Details = trip
  18165. });
  18166. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18167. var last = threeCodeStr.Last();
  18168. foreach (var item in threeCodeStr)
  18169. {
  18170. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18171. if (item.Equals(last))
  18172. {
  18173. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18174. }
  18175. }
  18176. cityPath = cityPath.Trim('-');
  18177. }
  18178. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18179. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18180. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  18181. appro.Diid = dto.Diid;
  18182. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18183. appro.Id = thisId;
  18184. appro.CreateUserId = dto.Userid;
  18185. appro.CreateTime = DateTime.Now;
  18186. foreach (var item in gwinfo)
  18187. {
  18188. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  18189. chi.Details = "拜访" + item.Client;
  18190. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  18191. {
  18192. chi.Details += "," + item.ReqSample;
  18193. }
  18194. chi.ParentId = thisId;
  18195. chi.Time = item.Time;
  18196. chiarr.Add(chi);
  18197. }
  18198. if (chiarr.Count < 5)
  18199. {
  18200. for (int j = chiarr.Count; j < 5; j++)
  18201. {
  18202. chiarr.Add(new
  18203. Grp_ApprovalTravelDetails());
  18204. }
  18205. }
  18206. resultArr.Add(new
  18207. {
  18208. appro.Id,
  18209. appro.Date,
  18210. appro.Diid,
  18211. chiList = chiarr.Select(x1 => new
  18212. {
  18213. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  18214. x1.Details,
  18215. x1.ParentId,
  18216. x1.Id
  18217. })
  18218. });
  18219. }
  18220. _sqlSugar.CommitTran();
  18221. jw = JsonView(true, "生成成功!", resultArr);
  18222. }
  18223. catch (Exception ex)
  18224. {
  18225. jw.Code = 400;
  18226. jw.Msg = "生成失败!" + ex.Message;
  18227. }
  18228. return Ok(jw);
  18229. }
  18230. /// <summary>
  18231. /// 报批行程word导出
  18232. /// </summary>
  18233. /// <param name="dto"></param>
  18234. /// <returns></returns>
  18235. [HttpPost]
  18236. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  18237. {
  18238. var jw = JsonView(false);
  18239. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18240. if (group == null)
  18241. {
  18242. jw.Msg = "暂无该团组!";
  18243. return Ok(jw);
  18244. }
  18245. //模板路径
  18246. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  18247. //载入模板
  18248. Document doc = new Document(tempPath);
  18249. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18250. //获取所填表格的序数
  18251. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18252. Aspose.Words.Tables.Row titleRowClone = null;
  18253. Aspose.Words.Tables.Row CenterRowClone = null;
  18254. int index = 0;
  18255. int indexChi = 0;
  18256. int SetIndex = 0;
  18257. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  18258. //获取数据,放到datatable
  18259. foreach (var item in ApprovalTravelArr)
  18260. {
  18261. if (index > 0)
  18262. {
  18263. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  18264. tableOne.AppendChild(titleRowClone);
  18265. }
  18266. var textTime = item.Date;
  18267. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  18268. SetCells(tableOne, doc, SetIndex, 0, textTime);
  18269. SetIndex++;
  18270. if (ChiRep.Count > 0)
  18271. {
  18272. foreach (var itemChi in ChiRep)
  18273. {
  18274. var txtTime = itemChi.Time;
  18275. var txtDetail = itemChi.Details;
  18276. if (indexChi > 0)
  18277. {
  18278. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18279. tableOne.AppendChild(CenterRowClone);
  18280. }
  18281. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  18282. {
  18283. SetCells(tableOne, doc, SetIndex, 0, "");
  18284. SetCells(tableOne, doc, SetIndex, 1, "");
  18285. indexChi++;
  18286. SetIndex++;
  18287. break;
  18288. }
  18289. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  18290. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  18291. indexChi++;
  18292. SetIndex++;
  18293. }
  18294. }
  18295. else
  18296. {
  18297. if (indexChi > 0)
  18298. {
  18299. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18300. tableOne.AppendChild(CenterRowClone);
  18301. }
  18302. SetCells(tableOne, doc, SetIndex, 0, "");
  18303. SetCells(tableOne, doc, SetIndex, 1, "");
  18304. indexChi++;
  18305. SetIndex++;
  18306. }
  18307. index++;
  18308. }
  18309. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  18310. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18311. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18312. jw.Code = 200;
  18313. jw.Msg = "";
  18314. return Ok(jw);
  18315. }
  18316. private string intToString(int numberVal)
  18317. {
  18318. string numberval = numberVal.ToString();
  18319. Dictionary<char, string> Number = new Dictionary<char, string>();
  18320. Number.Add('1', "一");
  18321. Number.Add('2', "二");
  18322. Number.Add('3', "三");
  18323. Number.Add('4', "四");
  18324. Number.Add('5', "五");
  18325. Number.Add('6', "六");
  18326. Number.Add('7', "七");
  18327. Number.Add('8', "八");
  18328. Number.Add('9', "九");
  18329. string stringNumberVal = string.Empty;
  18330. for (int i = 0; i < numberval.Length; i++)
  18331. {
  18332. if (i == 0)
  18333. {
  18334. stringNumberVal += Number[numberval[i]];
  18335. }
  18336. else if (i >= 1)
  18337. {
  18338. if (numberval[i] == '0')
  18339. {
  18340. stringNumberVal = "十";
  18341. }
  18342. else
  18343. {
  18344. stringNumberVal += "十" + Number[numberval[i]];
  18345. }
  18346. }
  18347. }
  18348. return stringNumberVal;
  18349. }
  18350. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  18351. {
  18352. //获取table中的某个单元格,从0开始
  18353. Cell lshCell = table.Rows[rows].Cells[cells];
  18354. //将单元格中段落移除
  18355. foreach (Node item in lshCell.Paragraphs)
  18356. {
  18357. lshCell.Paragraphs.Remove(item);
  18358. }
  18359. if (val.Contains("\r\n"))
  18360. {
  18361. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  18362. foreach (var item in spArr)
  18363. {
  18364. //新建一个段落
  18365. Paragraph p = new Paragraph(doc);
  18366. var r = new Run(doc, item);
  18367. //把设置的值赋给之前新建的段落
  18368. p.AppendChild(r);
  18369. //将此段落加到单元格内
  18370. lshCell.AppendChild(p);
  18371. }
  18372. }
  18373. else
  18374. {
  18375. //新建一个段落
  18376. Paragraph p = new Paragraph(doc);
  18377. var r = new Run(doc, val);
  18378. //把设置的值赋给之前新建的段落
  18379. p.AppendChild(r);
  18380. //将此段落加到单元格内
  18381. lshCell.AppendChild(p);
  18382. }
  18383. }
  18384. [HttpPost]
  18385. public async Task<IActionResult> ServerHttp(string paramStr)
  18386. {
  18387. paramStr = paramStr.TrimEnd('\'');
  18388. paramStr = paramStr.TrimStart('\'');
  18389. JsonView jw = JsonView(false);
  18390. JObject param = JObject.Parse(paramStr);
  18391. if (!param.ContainsKey("url"))
  18392. {
  18393. jw.Msg = "url null";
  18394. return Ok(jw);
  18395. }
  18396. string url = param["url"]!.ToString();
  18397. var methon = "get";
  18398. Dictionary<string, string> headValues = null;
  18399. string bodyStr = string.Empty;
  18400. if (param.ContainsKey("methon"))
  18401. {
  18402. methon = param["methon"]!.ToString().ToLower();
  18403. }
  18404. if (param.ContainsKey("header"))
  18405. {
  18406. var header = param["header"]!.ToString();
  18407. JObject headerJobject = JObject.Parse(header);
  18408. headValues = new Dictionary<string, string>();
  18409. foreach (JProperty item in headerJobject.Properties())
  18410. {
  18411. var value = item.Value.ToString();
  18412. var head = item.Path;
  18413. headValues.Add(head, value);
  18414. }
  18415. }
  18416. HttpClient client = new HttpClient();
  18417. string responseString = string.Empty;
  18418. StringContent content = null;
  18419. if (headValues != null)
  18420. {
  18421. foreach (var item in headValues.Keys)
  18422. {
  18423. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  18424. {
  18425. if (param.ContainsKey("body"))
  18426. {
  18427. bodyStr = param["body"]!.ToString();
  18428. }
  18429. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  18430. }
  18431. else
  18432. {
  18433. client.DefaultRequestHeaders.Add(item, headValues[item]);
  18434. }
  18435. }
  18436. }
  18437. try
  18438. {
  18439. if (methon == "get")
  18440. {
  18441. responseString = await client.GetStringAsync(url);
  18442. }
  18443. else if (methon == "post")
  18444. {
  18445. var request = new HttpRequestMessage(HttpMethod.Post, url)
  18446. {
  18447. Content = content
  18448. };
  18449. var response = await client.SendAsync(request);
  18450. try
  18451. {
  18452. Stream responseStream = await response.Content.ReadAsStreamAsync();
  18453. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  18454. {
  18455. using (StreamReader reader = new StreamReader(gzipStream))
  18456. {
  18457. responseString = await reader.ReadToEndAsync();
  18458. }
  18459. }
  18460. }
  18461. catch (Exception)
  18462. {
  18463. responseString = await response.Content.ReadAsStringAsync();
  18464. }
  18465. }
  18466. else
  18467. {
  18468. responseString = "methon error";
  18469. }
  18470. jw = JsonView(true, "success", responseString);
  18471. }
  18472. catch (Exception ex)
  18473. {
  18474. jw.Msg = "error " + ex.Message;
  18475. jw.Data = ex.StackTrace;
  18476. }
  18477. finally
  18478. {
  18479. client.Dispose();
  18480. }
  18481. return Ok(jw);
  18482. }
  18483. #endregion
  18484. #region 团组接待意见调查
  18485. /// <summary>
  18486. /// 团组接待意见调查 - 信息管理
  18487. /// 基础数据(团组)
  18488. /// </summary>
  18489. /// <returns></returns>
  18490. [HttpGet]
  18491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18492. public async Task<IActionResult> OpinionaireInit()
  18493. {
  18494. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  18495. .Select(x => new
  18496. {
  18497. x.Id,
  18498. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  18499. })
  18500. .OrderByDescending(x => x.Id)
  18501. .ToListAsync();
  18502. return Ok(JsonView(groupData, groupData.Count));
  18503. }
  18504. /// <summary>
  18505. /// 团组接待意见调查 - 信息管理
  18506. /// 列表
  18507. /// </summary>
  18508. /// <param name="groupId"></param>
  18509. /// <returns></returns>
  18510. [HttpGet("{groupId}")]
  18511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18512. public async Task<IActionResult> OpinionaireManageList(int groupId)
  18513. {
  18514. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18515. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  18516. .Select(x => new
  18517. {
  18518. x.Id,
  18519. x.TourGuideName,
  18520. x.CityName,
  18521. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  18522. x.CreateTime
  18523. })
  18524. .OrderBy(x => x.Id)
  18525. .ToListAsync();
  18526. return Ok(JsonView(data));
  18527. }
  18528. /// <summary>
  18529. /// 团组接待意见调查 - 信息管理
  18530. /// 保存
  18531. /// </summary>
  18532. /// <param name="dto"></param>
  18533. /// <returns></returns>
  18534. [HttpPost]
  18535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18536. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  18537. {
  18538. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18539. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18540. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18541. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  18542. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  18543. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  18544. _opinionaireRep.BeginTran();
  18545. if (addData != null && addData.Count > 0)
  18546. {
  18547. foreach (var item in addData)
  18548. {
  18549. item.CreateUserId = currUserInfo.UserId;
  18550. item.DiId = dto.DiId;
  18551. }
  18552. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  18553. }
  18554. if (updData != null && updData.Count > 0)
  18555. {
  18556. var upd = await _opinionaireRep._sqlSugar
  18557. .Updateable(updData)
  18558. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  18559. .WhereColumns(x => new { x.Id })
  18560. .ExecuteCommandAsync();
  18561. }
  18562. _opinionaireRep.CommitTran();
  18563. return Ok(JsonView("操作成功!"));
  18564. }
  18565. /// <summary>
  18566. /// 团组接待意见调查 - 信息管理
  18567. /// 删除
  18568. /// </summary>
  18569. /// <param name="id"></param>
  18570. /// <returns></returns>
  18571. [HttpDelete("{id}")]
  18572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18573. public async Task<IActionResult> OpinionaireManageDel(int id)
  18574. {
  18575. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18576. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18577. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  18578. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  18579. if (!del) return Ok(JsonView("操作失败!"));
  18580. return Ok(JsonView("操作成功!"));
  18581. }
  18582. /// <summary>
  18583. /// 团组接待意见调查 - 用户
  18584. /// 列表
  18585. /// </summary>
  18586. /// <param name="diId"></param>
  18587. /// <returns></returns>
  18588. [HttpGet("{diId}")]
  18589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18590. public async Task<IActionResult> OpinionaireUserList(int diId)
  18591. {
  18592. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18593. var sql = string.Format(@"
  18594. SELECT
  18595. o.Id,
  18596. o.DiId,
  18597. di.TeamName AS 'GroupName',
  18598. di.VisitPNumber AS 'PeopleNumber',
  18599. di.ClientName AS 'LeadGroup',
  18600. di.VisitCountry AS 'Travel',
  18601. di.VisitDays AS 'Days',
  18602. o.CityName,
  18603. o.TourGuideName,
  18604. o.Catering,
  18605. o.CateringReason,
  18606. o.Stay,
  18607. o.StayReason,
  18608. o.[Route],
  18609. o.RouteReason,
  18610. o.OfficialActivity,
  18611. o.OfficialActivityReason,
  18612. o.TourGuide,
  18613. o.TourGuideReason,
  18614. o.[Translate],
  18615. o.TranslateReason,
  18616. o.Trip,
  18617. o.TripReason,
  18618. o.ESFileName,
  18619. o.SignatureDate,
  18620. o.Remark
  18621. FROM
  18622. Grp_Opinionaire o
  18623. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  18624. WHERE
  18625. o.IsDel = 0
  18626. AND o.DiId = {0}
  18627. ORDER BY
  18628. o.Id ASC", diId);
  18629. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  18630. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  18631. return Ok(JsonView(data));
  18632. }
  18633. /// <summary>
  18634. /// 团组接待意见调查 - 用户
  18635. /// 保存
  18636. /// </summary>
  18637. /// <param name="dto"></param>
  18638. /// <returns></returns>
  18639. [HttpPost]
  18640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18641. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  18642. {
  18643. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  18644. foreach (var item in dto)
  18645. {
  18646. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  18647. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  18648. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  18649. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  18650. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  18651. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  18652. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  18653. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  18654. }
  18655. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  18656. if (!Directory.Exists(filePathBase))
  18657. {
  18658. Directory.CreateDirectory(filePathBase);
  18659. }
  18660. #region 上传文件
  18661. var filePaths = new List<string>();
  18662. foreach (var item in dto)
  18663. {
  18664. var file = item.File;
  18665. // 将文件保存到指定位置
  18666. var filePath = Path.Combine(filePathBase, file.FileName);
  18667. using (var stream = new FileStream(filePath, FileMode.Create))
  18668. {
  18669. await file.CopyToAsync(stream);
  18670. }
  18671. //验证文件是否上传成功
  18672. if (!System.IO.File.Exists(filePath))
  18673. {
  18674. foreach (var filePathStr in filePaths)
  18675. {
  18676. System.IO.File.Delete(filePathStr);
  18677. }
  18678. return Ok(JsonView(false, "文件上传失败!"));
  18679. }
  18680. item.ESFileName = file.FileName;
  18681. }
  18682. #endregion
  18683. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  18684. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  18685. .UpdateColumns(x => new
  18686. {
  18687. x.Catering,
  18688. x.CateringReason,
  18689. x.Stay,
  18690. x.StayReason,
  18691. x.Route,
  18692. x.RouteReason,
  18693. x.OfficialActivity,
  18694. x.OfficialActivityReason,
  18695. x.TourGuide,
  18696. x.TourGuideReason,
  18697. x.Translate,
  18698. x.TranslateReason,
  18699. x.Trip,
  18700. x.TripReason,
  18701. x.ESFileName,
  18702. x.SignatureDate,
  18703. x.Remark
  18704. })
  18705. .WhereColumns(x => new { x.Id })
  18706. .ExecuteCommandAsync();
  18707. if (upd < 1)
  18708. {
  18709. foreach (var filePathStr in filePaths)
  18710. {
  18711. System.IO.File.Delete(filePathStr);
  18712. }
  18713. return Ok(JsonView(false));
  18714. }
  18715. return Ok(JsonView(true));
  18716. }
  18717. #endregion
  18718. #region 团组餐厅相关信息
  18719. /// <summary>
  18720. /// 团组相关餐厅信息
  18721. /// 基础数据(团组)
  18722. /// </summary>
  18723. /// <returns></returns>
  18724. [HttpGet]
  18725. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18726. public async Task<IActionResult> RestaurantInit()
  18727. {
  18728. return Ok(await _restaurantRep.InitAsync());
  18729. }
  18730. /// <summary>
  18731. /// 团组相关餐厅信息
  18732. /// Item
  18733. /// </summary>
  18734. /// <param name="dto"></param>
  18735. /// <returns></returns>
  18736. [HttpPost]
  18737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18738. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  18739. {
  18740. int portType = dto.PortType,
  18741. groupId = dto.GroupId;
  18742. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18743. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18744. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  18745. }
  18746. /// <summary>
  18747. /// 团组相关餐厅信息
  18748. /// List
  18749. /// </summary>
  18750. /// <param name="dto"></param>
  18751. /// <returns></returns>
  18752. [HttpPost]
  18753. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18754. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  18755. {
  18756. int portType = dto.PortType,
  18757. groupId = dto.GroupId;
  18758. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18759. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18760. var sql = string.Format(@" SELECT
  18761. ri.Id,
  18762. ri.GroupId,
  18763. ri.Date,
  18764. ri.StartTime,
  18765. ri.EndTime,
  18766. CASE WHEN ri.Type = 1 THEN '早餐'
  18767. WHEN ri.Type = 2 THEN '午餐'
  18768. WHEN ri.Type = 3 THEN '晚餐'
  18769. ELSE '其他'
  18770. END AS 'Type',
  18771. ri.Name,
  18772. ri.Address,
  18773. ri.Tel,
  18774. ri.Remark,
  18775. ri.CreateTime,
  18776. u.CnName AS CreateUserName
  18777. FROM
  18778. Grp_RestaurantInfo ri
  18779. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  18780. WHERE
  18781. ri.IsDel = 0
  18782. AND ri.GroupId = {0}
  18783. ORDER BY
  18784. ri.Date ASC
  18785. ", groupId);
  18786. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  18787. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  18788. return Ok(JsonView(infos));
  18789. }
  18790. /// <summary>
  18791. /// 团组相关餐厅信息
  18792. /// Info
  18793. /// </summary>
  18794. /// <param name="dto"></param>
  18795. /// <returns></returns>
  18796. [HttpPost]
  18797. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18798. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  18799. {
  18800. int portType = dto.PortType,
  18801. id = dto.Id;
  18802. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18803. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18804. return Ok(await _restaurantRep.InfoAsync(portType, id));
  18805. }
  18806. /// <summary>
  18807. /// 团组相关餐厅信息
  18808. /// Op
  18809. /// </summary>
  18810. /// <param name="dto"></param>
  18811. /// <returns></returns>
  18812. [HttpPost]
  18813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18814. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  18815. {
  18816. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18817. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18818. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  18819. return Ok(await _restaurantRep.OpAsync(dto));
  18820. }
  18821. /// <summary>
  18822. /// 团组相关餐厅信息
  18823. /// Del
  18824. /// </summary>
  18825. /// <param name="dto"></param>
  18826. /// <returns></returns>
  18827. [HttpPost]
  18828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18829. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  18830. {
  18831. int userId = dto.DeleteUserId;
  18832. var id = dto.Id;
  18833. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18834. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18835. return Ok(await _restaurantRep.DelAsync(dto));
  18836. }
  18837. #endregion
  18838. // /// <summary>
  18839. // ///
  18840. // /// </summary>
  18841. // /// <param name="_dto"></param>
  18842. // /// <returns></returns>
  18843. // [HttpPost]
  18844. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18845. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18846. // {
  18847. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18848. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  18849. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  18850. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18851. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  18852. // dic_psg.Add("客人", 974);
  18853. // dic_psg.Add("司机", 975);
  18854. // dic_psg.Add("导游", 976);
  18855. // dic_psg.Add("公司内部人员", 977);
  18856. // dic_psg.Add("司机/导游/公司内部人员", 978);
  18857. // foreach (var item in list_visa)
  18858. // {
  18859. // Grp_VisaInfo temp = new Grp_VisaInfo();
  18860. // temp.Id = item.Id;
  18861. // temp.DIId = item.DIId;
  18862. // temp.VisaClient = item.VisaClient;
  18863. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  18864. // temp.VisaCurrency = item.VisaCurrency;
  18865. // temp.IsThird = item.IsThird;
  18866. // if (dic_psg.ContainsKey(item.PassengerType))
  18867. // {
  18868. // temp.PassengerType = dic_psg[item.PassengerType];
  18869. // }
  18870. // else {
  18871. // temp.PassengerType = -1;
  18872. // }
  18873. // temp.VisaNumber = item.VisaNumber;
  18874. // temp.VisaFreeNumber = item.VisaFreeNumber;
  18875. // temp.CreateUserId = item.Operators;
  18876. // DateTime dt_ct;
  18877. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  18878. // if (b_ct)
  18879. // {
  18880. // temp.CreateTime = dt_ct;
  18881. // }
  18882. // else
  18883. // {
  18884. // temp.CreateTime = DateTime.Now;
  18885. // }
  18886. // temp.DeleteTime = "";
  18887. // temp.DeleteUserId = 0;
  18888. // temp.Remark = item.Remark;
  18889. // if (string.IsNullOrEmpty(temp.Remark)) {
  18890. // temp.Remark = "";
  18891. // }
  18892. // temp.IsDel = item.IsDel;
  18893. // temp.VisaDescription = item.VisaAttachment;
  18894. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  18895. //([Id]
  18896. // ,[DIId]
  18897. // ,[VisaClient]
  18898. // ,[VisaPrice]
  18899. // ,[VisaCurrency]
  18900. // ,[IsThird]
  18901. // ,[PassengerType]
  18902. // ,[VisaNumber]
  18903. // ,[VisaFreeNumber]
  18904. // ,[CreateUserId]
  18905. // ,[CreateTime]
  18906. // ,[DeleteTime]
  18907. // ,[DeleteUserId]
  18908. // ,[Remark]
  18909. // ,[IsDel]
  18910. // ,[visaDescription])
  18911. // VALUES
  18912. // ({0},{1},'{2}',{3},{4}
  18913. //,{5},{6},{7},{8},{9}
  18914. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  18915. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  18916. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  18917. //);
  18918. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  18919. // }
  18920. // return Ok(JsonView(true, "操作成功!"));
  18921. // }
  18922. /// <summary>
  18923. /// 123132123
  18924. /// </summary>
  18925. /// <param name="_dto"></param>
  18926. /// <returns></returns>
  18927. [HttpPost]
  18928. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18929. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18930. {
  18931. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18932. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  18933. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  18934. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18935. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  18936. dicDetail.Add(789, 1034);
  18937. dicDetail.Add(790, 1035);
  18938. dicDetail.Add(791, 1036);
  18939. dicDetail.Add(792, 1037);
  18940. dicDetail.Add(793, 1038);
  18941. dicDetail.Add(794, 1039);
  18942. dicDetail.Add(795, 1040);
  18943. dicDetail.Add(796, 1041);
  18944. dicDetail.Add(797, 1042);
  18945. dicDetail.Add(798, 1043);
  18946. dicDetail.Add(801, 1044);
  18947. dicDetail.Add(802, 1045);
  18948. dicDetail.Add(803, 1046);
  18949. Dictionary<int, int> dic = new Dictionary<int, int>();
  18950. dic.Add(806, 1027);
  18951. dic.Add(807, 1028);
  18952. dic.Add(808, 1029);
  18953. dic.Add(809, 1030);
  18954. dic.Add(810, 1031);
  18955. dic.Add(811, 1032);
  18956. dic.Add(812, 1033);
  18957. foreach (var item in list_visa)
  18958. {
  18959. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  18960. temp.Coefficient = item.coefficient;
  18961. DateTime dtCrt;
  18962. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  18963. if (b1)
  18964. {
  18965. temp.CreateTime = dtCrt;
  18966. }
  18967. else
  18968. {
  18969. temp.CreateTime = DateTime.Now;
  18970. }
  18971. temp.CreateUserId = item.Operators;
  18972. temp.DeleteTime = "";
  18973. temp.DeleteUserId = 0;
  18974. temp.DiId = int.Parse(item.DIID);
  18975. temp.FilePath = item.FilePath;
  18976. temp.IsDel = item.IsDel;
  18977. temp.Price = item.Price;
  18978. temp.PriceCount = 1;
  18979. temp.PriceCurrency = item.Currency;
  18980. int detailId = 0;
  18981. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  18982. {
  18983. detailId = dicDetail[item.PriceTypeDetail];
  18984. }
  18985. temp.PriceDetailType = detailId;
  18986. temp.PriceDt = DateTime.Now;
  18987. temp.PriceName = item.PriceName;
  18988. temp.PriceSum = item.Price;
  18989. int tid = 0;
  18990. if (dic.ContainsKey(item.PriceType))
  18991. {
  18992. tid = dic[item.PriceType];
  18993. }
  18994. temp.PriceType = tid;
  18995. temp.Remark = item.Remark;
  18996. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  18997. }
  18998. return Ok(JsonView(true, "操作成功!"));
  18999. }
  19000. [HttpPost]
  19001. public IActionResult TimeTest()
  19002. {
  19003. var jw = JsonView(false, "error");
  19004. _sqlSugar.BeginTran();
  19005. try
  19006. {
  19007. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  19008. .Select(x => new Crm_NewClientData
  19009. {
  19010. Id = x.Id,
  19011. Client = x.Client,
  19012. Contact = x.Contact,
  19013. Location = x.Location,
  19014. })
  19015. .ToList();
  19016. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  19017. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  19018. Stopwatch stopwatch = new Stopwatch();
  19019. // 开始计时
  19020. stopwatch.Start();
  19021. foreach (var item in clientList)
  19022. {
  19023. EncryptionProcessor.DecryptProperties(item);
  19024. }
  19025. stopwatch.Stop();
  19026. jw.Code = 200;
  19027. jw.Data = stopwatch.ElapsedMilliseconds;
  19028. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  19029. }
  19030. catch (Exception ex)
  19031. {
  19032. jw.Code = 400;
  19033. jw.Msg = ex.Message;
  19034. }
  19035. return Ok(jw);
  19036. }
  19037. }
  19038. }