GroupsController.cs 1002 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using Microsoft.AspNetCore.SignalR;
  7. using Microsoft.EntityFrameworkCore.Query.Internal;
  8. using NPOI.HSSF.UserModel;
  9. using NPOI.SS.UserModel;
  10. using NPOI.SS.Util;
  11. using NPOI.XSSF.UserModel;
  12. using OASystem.API.Middlewares;
  13. using OASystem.API.OAMethodLib;
  14. using OASystem.API.OAMethodLib.APNs;
  15. using OASystem.API.OAMethodLib.File;
  16. using OASystem.API.OAMethodLib.Hub.HubClients;
  17. using OASystem.API.OAMethodLib.Hub.Hubs;
  18. using OASystem.API.OAMethodLib.JuHeAPI;
  19. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  20. using OASystem.Domain.AesEncryption;
  21. using OASystem.Domain.Dtos.CRM;
  22. using OASystem.Domain.Dtos.FileDto;
  23. using OASystem.Domain.Dtos.Financial;
  24. using OASystem.Domain.Dtos.Groups;
  25. using OASystem.Domain.Entities.Customer;
  26. using OASystem.Domain.Entities.Financial;
  27. using OASystem.Domain.Entities.Groups;
  28. using OASystem.Domain.ViewModels.Financial;
  29. using OASystem.Domain.ViewModels.Groups;
  30. using OASystem.Infrastructure.Repositories.CRM;
  31. using OASystem.Infrastructure.Repositories.Financial;
  32. using OASystem.Infrastructure.Repositories.Groups;
  33. using OfficeOpenXml;
  34. using Org.BouncyCastle.Asn1.Ocsp;
  35. using Org.BouncyCastle.Utilities.Encoders;
  36. using Quartz.Util;
  37. using SqlSugar.Extensions;
  38. using System.Collections;
  39. using System.Data;
  40. using System.Diagnostics;
  41. using System.Globalization;
  42. using System.IO.Compression;
  43. using static OASystem.API.OAMethodLib.JWTHelper;
  44. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  45. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  46. using Bookmark = Aspose.Words.Bookmark;
  47. using Cell = Aspose.Words.Tables.Cell;
  48. using Table = Aspose.Words.Tables.Table;
  49. namespace OASystem.API.Controllers
  50. {
  51. /// <summary>
  52. /// 团组相关
  53. /// </summary>
  54. //[Authorize]
  55. [Route("api/[controller]/[action]")]
  56. public class GroupsController : ControllerBase
  57. {
  58. private readonly ILogger<GroupsController> _logger;
  59. private readonly GrpScheduleRepository _grpScheduleRep;
  60. private readonly IMapper _mapper;
  61. private readonly DelegationInfoRepository _groupRepository;
  62. private readonly TaskAssignmentRepository _taskAssignmentRep;
  63. private readonly AirTicketResRepository _airTicketResRep;
  64. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  65. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  66. private readonly DelegationEnDataRepository _delegationEnDataRep;
  67. private readonly DelegationVisaRepository _delegationVisaRep;
  68. private readonly VisaPriceRepository _visaPriceRep;
  69. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  70. private readonly HotelPriceRepository _hotelPriceRep;
  71. private readonly CustomersRepository _customersRep;
  72. private readonly MessageRepository _message;
  73. private readonly SqlSugarClient _sqlSugar;
  74. private readonly TourClientListRepository _tourClientListRep;
  75. private readonly TeamRateRepository _teamRateRep;
  76. #region 成本相关
  77. private readonly CheckBoxsRepository _checkBoxs;
  78. private readonly GroupCostRepository _GroupCostRepository;
  79. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  80. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  81. #endregion
  82. private readonly SetDataRepository _setDataRep;
  83. private string url;
  84. private string path;
  85. private readonly EnterExitCostRepository _enterExitCostRep;
  86. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  87. private readonly UsersRepository _usersRep;
  88. private readonly IJuHeApiService _juHeApi;
  89. private readonly InvertedListRepository _invertedListRep;
  90. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  91. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  92. private readonly ThreeCodeRepository _threeCodeRepository;
  93. private readonly HotelInquiryRepository _hotelInquiryRep;
  94. private readonly FeeAuditRepository _feeAuditRep;
  95. private readonly VisaCommissionRepository _visaCommissionRep;
  96. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  97. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  98. private readonly List<CurrencyInfo> _currencyInit;
  99. private readonly List<int> _portTypeData;
  100. private readonly TableOperationRecordRepository _tableorRep;
  101. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  102. private readonly RestaurantRepository _restaurantRep;
  103. /// <summary>
  104. /// 构造函数
  105. /// </summary>
  106. /// <param name="logger"></param>
  107. /// <param name="mapper"></param>
  108. /// <param name="hubContext"></param>
  109. /// <param name="sqlSugar"></param>
  110. /// <param name="grpScheduleRep"></param>
  111. /// <param name="groupRepository"></param>
  112. /// <param name="taskAssignmentRep"></param>
  113. /// <param name="airTicketResRep"></param>
  114. /// <param name="decreasePaymentsRep"></param>
  115. /// <param name="InvitationOfficialActivitiesRep"></param>
  116. /// <param name="delegationEnDataRep"></param>
  117. /// <param name="enterExitCostRep"></param>
  118. /// <param name="delegationVisaRep"></param>
  119. /// <param name="message"></param>
  120. /// <param name="visaPriceRep"></param>
  121. /// <param name="carTouristGuideGroundRep"></param>
  122. /// <param name="checkBoxs"></param>
  123. /// <param name="GroupCostRepository"></param>
  124. /// <param name="CostTypeHotelNumberRepository"></param>
  125. /// <param name="GroupCostParameterRepository"></param>
  126. /// <param name="hotelPriceRep"></param>
  127. /// <param name="customersRep"></param>
  128. /// <param name="setDataRep"></param>
  129. /// <param name="tourClientListRep"></param>
  130. /// <param name="teamRateRep"></param>
  131. /// <param name="usersRep"></param>
  132. /// <param name="juHeApi"></param>
  133. /// <param name="invertedListRep"></param>
  134. /// <param name="visaFeeInfoRep"></param>
  135. /// <param name="ticketBlackCodeRep"></param>
  136. /// <param name="hotelInquiryRep"></param>
  137. /// <param name="threeCodeRepository"></param>
  138. /// <param name="feeAuditRep"></param>
  139. /// <param name="visaCommissionRep"></param>
  140. /// <param name="ffrRep"></param>
  141. /// <param name="opinionaireRep"></param>
  142. /// <param name="tableorRep"></param>
  143. /// <param name="enterExitCostDraftRep"></param>
  144. /// <param name="restaurantRep"></param>
  145. public GroupsController(
  146. ILogger<GroupsController> logger,
  147. IMapper mapper,
  148. IHubContext<ChatHub, IChatClient> hubContext,
  149. SqlSugarClient sqlSugar,
  150. GrpScheduleRepository grpScheduleRep,
  151. DelegationInfoRepository groupRepository,
  152. TaskAssignmentRepository taskAssignmentRep,
  153. AirTicketResRepository airTicketResRep,
  154. DecreasePaymentsRepository decreasePaymentsRep,
  155. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  156. DelegationEnDataRepository delegationEnDataRep,
  157. EnterExitCostRepository enterExitCostRep,
  158. DelegationVisaRepository delegationVisaRep,
  159. MessageRepository message,
  160. VisaPriceRepository visaPriceRep,
  161. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  162. CheckBoxsRepository checkBoxs,
  163. GroupCostRepository GroupCostRepository,
  164. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  165. GroupCostParameterRepository GroupCostParameterRepository,
  166. HotelPriceRepository hotelPriceRep,
  167. CustomersRepository customersRep,
  168. SetDataRepository setDataRep,
  169. TourClientListRepository tourClientListRep,
  170. TeamRateRepository teamRateRep,
  171. UsersRepository usersRep, IJuHeApiService juHeApi,
  172. InvertedListRepository invertedListRep,
  173. VisaFeeInfoRepository visaFeeInfoRep,
  174. TicketBlackCodeRepository ticketBlackCodeRep,
  175. HotelInquiryRepository hotelInquiryRep,
  176. ThreeCodeRepository threeCodeRepository,
  177. FeeAuditRepository feeAuditRep,
  178. VisaCommissionRepository visaCommissionRep,
  179. ForeignReceivablesRepository ffrRep,
  180. OpinionaireRepository opinionaireRep,
  181. TableOperationRecordRepository tableorRep,
  182. EnterExitCostDraftRepository enterExitCostDraftRep,
  183. RestaurantRepository restaurantRep
  184. )
  185. {
  186. _logger = logger;
  187. _mapper = mapper;
  188. _grpScheduleRep = grpScheduleRep;
  189. _groupRepository = groupRepository;
  190. _taskAssignmentRep = taskAssignmentRep;
  191. _airTicketResRep = airTicketResRep;
  192. _sqlSugar = sqlSugar;
  193. url = AppSettingsHelper.Get("ExcelBaseUrl");
  194. path = AppSettingsHelper.Get("ExcelBasePath");
  195. if (!System.IO.Directory.Exists(path))
  196. {
  197. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  198. }
  199. _decreasePaymentsRep = decreasePaymentsRep;
  200. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  201. _delegationEnDataRep = delegationEnDataRep;
  202. _enterExitCostRep = enterExitCostRep;
  203. _delegationVisaRep = delegationVisaRep;
  204. _message = message;
  205. _visaPriceRep = visaPriceRep;
  206. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  207. _checkBoxs = checkBoxs;
  208. _GroupCostRepository = GroupCostRepository;
  209. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  210. _GroupCostParameterRepository = GroupCostParameterRepository;
  211. _hotelPriceRep = hotelPriceRep;
  212. _customersRep = customersRep;
  213. _setDataRep = setDataRep;
  214. _tourClientListRep = tourClientListRep;
  215. _teamRateRep = teamRateRep;
  216. _hubContext = hubContext;
  217. _usersRep = usersRep;
  218. _juHeApi = juHeApi;
  219. _invertedListRep = invertedListRep;
  220. _visaFeeInfoRep = visaFeeInfoRep;
  221. _ticketBlackCodeRep = ticketBlackCodeRep;
  222. _hotelInquiryRep = hotelInquiryRep;
  223. _threeCodeRepository = threeCodeRepository;
  224. _feeAuditRep = feeAuditRep;
  225. _visaCommissionRep = visaCommissionRep;
  226. _ffrRep = ffrRep;
  227. _opinionaireRep = opinionaireRep;
  228. _currencyInit = new List<CurrencyInfo>()
  229. {
  230. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  231. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  232. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  233. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  234. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  235. };
  236. _portTypeData = new List<int>() { 2, 3 };
  237. _tableorRep = tableorRep;
  238. _enterExitCostDraftRep = enterExitCostDraftRep;
  239. _restaurantRep = restaurantRep;
  240. }
  241. #region 流程管控
  242. /// <summary>
  243. /// 获取团组流程管控信息
  244. /// </summary>
  245. /// <param name="paras">参数Json字符串</param>
  246. /// <returns></returns>
  247. [HttpPost]
  248. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  249. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  250. {
  251. if (string.IsNullOrEmpty(_jsonDto.Paras))
  252. {
  253. return Ok(JsonView(false, "参数为空"));
  254. }
  255. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  256. if (_ScheduleDto != null)
  257. {
  258. if (_ScheduleDto.SearchType == 2)//获取列表
  259. {
  260. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  261. return Ok(JsonView(_grpScheduleViewList));
  262. }
  263. else//获取对象
  264. {
  265. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  266. if (_grpScheduleView != null)
  267. {
  268. return Ok(JsonView(_grpScheduleView));
  269. }
  270. }
  271. }
  272. else
  273. {
  274. return Ok(JsonView(false, "参数反序列化失败"));
  275. }
  276. return Ok(JsonView(false, "暂无数据!"));
  277. }
  278. /// <summary>
  279. /// 修改团组流程管控详细表数据
  280. /// </summary>
  281. /// <param name="paras"></param>
  282. /// <returns></returns>
  283. [HttpPost]
  284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  285. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  286. {
  287. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  288. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  289. .SetColumns(it => it.Duty == _detail.Duty)
  290. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  291. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  292. .SetColumns(it => it.JobContent == _detail.JobContent)
  293. .SetColumns(it => it.Remark == _detail.Remark)
  294. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  295. .Where(s => s.Id == dto.Id)
  296. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  297. .ExecuteCommandAsync();
  298. if (result > 0)
  299. {
  300. return Ok(JsonView(true, "保存成功!"));
  301. }
  302. return Ok(JsonView(false, "保存失败!"));
  303. }
  304. /// <summary>
  305. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  306. /// </summary>
  307. /// <param name="dto"></param>
  308. /// <returns></returns>
  309. [HttpPost]
  310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  311. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  312. {
  313. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  314. _detail.IsDel = 1;
  315. _detail.DeleteUserId = dto.Duty;
  316. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  317. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  318. .SetColumns(it => it.IsDel == _detail.IsDel)
  319. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  320. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  321. .Where(it => it.Id == dto.Id)
  322. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  323. //.WhereColumns(s => s.Id == dto.Id)
  324. .ExecuteCommandAsync();
  325. if (result > 0)
  326. {
  327. return Ok(JsonView(true, "删除成功!"));
  328. }
  329. return Ok(JsonView(false, "删除失败!"));
  330. }
  331. /// <summary>
  332. /// 增加团组流程管控详细表数据
  333. /// </summary>
  334. /// <param name="dto"></param>
  335. /// <returns></returns>
  336. [HttpPost]
  337. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  338. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  339. {
  340. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  341. if (DateTime.Now < _detail.ExpectBeginDt)
  342. {
  343. _detail.StepStatus = 0;
  344. }
  345. else
  346. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  347. _detail.StepStatus = 1;
  348. }
  349. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  350. if (result > 0)
  351. {
  352. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  353. return Ok(JsonView(true, "添加成功!", _result));
  354. }
  355. return Ok(JsonView(false, "添加失败!"));
  356. }
  357. #endregion
  358. #region 团组基本信息
  359. /// <summary>
  360. /// 接团信息列表
  361. /// </summary>
  362. /// <param name="dto">团组列表请求dto</param>
  363. /// <returns></returns>
  364. [HttpPost]
  365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  366. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  367. {
  368. var groupData = await _groupRepository.GetGroupList(dto);
  369. if (groupData.Code != 0)
  370. {
  371. return Ok(JsonView(false, groupData.Msg));
  372. }
  373. return Ok(JsonView(groupData.Data));
  374. }
  375. /// <summary>
  376. /// 分页查询团组列表
  377. /// </summary>
  378. /// <param name="dto"></param>
  379. /// <returns></returns>
  380. [HttpPost]
  381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  382. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  383. {
  384. var watch = new Stopwatch();
  385. watch.Start();
  386. RefAsync<int> total = 0;
  387. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  388. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  389. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  390. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  391. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  392. .Distinct()
  393. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  394. watch.Stop();
  395. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  396. }
  397. /// <summary>
  398. /// 接团信息列表 Page
  399. /// </summary>
  400. /// <param name="dto">团组列表请求dto</param>
  401. /// <returns></returns>
  402. [HttpPost]
  403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  404. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  405. {
  406. #region 参数验证
  407. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  408. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  409. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  410. #region 页面操作权限验证
  411. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  412. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  413. #endregion
  414. #endregion
  415. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  416. {
  417. string sqlWhere = string.Empty;
  418. if (dto.IsSure == 0) //未完成
  419. {
  420. sqlWhere += string.Format(@" And IsSure = 0");
  421. }
  422. else if (dto.IsSure == 1) //已完成
  423. {
  424. sqlWhere += string.Format(@" And IsSure = 1");
  425. }
  426. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  427. {
  428. string tj = dto.SearchCriteria;
  429. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  430. tj, tj, tj, tj, tj);
  431. }
  432. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  433. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  434. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  435. JietuanOperator,IsSure,CreateTime,IsBid
  436. From (
  437. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  438. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  439. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  440. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  441. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  442. From Grp_DelegationInfo gdi
  443. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  444. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  445. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  446. Where gdi.IsDel = 0 {0}
  447. ) temp", sqlWhere);
  448. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  449. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  450. #region 处理所属部门
  451. /*
  452. * 1.sq 和 gyy 等显示 市场部
  453. * 2.王鸽和主管及张总还有管理员号统一国交部
  454. * 2-1. 4 管理员 ,21 张海麟
  455. */
  456. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  457. List<int> userIds1 = new List<int>() { 4, 21 };
  458. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  459. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  460. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  461. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  462. .ToList();
  463. foreach (var item in _DelegationList)
  464. {
  465. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  466. }
  467. #endregion
  468. var _view = new
  469. {
  470. PageFuncAuth = pageFunAuthView,
  471. Data = _DelegationList
  472. };
  473. return Ok(JsonView(true, "查询成功!", _view, total));
  474. }
  475. else
  476. {
  477. return Ok(JsonView(false, "查询失败"));
  478. }
  479. }
  480. /// <summary>
  481. /// 团组列表
  482. /// </summary>
  483. /// <returns></returns>
  484. [HttpPost]
  485. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  486. {
  487. #region 参数验证
  488. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  489. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  490. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  491. #region 页面操作权限验证
  492. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  493. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  494. #endregion
  495. #endregion
  496. if (dto.PortType != 1 && dto.PortType != 2)
  497. {
  498. return Ok(JsonView(false, "查询失败!"));
  499. }
  500. string orderbyStr = "order by gdi.CreateTime Desc";
  501. string sqlWhere = string.Empty;
  502. if (dto.IsSure == 0) //未完成
  503. {
  504. sqlWhere += string.Format(@" And IsSure = 0");
  505. }
  506. else if (dto.IsSure == 1) //已完成
  507. {
  508. sqlWhere += string.Format(@" And IsSure = 1");
  509. }
  510. //团组类型
  511. if (dto.TeamDid > 0)
  512. {
  513. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  514. }
  515. //团组名称
  516. if (!string.IsNullOrEmpty(dto.TeamName))
  517. {
  518. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  519. }
  520. //客户名称
  521. if (!string.IsNullOrEmpty(dto.ClientName))
  522. {
  523. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  524. }
  525. //客户单位
  526. if (!string.IsNullOrEmpty(dto.ClientUnit))
  527. {
  528. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  529. }
  530. //出访时间
  531. if (!string.IsNullOrEmpty(dto.visitDataTime))
  532. {
  533. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  534. orderbyStr = "order by gdi.VisitDate";
  535. }
  536. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  537. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  538. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  539. JietuanOperator,IsSure,CreateTime
  540. From (
  541. Select row_number() over({0}) as Row_Number,
  542. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  543. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  544. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  545. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  546. From Grp_DelegationInfo gdi
  547. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  548. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  549. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  550. Where gdi.IsDel = 0 {1}
  551. ) temp ", orderbyStr, sqlWhere);
  552. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  553. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  554. #region 处理所属部门
  555. /*
  556. * 1.sq 和 gyy 等显示 市场部
  557. * 2.王鸽和主管及张总还有管理员号统一国交部
  558. * 2-1. 4 管理员 ,21 张海麟
  559. */
  560. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  561. List<int> userIds1 = new List<int>() { 4, 21 };
  562. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  563. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  564. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  565. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  566. .ToList();
  567. foreach (var item in _DelegationList)
  568. {
  569. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  570. }
  571. #endregion
  572. var _view = new
  573. {
  574. PageFuncAuth = pageFunAuthView,
  575. Data = _DelegationList
  576. };
  577. return Ok(JsonView(true, "查询成功!", _view, total));
  578. }
  579. /// <summary>
  580. /// 接团信息详情
  581. /// </summary>
  582. /// <param name="dto">团组info请求dto</param>
  583. /// <returns></returns>
  584. [HttpPost]
  585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  586. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  587. {
  588. var groupData = await _groupRepository.GetGroupInfo(dto);
  589. if (groupData.Code != 0)
  590. {
  591. return Ok(JsonView(false, groupData.Msg));
  592. }
  593. return Ok(JsonView(groupData.Data));
  594. }
  595. /// <summary>
  596. /// 接团信息 编辑添加
  597. /// 基础信息数据源
  598. /// </summary>
  599. /// <param name="dto"></param>
  600. /// <returns></returns>
  601. [HttpPost]
  602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  603. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  604. {
  605. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  606. if (groupData.Code != 0)
  607. {
  608. return Ok(JsonView(false, groupData.Msg));
  609. }
  610. return Ok(JsonView(groupData.Data));
  611. }
  612. /// <summary>
  613. /// 接团信息 操作(增改)
  614. /// </summary>
  615. /// <param name="dto"></param>
  616. /// <returns></returns>
  617. [HttpPost]
  618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  619. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  620. {
  621. // 创建 Stopwatch 实例
  622. Stopwatch stopwatch = Stopwatch.StartNew();
  623. decimal ffrPrice = 0.00M;
  624. DateTime? visitDt = null;
  625. if (dto.Status == 2)
  626. {
  627. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  628. if (groupInfo != null)
  629. {
  630. ffrPrice = groupInfo.PaymentMoney;
  631. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  632. }
  633. }
  634. var groupData = await _groupRepository.GroupOperation(dto);
  635. if (groupData.Code != 0)
  636. {
  637. return Ok(JsonView(false, groupData.Msg));
  638. }
  639. int diId = 0;
  640. try
  641. {
  642. //添加时 默认加入团组汇率
  643. if (dto.Status == 1) //添加
  644. {
  645. diId = groupData.Data;
  646. //添加默认币种
  647. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  648. //默认分配权限
  649. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  650. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  651. var _managerIds = new List<int>() { 22, 32, 21 };
  652. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  653. if (userIds.Count > 0)
  654. {
  655. userIds.Add(208);
  656. //创建团组管控
  657. GroupStepForDelegation.CreateWorkStep(diId);
  658. //发送消息
  659. string groupName = dto.TeamName;
  660. string createGroupUser = string.Empty;
  661. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  662. if (userInfo != null) createGroupUser = userInfo.CnName;
  663. string title = $"系统通知";
  664. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  665. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  666. }
  667. //默认创建倒推表
  668. await _invertedListRep._Create(dto.UserId, diId);
  669. }
  670. else if (dto.Status == 2)
  671. {
  672. diId = dto.Id;
  673. }
  674. #region 签证人员团组时间通知
  675. #region 计算出访起止时间
  676. var startTime = new DateTime();
  677. var endTime = new DateTime();
  678. if (DateTime.TryParse(dto.VisitDate, out startTime))
  679. {
  680. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  681. }
  682. #endregion
  683. #endregion
  684. #region 团组操作默认添加/修改收款账单
  685. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  686. {
  687. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  688. .Where(x => x.IsDel == 0 &&
  689. x.Diid == diId &&
  690. x.Remark.Equals("预付款")
  691. )
  692. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  693. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  694. .FirstAsync();
  695. ffrInfo = new Fin_ForeignReceivables()
  696. {
  697. Diid = diId,
  698. PriceName = dto.ClientUnit,
  699. Price = dto.PaymentMoney,
  700. Count = 1,
  701. Unit = $"元",
  702. ItemSumPrice = dto.PaymentMoney,
  703. Rate = 1.0000M,
  704. Currency = 836,
  705. AddingWay = 0,
  706. CreateUserId = dto.UserId,
  707. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  708. Remark = $"预付款"
  709. };
  710. if (ffrInfo == null) //Add
  711. {
  712. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  713. }
  714. else //修改
  715. {
  716. await _sqlSugar.Updateable(ffrInfo)
  717. .UpdateColumns(x => new
  718. {
  719. x.PriceName,
  720. x.Price,
  721. x.ItemSumPrice,
  722. x.CreateTime,
  723. x.CreateUserId
  724. })
  725. .WhereColumns(x => x.Id)
  726. .ExecuteCommandAsync();
  727. }
  728. }
  729. #endregion
  730. if (diId > 0)
  731. {
  732. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  733. }
  734. // 停止计时
  735. stopwatch.Stop();
  736. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  737. }
  738. catch (Exception ex)
  739. {
  740. // 停止计时
  741. stopwatch.Stop();
  742. Logs("[response]" + JsonConvert.SerializeObject(dto));
  743. Logs(ex.Message);
  744. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  745. }
  746. // 停止计时
  747. stopwatch.Stop();
  748. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  749. }
  750. /// <summary>
  751. /// 接团流程操作(增改)
  752. /// 安卓端使用 建团时添加客户名单
  753. /// </summary>
  754. /// <param name="dto"></param>
  755. /// <returns></returns>
  756. [HttpPost]
  757. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  758. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  759. {
  760. #region 参数验证
  761. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  762. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  763. #region 页面操作权限验证
  764. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  765. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  766. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  767. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  768. #endregion
  769. #endregion
  770. try
  771. {
  772. //_sqlSugar.BeginTran();
  773. decimal ffrPrice = 0.00M;
  774. DateTime? visitDt = null;
  775. if (dto.Status == 2)
  776. {
  777. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  778. if (groupInfo != null)
  779. {
  780. ffrPrice = groupInfo.PaymentMoney;
  781. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  782. }
  783. }
  784. var _dto = new GroupOperationDto();
  785. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  786. var groupData = await _groupRepository.GroupOperation(_dto);
  787. if (groupData.Code != 0)
  788. {
  789. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  790. }
  791. int diId = 0;
  792. //添加时 默认加入团组汇率
  793. if (dto.Status == 1) //添加
  794. {
  795. diId = groupData.Data;
  796. //添加默认币种
  797. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  798. //默认分配权限
  799. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  800. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  801. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  802. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  803. if (userIds.Count > 0)
  804. {
  805. userIds.Add(208);
  806. //创建团组管控
  807. GroupStepForDelegation.CreateWorkStep(diId);
  808. //发送消息
  809. string groupName = dto.TeamName;
  810. string createGroupUser = string.Empty;
  811. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  812. if (userInfo != null) createGroupUser = userInfo.CnName;
  813. string title = $"系统通知";
  814. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  815. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  816. }
  817. #region 应用推送
  818. try
  819. {
  820. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  821. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  822. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  823. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  824. {
  825. List<string> userList = new List<string>() { users.QiyeChatUserId };
  826. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  827. }
  828. }
  829. catch (Exception ex)
  830. {
  831. }
  832. #endregion
  833. //默认创建倒推表
  834. await _invertedListRep._Create(dto.UserId, diId);
  835. }
  836. if (dto.Status == 2)
  837. {
  838. diId = dto.Id;
  839. if (diId == 0)
  840. {
  841. //_sqlSugar.RollbackTran();
  842. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  843. }
  844. }
  845. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  846. if (viewData.Code != 0)
  847. {
  848. //_sqlSugar.RollbackTran();
  849. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  850. }
  851. #region 团组操作默认添加/修改收款账单
  852. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  853. {
  854. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  855. .Where(x => x.IsDel == 0 &&
  856. x.Diid == diId &&
  857. x.Remark.Equals("预付款")
  858. )
  859. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  860. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  861. .FirstAsync();
  862. ffrInfo = new Fin_ForeignReceivables()
  863. {
  864. Diid = diId,
  865. PriceName = dto.ClientUnit,
  866. Price = dto.PaymentMoney,
  867. Count = 1,
  868. Unit = $"元",
  869. ItemSumPrice = dto.PaymentMoney,
  870. Rate = 1.0000M,
  871. Currency = 836,
  872. AddingWay = 0,
  873. CreateUserId = dto.UserId,
  874. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  875. Remark = $"预付款"
  876. };
  877. if (ffrInfo == null) //Add
  878. {
  879. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  880. }
  881. else //修改
  882. {
  883. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  884. .UpdateColumns(x => new
  885. {
  886. x.PriceName,
  887. x.Price,
  888. x.ItemSumPrice,
  889. x.CreateTime,
  890. x.CreateUserId
  891. })
  892. .WhereColumns(x => x.Id)
  893. .ExecuteCommandAsync();
  894. }
  895. }
  896. #endregion
  897. #region 签证人员团组时间通知
  898. #region 计算出访起止时间
  899. var startTime = new DateTime();
  900. var endTime = new DateTime();
  901. if (DateTime.TryParse(dto.VisitDate, out startTime))
  902. {
  903. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  904. }
  905. #endregion
  906. if (diId > 0)
  907. {
  908. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  909. }
  910. #endregion
  911. //_sqlSugar.CommitTran();
  912. return Ok(JsonView(true, "添加成功"));
  913. }
  914. catch (Exception ex)
  915. {
  916. _sqlSugar.RollbackTran();
  917. return Ok(JsonView(false, ex.Message));
  918. }
  919. }
  920. /// <summary>
  921. /// 接团流程操作(增改)
  922. /// 安卓端使用 建团时添加客户名单
  923. /// </summary>
  924. /// <param name="dto"></param>
  925. /// <returns></returns>
  926. [HttpPost]
  927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  928. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  929. {
  930. #region 参数验证
  931. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  932. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  933. #region 页面操作权限验证
  934. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  935. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  936. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  937. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  938. #endregion
  939. #endregion
  940. _sqlSugar.BeginTran();
  941. decimal ffrPrice = 0.00M;
  942. DateTime? visitDt = null;
  943. if (dto.Status == 2)
  944. {
  945. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  946. if (groupInfo != null)
  947. {
  948. ffrPrice = groupInfo.PaymentMoney;
  949. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  950. }
  951. }
  952. var _dto = new GroupOperationDto();
  953. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  954. var groupData = await _groupRepository.GroupOperation(_dto);
  955. if (groupData.Code != 0)
  956. {
  957. _sqlSugar.RollbackTran();
  958. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  959. }
  960. try
  961. {
  962. int diId = 0;
  963. //添加时 默认加入团组汇率
  964. if (dto.Status == 1) //添加
  965. {
  966. diId = groupData.Data;
  967. //添加默认币种
  968. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  969. //默认分配权限
  970. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  971. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  972. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  973. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  974. if (userIds.Count > 0)
  975. {
  976. userIds.Add(208);
  977. //创建团组管控
  978. GroupStepForDelegation.CreateWorkStep(diId);
  979. //发送消息
  980. string groupName = dto.TeamName;
  981. string createGroupUser = string.Empty;
  982. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  983. if (userInfo != null) createGroupUser = userInfo.CnName;
  984. string title = $"系统通知";
  985. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  986. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  987. }
  988. #region 应用推送
  989. try
  990. {
  991. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  992. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  993. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  994. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  995. {
  996. List<string> userList = new List<string>() { users.QiyeChatUserId };
  997. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  998. }
  999. }
  1000. catch (Exception ex)
  1001. {
  1002. _sqlSugar.CommitTran();
  1003. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1004. }
  1005. #endregion
  1006. //默认创建倒推表
  1007. await _invertedListRep._Create(dto.UserId, diId);
  1008. }
  1009. else if (dto.Status == 2)
  1010. {
  1011. diId = dto.Id;
  1012. if (diId == 0)
  1013. {
  1014. _sqlSugar.RollbackTran();
  1015. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1016. }
  1017. }
  1018. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1019. if (viewData.Code != 0)
  1020. {
  1021. _sqlSugar.RollbackTran();
  1022. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1023. }
  1024. #region 团组操作默认添加/修改收款账单
  1025. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1026. {
  1027. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1028. .Where(x => x.IsDel == 0 &&
  1029. x.Diid == diId &&
  1030. x.Remark.Equals("预付款")
  1031. )
  1032. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1033. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1034. .FirstAsync();
  1035. ffrInfo = new Fin_ForeignReceivables()
  1036. {
  1037. Diid = diId,
  1038. PriceName = dto.ClientUnit,
  1039. Price = dto.PaymentMoney,
  1040. Count = 1,
  1041. Unit = $"元",
  1042. ItemSumPrice = dto.PaymentMoney,
  1043. Rate = 1.0000M,
  1044. Currency = 836,
  1045. AddingWay = 0,
  1046. CreateUserId = dto.UserId,
  1047. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1048. Remark = $"预付款"
  1049. };
  1050. if (ffrInfo == null) //Add
  1051. {
  1052. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1053. }
  1054. else //修改
  1055. {
  1056. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1057. .UpdateColumns(x => new
  1058. {
  1059. x.PriceName,
  1060. x.Price,
  1061. x.ItemSumPrice,
  1062. x.CreateTime,
  1063. x.CreateUserId
  1064. })
  1065. .WhereColumns(x => x.Id)
  1066. .ExecuteCommandAsync();
  1067. }
  1068. }
  1069. #endregion
  1070. #region 签证人员团组时间通知
  1071. #region 计算出访起止时间
  1072. var startTime = new DateTime();
  1073. var endTime = new DateTime();
  1074. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1075. {
  1076. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1077. }
  1078. #endregion
  1079. if (diId > 0)
  1080. {
  1081. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1082. }
  1083. #endregion
  1084. _sqlSugar.CommitTran();
  1085. return Ok(JsonView(true));
  1086. }
  1087. catch (Exception ex)
  1088. {
  1089. _sqlSugar.RollbackTran();
  1090. return Ok(JsonView(false, ex.Message));
  1091. }
  1092. }
  1093. /// <summary>
  1094. /// 接团信息 操作(删除)
  1095. /// </summary>
  1096. /// <param name="dto"></param>
  1097. /// <returns></returns>
  1098. [HttpPost]
  1099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1100. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1101. {
  1102. var diId = dto.Id;
  1103. if (diId < 1) return Ok(JsonView(false,MsgTips.Id));
  1104. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1105. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1106. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1107. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1108. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1109. #endregion
  1110. var groupData = await _groupRepository.GroupDel(dto);
  1111. if (groupData.Code != 0)
  1112. {
  1113. return Ok(JsonView(false, groupData.Msg));
  1114. }
  1115. return Ok(JsonView(true));
  1116. }
  1117. /// <summary>
  1118. /// 获取团组销售报价号
  1119. /// 团组添加时 使用
  1120. /// </summary>
  1121. /// <returns></returns>
  1122. [HttpPost]
  1123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1124. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1125. {
  1126. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1127. if (groupData.Code != 0)
  1128. {
  1129. return Ok(JsonView(false, groupData.Msg));
  1130. }
  1131. object salesQuoteNo = new
  1132. {
  1133. SalesQuoteNo = groupData.Data
  1134. };
  1135. return Ok(JsonView(salesQuoteNo));
  1136. }
  1137. /// <summary>
  1138. /// 设置确认出团
  1139. /// </summary>
  1140. /// <param name="dto"></param>
  1141. /// <returns></returns>
  1142. [HttpPost]
  1143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1144. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1145. {
  1146. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1147. if (groupData.Code != 0)
  1148. {
  1149. return Ok(JsonView(false, groupData.Msg));
  1150. }
  1151. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1152. #region OA消息推送
  1153. try
  1154. {
  1155. string groupName = groupInfo.TeamName;
  1156. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1157. string title = $"系统通知";
  1158. string content = $"团组[{groupName}]已确认出团!";
  1159. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1160. }
  1161. catch (Exception ex)
  1162. {
  1163. }
  1164. #endregion
  1165. #region 应用推送
  1166. try
  1167. {
  1168. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1169. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1170. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1171. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1172. {
  1173. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1174. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1175. }
  1176. }
  1177. catch (Exception ex)
  1178. {
  1179. }
  1180. #endregion
  1181. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1182. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1183. }
  1184. /// <summary>
  1185. /// 获取团组名称data And 签证国别Data
  1186. /// </summary>
  1187. /// <param name="dto"></param>
  1188. /// <returns></returns>
  1189. [HttpPost]
  1190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1191. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1192. {
  1193. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1194. if (groupData.Code != 0)
  1195. {
  1196. return Ok(JsonView(false, groupData.Msg));
  1197. }
  1198. return Ok(JsonView(groupData.Data));
  1199. }
  1200. /// <summary>
  1201. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1202. /// </summary>
  1203. /// <returns></returns>
  1204. [HttpPost]
  1205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1206. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1207. {
  1208. try
  1209. {
  1210. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1211. if (groupData.Code != 0)
  1212. {
  1213. return Ok(JsonView(false, groupData.Msg));
  1214. }
  1215. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1216. }
  1217. catch (Exception ex)
  1218. {
  1219. return Ok(JsonView(false, "程序错误!"));
  1220. throw;
  1221. }
  1222. }
  1223. /// <summary>
  1224. /// 团组清单 Excel
  1225. /// </summary>
  1226. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1227. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1228. /// <returns></returns>
  1229. [HttpGet]
  1230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1231. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1232. {
  1233. DateTime _beginDt, _endDt;
  1234. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1235. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1236. if (!beginBool && !endBool)
  1237. {
  1238. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1239. }
  1240. string sql = string.Format(@"
  1241. SELECT
  1242. ROW_NUMBER,
  1243. Id,
  1244. SalesQuoteNo,
  1245. TourCode,
  1246. TeamTypeId,
  1247. TeamType,
  1248. TeamLevId,
  1249. TeamLev,
  1250. TeamName,
  1251. ClientName,
  1252. ClientUnit,
  1253. VisitDate,
  1254. VisitDays,
  1255. VisitPNumber,
  1256. JietuanOperatorId,
  1257. JietuanOperator,
  1258. IsSure,
  1259. CreateUserName,
  1260. IsBid
  1261. FROM
  1262. (
  1263. SELECT
  1264. ROW_NUMBER() OVER(
  1265. ORDER BY
  1266. gdi.CreateTime Desc
  1267. ) AS ROW_NUMBER,
  1268. gdi.Id,
  1269. SalesQuoteNo,
  1270. TourCode,
  1271. ssd.Id TeamTypeId,
  1272. ssd.Name TeamType,
  1273. ssd1.Id TeamLevId,
  1274. ssd1.Name TeamLev,
  1275. TeamName,
  1276. ClientName,
  1277. ClientUnit,
  1278. VisitDate,
  1279. VisitDays,
  1280. VisitPNumber,
  1281. JietuanOperator JietuanOperatorId,
  1282. su.CnName JietuanOperator,
  1283. IsSure,
  1284. gdi.CreateTime,
  1285. su1.CnName As CreateUserName,
  1286. gdi.IsBid
  1287. FROM
  1288. Grp_DelegationInfo gdi
  1289. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1290. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1291. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1292. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1293. WHERE
  1294. gdi.IsDel = 0
  1295. AND gdi.IsBid = 0
  1296. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1297. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1298. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1299. #region 处理所属部门
  1300. /*
  1301. * 1.sq 和 gyy 等显示 市场部
  1302. * 2.王鸽和主管及张总还有管理员号统一国交部
  1303. * 2-1. 4 管理员 ,21 张海麟
  1304. */
  1305. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1306. List<int> userIds1 = new List<int>() { 4, 21 };
  1307. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1308. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1309. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1310. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1311. .ToListAsync();
  1312. var droupIds = groupList.Select(it => it.Id).ToList();
  1313. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1314. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1315. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1316. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1317. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1318. {
  1319. DiId = tcl.DiId,
  1320. LastName = dc.LastName,
  1321. FirstName = dc.FirstName,
  1322. Sex = dc.Sex,
  1323. Birthday = dc.BirthDay,
  1324. Company = cc.CompanyFullName,
  1325. Job = dc.Job,
  1326. CreateTime = tcl.CreateTime,
  1327. })
  1328. .ToList();
  1329. foreach (var item in groupList)
  1330. {
  1331. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1332. string groupFirstName = "";
  1333. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1334. if (currDatas.Any())
  1335. {
  1336. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1337. }
  1338. item.GroupFirst = groupFirstName;
  1339. }
  1340. #endregion
  1341. #region Excel
  1342. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1343. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1344. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1345. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1346. var fileName = $"团组清单({beginDt}{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1347. //载入模板
  1348. WorkbookDesigner designer = new WorkbookDesigner();
  1349. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1350. designer.SetDataSource("Titel", $"团组清单({beginDt}{endDt})");
  1351. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1352. dt.TableName = "GroupList";
  1353. designer.SetDataSource(dt);
  1354. designer.Process();
  1355. if (!Directory.Exists(savePath))
  1356. {
  1357. Directory.CreateDirectory(savePath);
  1358. }
  1359. string serverPath = $"{savePath}{fileName}";
  1360. designer.Workbook.Save(serverPath);
  1361. string rst = $"{servicePath}{ftpPath}{fileName}";
  1362. #endregion
  1363. return Ok(JsonView(true, "操作成功!", rst));
  1364. }
  1365. #endregion
  1366. #region 团组&签证
  1367. /// <summary>
  1368. /// 根据团组Id获取签证客户信息List
  1369. /// </summary>
  1370. /// <param name="dto">请求dto</param>
  1371. /// <returns></returns>
  1372. [HttpPost]
  1373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1374. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1375. {
  1376. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1377. if (groupData.Code != 0)
  1378. {
  1379. return Ok(JsonView(false, groupData.Msg));
  1380. }
  1381. return Ok(JsonView(groupData.Data));
  1382. }
  1383. /// <summary>
  1384. /// IOS获取团组签证拍照上传进度01(团组列表)
  1385. /// </summary>
  1386. /// <param name="dto">请求dto</param>
  1387. /// <returns></returns>
  1388. [HttpPost]
  1389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1390. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1391. {
  1392. if (dto == null)
  1393. {
  1394. return Ok(JsonView(false, "参数为空"));
  1395. }
  1396. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1397. return Ok(JsonView(visaList));
  1398. }
  1399. /// <summary>
  1400. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1401. /// </summary>
  1402. /// <returns></returns>
  1403. [HttpPost]
  1404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1405. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1406. {
  1407. if (dto == null)
  1408. {
  1409. return Ok(JsonView(false, "请求错误:"));
  1410. }
  1411. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1412. return Ok(JsonView(list));
  1413. }
  1414. /// <summary>
  1415. /// IOS获取团组签证拍照上传进度03(相册)
  1416. /// </summary>
  1417. /// <returns></returns>
  1418. [HttpPost]
  1419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1420. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1421. {
  1422. if (dto == null)
  1423. {
  1424. return Ok(JsonView(false, "请求错误:"));
  1425. }
  1426. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1427. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1428. list.ForEach(s => s.url = url);
  1429. return Ok(JsonView(list));
  1430. }
  1431. /// <summary>
  1432. /// IOS获取团组签证拍照上传进度04(图片上传)
  1433. /// </summary>
  1434. /// <param name="dto"></param>
  1435. /// <returns></returns>
  1436. [HttpPost]
  1437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1438. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1439. {
  1440. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1441. //if (!string.IsNullOrEmpty(result))
  1442. //{
  1443. //}
  1444. //else {
  1445. // return Ok(JsonView(false, "上传失败"));
  1446. //}
  1447. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1448. int sucNum = 0;
  1449. try
  1450. {
  1451. foreach (var item in dto.base64DataList)
  1452. {
  1453. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1454. string result = decodeBase64ToImage(item, imageName);
  1455. if (!string.IsNullOrEmpty(result))
  1456. {
  1457. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1458. pic.CreateUserId = dto.CreateUserId;
  1459. pic.PicName = imageName;
  1460. pic.PicPath = result;
  1461. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1462. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1463. if (insertResult > 0)
  1464. {
  1465. sucNum++;
  1466. }
  1467. }
  1468. }
  1469. }
  1470. catch (Exception ex)
  1471. {
  1472. return Ok(JsonView(false, ex.Message));
  1473. }
  1474. string msg = string.Format(@"成功上传{0}张", sucNum);
  1475. return Ok(JsonView(true, msg));
  1476. }
  1477. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1478. {
  1479. string filename = "";//声明一个string类型的相对路径
  1480. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1481. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1482. try//会有异常抛出,try,catch一下
  1483. {
  1484. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1485. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1486. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1487. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1488. //文件名称
  1489. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1490. //上传的文件的路径
  1491. string filePath = "";
  1492. if (!Directory.Exists(fileDir))
  1493. {
  1494. Directory.CreateDirectory(fileDir);
  1495. }
  1496. //上传的文件的路径
  1497. filePath = fileDir + filename;
  1498. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1499. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1500. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1501. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1502. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1503. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1504. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1505. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1506. bitmap.Dispose();
  1507. }
  1508. catch (Exception e)
  1509. {
  1510. string massage = e.Message;
  1511. Logs("IOS图片上传Error:" + massage);
  1512. //filename = e.Message;
  1513. }
  1514. return filename;//返回相对路径
  1515. }
  1516. /// <summary>
  1517. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1518. /// </summary>
  1519. /// <param name="dto"></param>
  1520. /// <returns></returns>
  1521. [HttpPost]
  1522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1523. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1524. {
  1525. if (dto == null)
  1526. {
  1527. return Ok(JsonView(false, "请求错误:"));
  1528. }
  1529. string msg = "参数错误";
  1530. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1531. {
  1532. try
  1533. {
  1534. //_delegationVisaRep.BeginTran();
  1535. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1536. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1537. .Where(s => s.Id == dto.visaProgressCustomerId)
  1538. .ExecuteCommandAsync();
  1539. if (updCount > 0 && dto.publishCode == 1)
  1540. {
  1541. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1542. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1543. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1544. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1545. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1546. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1547. if (groupData == null)
  1548. {
  1549. _delegationVisaRep.RollbackTran();
  1550. }
  1551. string title = string.Format(@"[签证进度更新]");
  1552. string content = string.Format(@"测试文本");
  1553. bool rst = await _message.AddMsg(new MessageDto()
  1554. {
  1555. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1556. IssuerId = dto.publisher,
  1557. Title = title,
  1558. Content = content,
  1559. ReleaseTime = DateTime.Now,
  1560. UIdList = new List<int> {
  1561. 234
  1562. }
  1563. });
  1564. if (rst)
  1565. {
  1566. return Ok(JsonView(true, "发送通知成功"));
  1567. }
  1568. }
  1569. //_delegationVisaRep.CommitTran();
  1570. }
  1571. catch (Exception)
  1572. {
  1573. //_delegationVisaRep.RollbackTran();
  1574. }
  1575. }
  1576. return Ok(JsonView(true, msg));
  1577. }
  1578. #endregion
  1579. #region 团组任务分配
  1580. /// <summary>
  1581. /// 团组任务分配初始化
  1582. /// </summary>
  1583. /// <param name="dto"></param>
  1584. /// <returns></returns>
  1585. [HttpPost]
  1586. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1587. public async Task<IActionResult> GetTaskAssignmen()
  1588. {
  1589. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1590. if (groupData.Code != 0)
  1591. {
  1592. return Ok(JsonView(false, groupData.Msg));
  1593. }
  1594. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1595. }
  1596. /// <summary>
  1597. /// 团组任务分配查询
  1598. /// </summary>
  1599. /// <param name="dto"></param>
  1600. /// <returns></returns>
  1601. [HttpPost]
  1602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1603. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1604. {
  1605. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1606. if (groupData.Code != 0)
  1607. {
  1608. return Ok(JsonView(false, groupData.Msg));
  1609. }
  1610. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1611. }
  1612. /// <summary>
  1613. /// 团组任务分配操作
  1614. /// </summary>
  1615. /// <param name="dto"></param>
  1616. /// <returns></returns>
  1617. [HttpPost]
  1618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1619. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1620. {
  1621. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1622. if (groupData.Code != 0)
  1623. {
  1624. return Ok(JsonView(false, groupData.Msg));
  1625. }
  1626. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1627. }
  1628. /// <summary>
  1629. /// 团组任务分配
  1630. /// 批量分配
  1631. /// 查询团组
  1632. /// </summary>
  1633. /// <param name="dto"></param>
  1634. /// <returns></returns>
  1635. [HttpPost]
  1636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1637. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1638. {
  1639. //参数验证
  1640. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1641. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1642. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1643. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1644. }
  1645. /// <summary>
  1646. /// 团组任务分配
  1647. /// 批量分配
  1648. /// </summary>
  1649. /// <param name="dto"></param>
  1650. /// <returns></returns>
  1651. [HttpPost]
  1652. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1653. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1654. {
  1655. //参数验证
  1656. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1657. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1658. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1659. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1660. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1661. }
  1662. #endregion
  1663. #region 团组费用审核
  1664. /// <summary>
  1665. /// 费用审核
  1666. /// 团组列表 Page
  1667. /// </summary>
  1668. /// <param name="_dto">团组列表请求dto</param>
  1669. /// <returns></returns>
  1670. [HttpPost]
  1671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1672. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1673. {
  1674. #region 参数验证
  1675. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1676. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1677. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1678. #region 页面操作权限验证
  1679. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1680. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1681. #endregion
  1682. #endregion
  1683. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1684. {
  1685. string sqlWhere = string.Empty;
  1686. if (_dto.IsSure == 0) //未完成
  1687. {
  1688. sqlWhere += string.Format(@" And IsSure = 0");
  1689. }
  1690. else if (_dto.IsSure == 1) //已完成
  1691. {
  1692. sqlWhere += string.Format(@" And IsSure = 1");
  1693. }
  1694. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1695. {
  1696. string tj = _dto.SearchCriteria;
  1697. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  1698. tj, tj, tj, tj, tj);
  1699. }
  1700. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1701. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1702. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1703. From (
  1704. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1705. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1706. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1707. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1708. From Grp_DelegationInfo gdi
  1709. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1710. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1711. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1712. Where gdi.IsDel = 0 {0}
  1713. ) temp ", sqlWhere);
  1714. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1715. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1716. var _view = new
  1717. {
  1718. PageFuncAuth = pageFunAuthView,
  1719. Data = _DelegationList
  1720. };
  1721. return Ok(JsonView(true, "查询成功!", _view, total));
  1722. }
  1723. else
  1724. {
  1725. return Ok(JsonView(false, "查询失败"));
  1726. }
  1727. }
  1728. /// <summary>
  1729. /// 获取团组费用审核
  1730. /// </summary>
  1731. /// <param name="paras">参数Json字符串</param>
  1732. /// <returns></returns>
  1733. [HttpPost]
  1734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1735. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1736. {
  1737. try
  1738. {
  1739. #region 参数验证
  1740. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1741. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1742. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1743. #region 页面操作权限验证
  1744. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1745. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1746. #endregion
  1747. #endregion
  1748. var _view = new Grp_CreditCardPaymentView();
  1749. var clientNameList = getSimplClientList(_dto.DiId);
  1750. #region 费用清单
  1751. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1752. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1753. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1754. var entityList = _groupRepository .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1755. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1756. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1757. /*
  1758. * 76://酒店预订
  1759. */
  1760. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1761. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1762. /*
  1763. * 79://车/导游地接
  1764. */
  1765. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1766. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1767. /*
  1768. * 80: //签证
  1769. */
  1770. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1771. /*
  1772. *81: //邀请/公务活动
  1773. */
  1774. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1775. /*
  1776. * 82: //团组客户保险
  1777. */
  1778. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1779. /*
  1780. * Lable = 85 机票预订
  1781. */
  1782. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1783. /*
  1784. * 85 机票预定
  1785. */
  1786. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1787. /*
  1788. * 98 其他款项
  1789. */
  1790. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1791. /*
  1792. * 285:收款退还
  1793. */
  1794. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1795. /*
  1796. * 1015: //超支费用
  1797. */
  1798. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1799. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1800. /*
  1801. * 币种信息
  1802. */
  1803. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  1804. /*
  1805. * 车/导游地接 费用类型
  1806. */
  1807. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  1808. /*
  1809. * 车/导游地接 费用类型
  1810. */
  1811. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  1812. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1813. /*
  1814. * 用户信息
  1815. */
  1816. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  1817. /*
  1818. * 费用模块
  1819. */
  1820. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  1821. string priceModule = string.Empty;
  1822. if (sdPriceName != null)
  1823. {
  1824. priceModule = sdPriceName.Name;
  1825. }
  1826. /*
  1827. * 成本信息
  1828. */
  1829. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1830. decimal _groupRate = 0.0000M;
  1831. string _groupCurrencyCode = "-";
  1832. if (groupCost != null)
  1833. {
  1834. _groupRate = groupCost.Rate;
  1835. if (int.TryParse(groupCost.Currency, out int _currency))
  1836. {
  1837. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1838. }
  1839. else _groupCurrencyCode = groupCost.Currency;
  1840. }
  1841. string costContentSql = $"Select * From Grp_GroupCost";
  1842. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1843. //处理日期为空的天数
  1844. for (int i = 0; i < groupCostDetails.Count; i++)
  1845. if (i != 0)
  1846. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1847. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1848. /*
  1849. * 处理详情数据
  1850. */
  1851. foreach (var entity in entityList)
  1852. {
  1853. var _detail = new Grp_CreditCardPaymentDetailView();
  1854. _detail.Id = entity.Id;
  1855. _detail.PriceName = priceModule;
  1856. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1857. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1858. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1859. //处理金额
  1860. if (entity.CTable == 1015)
  1861. {
  1862. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1863. if (czInfo != null)
  1864. {
  1865. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1866. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1867. }
  1868. }
  1869. /*
  1870. * 应付款金额
  1871. */
  1872. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1873. string PaymentCurrency_WaitPay = "Unknown";
  1874. string hotelCurrncyCode = "Unknown";
  1875. string hotelCurrncyName = "Unknown";
  1876. if (sdPaymentCurrency_WaitPay != null)
  1877. {
  1878. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1879. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1880. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1881. if (hotelCurrncyCode.Equals("CNY"))
  1882. {
  1883. entity.DayRate = 1.0000M;
  1884. }
  1885. }
  1886. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1887. /*
  1888. * 此次付款金额
  1889. */
  1890. decimal CurrPayStr = 0.00M,
  1891. OriginalCurrPay = 0.00M;
  1892. if (entity.PayPercentage == 0)
  1893. {
  1894. if (entity.PayThenMoney != 0)
  1895. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1896. }
  1897. else
  1898. {
  1899. if (entity.PayMoney != 0)
  1900. {
  1901. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1902. }
  1903. }
  1904. //if (_dto.Label == 79)
  1905. //{
  1906. // string original = string.Empty;
  1907. // if (hotelCurrncyCode.Equals("CNY"))
  1908. // {
  1909. // OriginalCurrPay = CurrPayStr;
  1910. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1911. // }
  1912. // else
  1913. // {
  1914. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1915. // //760 EUR(7600.00 CNY)
  1916. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1917. // }
  1918. //}
  1919. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1920. string original = string.Empty;
  1921. if (hotelCurrncyCode.Equals("CNY"))
  1922. {
  1923. OriginalCurrPay = CurrPayStr;
  1924. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1925. }
  1926. else
  1927. {
  1928. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1929. //760 EUR(7600.00 CNY)
  1930. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1931. }
  1932. /*
  1933. * 剩余尾款
  1934. */
  1935. decimal BalanceStr = 0;
  1936. if (CurrPayStr != 0)
  1937. {
  1938. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1939. BalanceStr = 0;
  1940. else
  1941. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1942. }
  1943. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1944. /*
  1945. * Bus名称
  1946. */
  1947. _detail.BusName = "待增加";
  1948. /*
  1949. *费用所属
  1950. */
  1951. switch (entity.CTable)
  1952. {
  1953. case 76://酒店预订
  1954. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1955. if (hotelReservations != null)
  1956. {
  1957. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1958. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1959. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1960. string roomFeeStr = "", roomFeestr1 = "";
  1961. //是否比较房型价格
  1962. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1963. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1964. roomFeeStr += $"<br/>";
  1965. var roomTotal = 0.00M;
  1966. if (hotelReservations.SingleRoomPrice > 0)
  1967. {
  1968. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  1969. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1970. __isSingle = true;
  1971. roomTotal += fee;
  1972. }
  1973. if (hotelReservations.DoubleRoomPrice > 0)
  1974. {
  1975. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  1976. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1977. __isDouble = true;
  1978. roomTotal += fee;
  1979. }
  1980. if (hotelReservations.SuiteRoomPrice > 0)
  1981. {
  1982. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  1983. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1984. __isSuite = true;
  1985. roomTotal += fee;
  1986. }
  1987. if (hotelReservations.OtherRoomPrice > 0)
  1988. {
  1989. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  1990. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1991. __isOther = true;
  1992. roomTotal += fee;
  1993. }
  1994. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  1995. else roomFeeStr += " 0.00 * 0";
  1996. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1997. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1998. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1999. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2000. /*
  2001. * 费用类型
  2002. * 1:房费
  2003. * 2:早餐
  2004. * 3:地税
  2005. * 4:城市税
  2006. * </summary>
  2007. */
  2008. //地税
  2009. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2010. if (governmentRentData != null)
  2011. {
  2012. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2013. governmentRentFee = governmentRentData.Price;
  2014. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2015. if (governmentRentCurrData != null)
  2016. {
  2017. governmentRentCode = governmentRentCurrData.Name;
  2018. governmentRentName = $"({governmentRentCurrData.Remark})";
  2019. }
  2020. }
  2021. //城市税
  2022. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2023. if (cityTaxData != null)
  2024. {
  2025. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2026. cityTaxFee = cityTaxData.Price;
  2027. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2028. if (cityTaxCurrData != null)
  2029. {
  2030. cityTaxCode = cityTaxCurrData.Name;
  2031. cityTaxName = $"({cityTaxCurrData.Remark})";
  2032. }
  2033. }
  2034. //酒店早餐
  2035. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2036. if (breakfastData != null)
  2037. {
  2038. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2039. breakfastFee = breakfastData.Price;
  2040. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2041. if (breakfastCurrData != null)
  2042. {
  2043. breakfastCode = breakfastCurrData.Name;
  2044. breakfastName = $"({breakfastCurrData.Remark})";
  2045. }
  2046. }
  2047. //房间费用
  2048. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2049. if (roomData != null)
  2050. {
  2051. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2052. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2053. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2054. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2055. roomFee = roomData.Price;
  2056. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2057. if (roomCurrData != null)
  2058. {
  2059. roomCode = roomCurrData.Name;
  2060. roomName = $"({roomCurrData.Remark})";
  2061. }
  2062. }
  2063. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2064. string hotelCostStr = "";
  2065. decimal hotelCsotTotal = 0.00M;
  2066. if (groupCost != null)
  2067. {
  2068. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2069. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2070. }
  2071. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2072. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2073. string hotelCost_day = "";
  2074. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2075. foreach (var item in hotelCostDetails1)
  2076. {
  2077. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2078. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2079. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2080. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2081. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2082. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2083. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2084. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2085. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2086. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2087. hotelCost_day += @$"<br/>";
  2088. }
  2089. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2090. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2091. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2092. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2093. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2094. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2095. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2096. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2097. $"房间说明: {hotelReservations.Remark} <br/>" +
  2098. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2099. $"{hotelBreakfastStr}" +
  2100. $"{hotelGovernmentRentStr}" +
  2101. $"{hotelCityTaxStr}";
  2102. _detail.PriceNameContent = hotelReservations.HotelName;
  2103. }
  2104. break;
  2105. case 79://车/导游地接
  2106. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2107. if (touristGuideGroundReservations != null)
  2108. {
  2109. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2110. {
  2111. _detail.BusName = touristGuideGroundReservations.BusName;
  2112. }
  2113. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2114. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2115. //if (isInt)
  2116. //{
  2117. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2118. // if (cityInfo != null)
  2119. // {
  2120. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2121. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2122. // if (carFeeItem != null)
  2123. // {
  2124. // nameContent += $@"({carFeeItem.Name})";
  2125. // }
  2126. // _detail.PriceNameContent = nameContent;
  2127. // }
  2128. //}
  2129. //else
  2130. //{
  2131. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2132. //}
  2133. var touristGuideGroundReservationsContents =
  2134. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2135. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2136. foreach (var item in touristGuideGroundReservationsContents)
  2137. {
  2138. string typeName = "Unknown";
  2139. string carCurrencyCode = "Unknown";
  2140. string carCurrencyName = "Unknown";
  2141. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2142. if (carTypeData != null) typeName = carTypeData.Name;
  2143. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2144. if (currencyData != null)
  2145. {
  2146. carCurrencyCode = currencyData.Name;
  2147. carCurrencyName = currencyData.Remark;
  2148. }
  2149. //op、成本 币种是否一致
  2150. bool IsCurrencyAgreement = false;
  2151. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2152. string opCostStr = string.Empty;
  2153. decimal opCostTypePrice = 0.00M;
  2154. #region 处理成本各项费用
  2155. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2156. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2157. if (opCost.Count > 0)
  2158. {
  2159. switch (item.SId)
  2160. {
  2161. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2162. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2163. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2164. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2165. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2166. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2167. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2168. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2169. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2170. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2171. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2172. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2173. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2174. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2175. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2176. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2177. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2178. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2179. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2180. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2181. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2182. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2183. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2184. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2185. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2186. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2187. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2188. }
  2189. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2190. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2191. }
  2192. #endregion
  2193. string opTypeStr = $"{typeName}{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2194. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2195. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2196. $"{opTypeStr} {opCostStr}<br/>" +
  2197. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2198. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2199. }
  2200. _detail.PriceMsgContent = priceMsg;
  2201. }
  2202. break;
  2203. case 80: //签证
  2204. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2205. if (visaInfo != null)
  2206. {
  2207. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2208. _detail.PriceNameContent = visaInfo.VisaDescription;
  2209. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2210. }
  2211. break;
  2212. case 81: //邀请/公务活动
  2213. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2214. if (_ioa != null)
  2215. {
  2216. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2217. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2218. sendCurrName = "Unknown", //快递费用币种 Name
  2219. sendCurrCode = "Unknown", //快递费用币种 Code
  2220. eventsCurrName = "Unknown", //公务活动费币种 Name
  2221. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2222. translateCurrName = "Unknown", //公务翻译费 Name
  2223. translateCurrCode = "Unknown"; //公务翻译费 Code
  2224. #region 处理费用币种
  2225. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2226. if (inviteCurrData != null)
  2227. {
  2228. inviteCurrName = inviteCurrData.Remark;
  2229. inviteCurrCode = inviteCurrData.Name;
  2230. }
  2231. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2232. if (sendCurrData != null)
  2233. {
  2234. sendCurrName = sendCurrData.Remark;
  2235. sendCurrCode = sendCurrData.Name;
  2236. }
  2237. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2238. if (eventsCurrData != null)
  2239. {
  2240. eventsCurrName = eventsCurrData.Remark;
  2241. eventsCurrCode = eventsCurrData.Name;
  2242. }
  2243. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2244. if (translateCurrData != null)
  2245. {
  2246. translateCurrName = translateCurrData.Remark;
  2247. translateCurrCode = translateCurrData.Name;
  2248. }
  2249. #endregion
  2250. _detail.PriceNameContent = _ioa.InviterArea;
  2251. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2252. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2253. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2254. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2255. $@"备注:" + _ioa.Remark + "<br/>";
  2256. }
  2257. break;
  2258. case 82: //团组客户保险
  2259. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2260. if (customers != null)
  2261. {
  2262. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2263. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2264. }
  2265. break;
  2266. case 85: //机票预订
  2267. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2268. if (jpRes != null)
  2269. {
  2270. string FlightsDescription = jpRes.FlightsDescription;
  2271. string PriceDescription = jpRes.PriceDescription;
  2272. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2273. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2274. }
  2275. break;
  2276. case 98://其他款项
  2277. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2278. if (gdpRes != null)
  2279. {
  2280. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2281. _detail.PriceNameContent = gdpRes.PriceName;
  2282. }
  2283. break;
  2284. case 285://收款退还
  2285. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2286. if (refundAndOtherMoney != null)
  2287. {
  2288. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2289. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2290. }
  2291. break;
  2292. case 751://酒店早餐
  2293. break;
  2294. case 1015://超支费用
  2295. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2296. if (groupExtraCost != null)
  2297. {
  2298. _detail.PriceNameContent = groupExtraCost.PriceName;
  2299. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2300. }
  2301. break;
  2302. default:
  2303. break;
  2304. }
  2305. /*
  2306. * 申请人
  2307. */
  2308. string operatorName = " - ";
  2309. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2310. if (_opUser != null)
  2311. {
  2312. operatorName = _opUser.CnName;
  2313. }
  2314. _detail.OperatorName = operatorName;
  2315. /*
  2316. * 审核人
  2317. */
  2318. string auditOperatorName = "Unknown";
  2319. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2320. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2321. else
  2322. {
  2323. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2324. if (_adUser != null)
  2325. {
  2326. auditOperatorName = _adUser.CnName;
  2327. }
  2328. }
  2329. _detail.AuditOperatorName = auditOperatorName;
  2330. /*
  2331. * 超预算比例
  2332. */
  2333. string overBudgetStr = "";
  2334. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2335. else if (entity.ExceedBudget == 0)
  2336. {
  2337. if (entity.CTable == 76 || entity.CTable == 79)
  2338. {
  2339. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2340. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2341. }
  2342. else
  2343. {
  2344. overBudgetStr = "未超预算";
  2345. }
  2346. }
  2347. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2348. _detail.OverBudget = overBudgetStr;
  2349. decimal auditFee = 0.00M; //已审核金额 人名币
  2350. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2351. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2352. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2353. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2354. {
  2355. auditedFeeOriginal = entity.PayMoney;
  2356. auditFee = CurrPayStr;
  2357. }
  2358. else if (entity.IsAuditGM == 0)
  2359. {
  2360. unAuditFeeCNY = CurrPayStr;
  2361. unAuditFeeOriginal = OriginalCurrPay;
  2362. OriginalCurrPay = 0.00M;
  2363. }
  2364. /*
  2365. * 费用总计
  2366. */
  2367. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2368. {
  2369. CurrencyId = entity.PaymentCurrency,
  2370. CurrencyName = PaymentCurrency_WaitPay,
  2371. AmountPayable = entity.PayMoney,
  2372. ThisPayment = OriginalCurrPay,
  2373. BalancePayment = BalanceStr,
  2374. AuditedFunds = auditFee,
  2375. AuditedFundsOriginal = auditedFeeOriginal,
  2376. UnAuditFundsCNY = unAuditFeeCNY,
  2377. UnAuditFundsOriginal = unAuditFeeOriginal
  2378. });
  2379. _detail.IsAuditGM = entity.IsAuditGM;
  2380. detailList.Add(_detail);
  2381. }
  2382. #endregion
  2383. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2384. /*
  2385. * 下方描述处理
  2386. */
  2387. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2388. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2389. if (ccpCurrencyPrice != null)
  2390. {
  2391. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2392. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2393. }
  2394. else
  2395. {
  2396. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2397. }
  2398. string amountPayableStr = string.Format(@"应付款总金额: ");
  2399. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2400. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2401. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2402. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2403. foreach (var item in nonDuplicat)
  2404. {
  2405. var currencyName = item.CurrencyName;
  2406. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2407. if (strs.Count > 0)
  2408. {
  2409. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2410. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2411. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2412. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2413. //单独处理此次付款金额
  2414. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2415. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2416. //单独处理已审核费用
  2417. //if (item.CurrencyId == 836) //人民币
  2418. //{
  2419. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2420. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2421. //}
  2422. //else
  2423. //{
  2424. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2425. //}
  2426. if (currencyName.Equals("CNY"))
  2427. {
  2428. //已审核费用
  2429. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2430. //未审核费用
  2431. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2432. }
  2433. else
  2434. {
  2435. //已审核费用
  2436. auditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName, strs.Sum(x => x.AuditedFunds).ToString("#0.00"));
  2437. //未审核费用
  2438. unAuditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName, strs.Sum(x => x.UnAuditFundsCNY).ToString("#0.00"));
  2439. }
  2440. }
  2441. }
  2442. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2443. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2444. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2445. _view.TotalStr4 = $"{auditedFundsStr.Substring(0, auditedFundsStr.Length - 1)}<br/>{unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1)}";
  2446. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2447. var _view1 = new
  2448. {
  2449. PageFuncAuth = pageFunAuthView,
  2450. Data = _view
  2451. };
  2452. return Ok(JsonView(_view1));
  2453. }
  2454. catch (Exception ex)
  2455. {
  2456. return Ok(JsonView(false, ex.Message));
  2457. }
  2458. }
  2459. /// <summary>
  2460. /// 费用审核
  2461. /// 修改团组费用审核状态
  2462. /// </summary>
  2463. /// <param name="_dto">参数Json字符串</param>
  2464. /// <returns></returns>
  2465. [HttpPost]
  2466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2467. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2468. {
  2469. #region 参数验证
  2470. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2471. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2472. #endregion
  2473. #region 页面操作权限验证
  2474. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2475. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2476. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2477. #endregion
  2478. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2479. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2480. DateTime dtNow = DateTime.Now;
  2481. _groupRepository.BeginTran();
  2482. int rst = 0;
  2483. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2484. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2485. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2486. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2487. List<dynamic> msgDatas = new List<dynamic>();
  2488. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2489. foreach (var item in idList)
  2490. {
  2491. int CreditId = int.Parse(item);
  2492. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2493. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2494. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2495. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2496. .Where(s => s.Id == CreditId)
  2497. .ExecuteCommandAsync();
  2498. if (result < 1)
  2499. {
  2500. rst = -1;
  2501. _groupRepository.RollbackTran();
  2502. return Ok(JsonView(false, "操作失败并回滚!"));
  2503. }
  2504. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2505. if (creditData != null)
  2506. {
  2507. #region 应用通知配置
  2508. try
  2509. {
  2510. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2511. }
  2512. catch (Exception ex)
  2513. {
  2514. }
  2515. #endregion
  2516. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2517. string groupNameStr = string.Empty;
  2518. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2519. if (groupData != null) groupNameStr = groupData.TeamName;
  2520. string creditTypeStr = string.Empty;
  2521. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2522. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2523. string creditCurrency = string.Empty;
  2524. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2525. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2526. if (creditCurrency.Equals("CNY"))
  2527. {
  2528. creditData.DayRate = 1.0000M;
  2529. }
  2530. if (creditData.PayPercentage == 0.00M)
  2531. {
  2532. creditData.PayPercentage = 100M;
  2533. }
  2534. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2535. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2536. string msgContent = "";
  2537. if (creditCurrency.Equals("CNY"))
  2538. {
  2539. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2540. }
  2541. else
  2542. {
  2543. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2544. }
  2545. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2546. }
  2547. }
  2548. if (rst == 0)
  2549. {
  2550. _groupRepository.CommitTran();
  2551. foreach (var item in msgDatas)
  2552. {
  2553. //发送消息
  2554. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2555. }
  2556. #region 应用推送
  2557. try
  2558. {
  2559. foreach (var ccpId in dic_ccp_user.Keys)
  2560. {
  2561. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2562. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2563. }
  2564. }
  2565. catch (Exception)
  2566. {
  2567. }
  2568. #endregion
  2569. return Ok(JsonView(true, "操作成功!"));
  2570. }
  2571. return Ok(JsonView(false, "操作失败!"));
  2572. }
  2573. #endregion
  2574. #region 机票费用录入
  2575. /// <summary>
  2576. /// 机票录入当前登录人可操作团组
  2577. /// </summary>
  2578. /// <param name="dto"></param>
  2579. /// <returns></returns>
  2580. [HttpPost]
  2581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2582. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2583. {
  2584. try
  2585. {
  2586. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2587. if (groupData.Code != 0)
  2588. {
  2589. return Ok(JsonView(false, groupData.Msg));
  2590. }
  2591. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2592. }
  2593. catch (Exception ex)
  2594. {
  2595. return Ok(JsonView(false, "程序错误!"));
  2596. throw;
  2597. }
  2598. }
  2599. /// <summary>
  2600. /// 机票费用录入列表
  2601. /// </summary>
  2602. /// <param name="dto"></param>
  2603. /// <returns></returns>
  2604. [HttpPost]
  2605. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2606. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2607. {
  2608. try
  2609. {
  2610. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2611. if (groupData.Code != 0)
  2612. {
  2613. return Ok(JsonView(false, groupData.Msg));
  2614. }
  2615. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2616. }
  2617. catch (Exception ex)
  2618. {
  2619. return Ok(JsonView(false, ex.Message));
  2620. throw;
  2621. }
  2622. }
  2623. /// <summary>
  2624. /// 根据id查询费用录入信息
  2625. /// </summary>
  2626. /// <param name="dto"></param>
  2627. /// <returns></returns>
  2628. [HttpPost]
  2629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2630. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2631. {
  2632. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2633. if (groupData.Code != 0)
  2634. {
  2635. return Ok(JsonView(false, groupData.Msg));
  2636. }
  2637. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2638. }
  2639. /// <summary>
  2640. /// 机票费用录入操作(Status:1.新增,2.修改)
  2641. /// </summary>
  2642. /// <param name="dto"></param>
  2643. /// <returns></returns>
  2644. [HttpPost]
  2645. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2646. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2647. {
  2648. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2649. if (groupData.Code != 0)
  2650. {
  2651. return Ok(JsonView(false, groupData.Msg));
  2652. }
  2653. #region 应用推送
  2654. try
  2655. {
  2656. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2657. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2658. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2659. //2024-10-21 新增LZ UID
  2660. var userIds = new List<int>() { 21 };
  2661. string title = $"系统通知";
  2662. string content = "";
  2663. var diId = dto.AirTicketResOpData.DiId;
  2664. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2665. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2666. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2667. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2668. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2669. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2670. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2671. }
  2672. catch (Exception ex)
  2673. {
  2674. }
  2675. #endregion
  2676. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2677. }
  2678. /// <summary>
  2679. /// 根据舱位类型查询接团客户名单信息
  2680. /// </summary>
  2681. /// <param name="dto"></param>
  2682. /// <returns></returns>
  2683. [HttpPost]
  2684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2685. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2686. {
  2687. try
  2688. {
  2689. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2690. if (crm_Groups.Count != 0)
  2691. {
  2692. List<dynamic> Customer = new List<dynamic>();
  2693. foreach (var item in crm_Groups)
  2694. {
  2695. var data = new
  2696. {
  2697. Id = item.Id,
  2698. Pinyin = item.Pinyin,
  2699. Name = item.LastName + item.FirstName
  2700. };
  2701. Customer.Add(data);
  2702. }
  2703. return Ok(JsonView(true, "查询成功!", Customer));
  2704. }
  2705. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2706. }
  2707. catch (Exception ex)
  2708. {
  2709. return Ok(JsonView(false, "程序错误!"));
  2710. throw;
  2711. }
  2712. }
  2713. /// <summary>
  2714. /// 根据团号获取客户信息
  2715. /// </summary>
  2716. /// <param name="dto"></param>
  2717. /// <returns></returns>
  2718. [HttpPost]
  2719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2720. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2721. {
  2722. var jw = JsonView(false);
  2723. if (dto.DIID < 1)
  2724. {
  2725. jw.Msg += "请输入正确的diid";
  2726. return Ok(jw);
  2727. }
  2728. var arr = getSimplClientList(dto.DIID);
  2729. jw = JsonView(true, "获取成功!", arr);
  2730. return Ok(jw);
  2731. }
  2732. private List<SimplClientInfo> getSimplClientList(int diId)
  2733. {
  2734. string sql = string.Format("select b.Id,b.Pinyin,b.lastName,b.firstName,b.phone from Grp_TourClientList a, Crm_DeleClient b where a.clientid = b.id and a.isdel = 0 and a.diid = {0}", diId);
  2735. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2736. foreach (var item in arr)
  2737. {
  2738. EncryptionProcessor.DecryptProperties(item);
  2739. }
  2740. return arr;
  2741. }
  2742. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2743. {
  2744. string result = origin;
  2745. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2746. {
  2747. string[] temparr = origin.Split(',');
  2748. string fistrStr = temparr[0];
  2749. int count = temparr.Count();
  2750. int tempId;
  2751. bool success = int.TryParse(fistrStr, out tempId);
  2752. if (success)
  2753. {
  2754. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2755. if (tempInfo != null)
  2756. {
  2757. if (count > 1)
  2758. {
  2759. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2760. }
  2761. else
  2762. {
  2763. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2764. }
  2765. }
  2766. }
  2767. }
  2768. return result;
  2769. }
  2770. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2771. {
  2772. string result = origin;
  2773. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2774. {
  2775. string[] temparr = origin.Split(',');
  2776. result = "";
  2777. foreach (var item in temparr)
  2778. {
  2779. int tempId;
  2780. bool success = int.TryParse(item, out tempId);
  2781. if (success)
  2782. {
  2783. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2784. if (tempInfo != null)
  2785. {
  2786. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2787. }
  2788. }
  2789. }
  2790. }
  2791. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2792. return result;
  2793. }
  2794. /// <summary>
  2795. /// 机票费用录入,删除
  2796. /// </summary>
  2797. /// <param name="dto"></param>
  2798. /// <returns></returns>
  2799. [HttpPost]
  2800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2801. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2802. {
  2803. try
  2804. {
  2805. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2806. if (res)
  2807. {
  2808. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2809. {
  2810. IsDel = 1,
  2811. DeleteUserId = dto.DeleteUserId,
  2812. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2813. }).ExecuteCommandAsync();
  2814. return Ok(JsonView(true, "删除成功!"));
  2815. }
  2816. return Ok(JsonView(false, "删除失败!"));
  2817. }
  2818. catch (Exception ex)
  2819. {
  2820. return Ok(JsonView(false, "程序错误!"));
  2821. throw;
  2822. }
  2823. }
  2824. /// <summary>
  2825. /// 导出机票录入报表
  2826. /// </summary>
  2827. /// <param name="dto"></param>
  2828. /// <returns></returns>
  2829. [HttpPost]
  2830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2831. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2832. {
  2833. try
  2834. {
  2835. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2836. if (groupData.Code != 0)
  2837. {
  2838. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2839. }
  2840. else
  2841. {
  2842. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2843. if (AirTicketReservations.Count != 0)
  2844. {
  2845. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2846. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2847. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2848. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2849. WorkbookDesigner designer = new WorkbookDesigner();
  2850. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2851. decimal countCost = 0;
  2852. foreach (var item in AirTicketReservations)
  2853. {
  2854. #region 处理客人姓名
  2855. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2856. item.ClientName = clientNames;
  2857. #endregion
  2858. if (item.BankType == "其他")
  2859. {
  2860. item.BankNo = "--";
  2861. }
  2862. else
  2863. {
  2864. if (!string.IsNullOrEmpty(item.BankType))
  2865. {
  2866. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2867. }
  2868. }
  2869. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2870. item.Price = System.Decimal.Round(item.Price, 2);
  2871. countCost += Convert.ToDecimal(item.Price);
  2872. }
  2873. designer.SetDataSource("Export", AirTicketReservations);
  2874. designer.SetDataSource("ExportDiCode", diCode);
  2875. designer.SetDataSource("ExportDiName", diName);
  2876. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2877. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2878. designer.Process();
  2879. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2880. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2881. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2882. return Ok(JsonView(true, "成功", url = rst));
  2883. }
  2884. else
  2885. {
  2886. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2887. }
  2888. }
  2889. }
  2890. catch (Exception ex)
  2891. {
  2892. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2893. throw;
  2894. }
  2895. }
  2896. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2897. /// <summary>
  2898. /// 行程单导出
  2899. /// </summary>
  2900. /// <param name="dto"></param>
  2901. /// <returns></returns>
  2902. [HttpPost]
  2903. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2904. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2905. {
  2906. try
  2907. {
  2908. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2909. if (groupData.Code != 0)
  2910. {
  2911. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2912. }
  2913. else
  2914. {
  2915. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2916. if (dto.Language == "CN")
  2917. {
  2918. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2919. DocumentBuilder builder = new DocumentBuilder(doc);
  2920. int tableIndex = 0;//表格索引
  2921. //得到文档中的第一个表格
  2922. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2923. foreach (var item in _AirTicketReservations)
  2924. {
  2925. #region 处理固定数据
  2926. string[] FlightsCode = item.FlightsCode.Split('/');
  2927. if (FlightsCode.Length != 0)
  2928. {
  2929. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2930. if (_AirCompany != null)
  2931. {
  2932. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2933. }
  2934. else
  2935. {
  2936. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2937. }
  2938. }
  2939. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2940. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2941. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2942. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2943. string name = "";
  2944. foreach (string clientName in nameArray)
  2945. {
  2946. if (!name.Contains(clientName))
  2947. {
  2948. name += clientName + ",";
  2949. }
  2950. }
  2951. if (!string.IsNullOrWhiteSpace(name))
  2952. {
  2953. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2954. }
  2955. else
  2956. {
  2957. table.Range.Bookmarks["ClientName"].Text = "--";
  2958. }
  2959. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2960. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2961. table.Range.Bookmarks["JointTicket"].Text = "--";
  2962. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2963. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2964. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2965. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2966. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2967. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2968. #endregion
  2969. #region 循环数据处理
  2970. List<AirInfo> airs = new List<AirInfo>();
  2971. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2972. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2973. for (int i = 0; i < FlightsCode.Length; i++)
  2974. {
  2975. AirInfo air = new AirInfo();
  2976. string[] tempstr = DayArray[i]
  2977. .Replace("\r\n", string.Empty)
  2978. .Replace("\\r\\n", string.Empty)
  2979. .TrimStart().TrimEnd()
  2980. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2981. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2982. string starCity = "";
  2983. if (star_Three != null)
  2984. {
  2985. starCity = star_Three.AirPort;
  2986. }
  2987. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2988. string EndCity = "";
  2989. if (End_Three != null)
  2990. {
  2991. EndCity = End_Three.AirPort;
  2992. }
  2993. air.Destination = starCity + "/" + EndCity;
  2994. air.Flight = FlightsCode[i];
  2995. air.SeatingClass = item.CTypeName;
  2996. string dateTime = tempstr[2];
  2997. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2998. air.FlightDate = DateTemp;
  2999. air.DepartureTime = tempstr[5];
  3000. air.LandingTime = tempstr[6];
  3001. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3002. air.TicketStatus = "--";
  3003. air.Luggage = "--";
  3004. air.DepartureTerminal = "--";
  3005. air.LandingTerminal = "--";
  3006. airs.Add(air);
  3007. }
  3008. int row = 13;
  3009. for (int i = 0; i < airs.Count; i++)
  3010. {
  3011. if (airs.Count > 2)
  3012. {
  3013. for (int j = 0; j < airs.Count - 2; j++)
  3014. {
  3015. var CopyRow = table.Rows[12].Clone(true);
  3016. table.Rows.Add(CopyRow);
  3017. }
  3018. }
  3019. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3020. int index = 0;
  3021. foreach (PropertyInfo property in properties)
  3022. {
  3023. string value = property.GetValue(airs[i]).ToString();
  3024. Cell ishcel0 = table.Rows[row].Cells[index];
  3025. Paragraph p = new Paragraph(doc);
  3026. string s = value;
  3027. p.AppendChild(new Run(doc, s));
  3028. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3029. ishcel0.AppendChild(p);
  3030. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3031. index++;
  3032. }
  3033. row++;
  3034. }
  3035. #endregion
  3036. Paragraph lastParagraph = new Paragraph(doc);
  3037. //第一个表格末尾加段落
  3038. table.ParentNode.InsertAfter(lastParagraph, table);
  3039. //复制第一个表格
  3040. Table cloneTable = (Table)table.Clone(true);
  3041. //在文档末尾段落后面加入复制的表格
  3042. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3043. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3044. {
  3045. int rownewsIndex = 13;
  3046. for (int i = 0; i < 2; i++)
  3047. {
  3048. var CopyRow = table.Rows[12].Clone(true);
  3049. table.Rows.RemoveAt(13);
  3050. table.Rows.Add(CopyRow);
  3051. rownewsIndex++;
  3052. }
  3053. }
  3054. else
  3055. {
  3056. table.Rows.RemoveAt(12);
  3057. }
  3058. cloneTable.Rows.RemoveAt(12);
  3059. }
  3060. if (_AirTicketReservations.Count != 0)
  3061. {
  3062. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3063. if (FlightsCode.Length != 0)
  3064. {
  3065. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3066. if (_AirCompany != null)
  3067. {
  3068. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3069. }
  3070. else
  3071. {
  3072. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3073. }
  3074. }
  3075. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3076. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3077. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3078. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3079. string name = "";
  3080. foreach (string clientName in nameArray)
  3081. {
  3082. if (!name.Contains(clientName))
  3083. {
  3084. name += clientName + ",";
  3085. }
  3086. }
  3087. if (!string.IsNullOrWhiteSpace(name))
  3088. {
  3089. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3090. }
  3091. else
  3092. {
  3093. table.Range.Bookmarks["ClientName"].Text = "--";
  3094. }
  3095. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3096. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3097. table.Range.Bookmarks["JointTicket"].Text = "--";
  3098. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3099. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3100. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3101. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3102. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3103. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3104. }
  3105. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3106. //保存合并后的文档
  3107. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3108. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3109. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3110. return Ok(JsonView(true, "成功!", rst));
  3111. }
  3112. else
  3113. {
  3114. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3115. DocumentBuilder builder = new DocumentBuilder(doc);
  3116. int tableIndex = 0;//表格索引
  3117. //得到文档中的第一个表格
  3118. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3119. List<string> texts = new List<string>();
  3120. foreach (var item in _AirTicketReservations)
  3121. {
  3122. string[] FlightsCode = item.FlightsCode.Split('/');
  3123. if (FlightsCode.Length != 0)
  3124. {
  3125. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3126. if (_AirCompany != null)
  3127. {
  3128. if (!transDic.ContainsKey(_AirCompany.CnName))
  3129. {
  3130. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3131. }
  3132. }
  3133. else
  3134. {
  3135. if (!transDic.ContainsKey("--"))
  3136. {
  3137. transDic.Add("--", "--");
  3138. }
  3139. }
  3140. }
  3141. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3142. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3143. string name = "";
  3144. foreach (string clientName in nameArray)
  3145. {
  3146. name += clientName + ",";
  3147. }
  3148. if (!texts.Contains(name))
  3149. {
  3150. texts.Add(name);
  3151. }
  3152. List<AirInfo> airs = new List<AirInfo>();
  3153. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3154. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3155. for (int i = 0; i < FlightsCode.Length; i++)
  3156. {
  3157. AirInfo air = new AirInfo();
  3158. string[] tempstr = DayArray[i]
  3159. .Replace("\r\n", string.Empty)
  3160. .Replace("\\r\\n", string.Empty)
  3161. .TrimStart().TrimEnd()
  3162. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3163. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3164. if (star_Three != null)
  3165. {
  3166. if (!transDic.ContainsKey(star_Three.AirPort))
  3167. {
  3168. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3169. }
  3170. }
  3171. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3172. if (End_Three != null)
  3173. {
  3174. if (!transDic.ContainsKey(End_Three.AirPort))
  3175. {
  3176. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3177. }
  3178. }
  3179. if (!texts.Contains(item.CTypeName))
  3180. {
  3181. texts.Add(item.CTypeName);
  3182. }
  3183. }
  3184. }
  3185. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3186. if (transData.Count > 0)
  3187. {
  3188. foreach (TranslateResult item in transData)
  3189. {
  3190. if (!transDic.ContainsKey(item.Query))
  3191. {
  3192. transDic.Add(item.Query, item.Translation);
  3193. }
  3194. }
  3195. }
  3196. foreach (var item in _AirTicketReservations)
  3197. {
  3198. #region 处理固定数据
  3199. string[] FlightsCode = item.FlightsCode.Split('/');
  3200. if (FlightsCode.Length != 0)
  3201. {
  3202. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3203. if (_AirCompany != null)
  3204. {
  3205. string str = "--";
  3206. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3207. if (!string.IsNullOrEmpty(translateResult))
  3208. {
  3209. str = translateResult;
  3210. str = _airTicketResRep.Processing(str);
  3211. }
  3212. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3213. }
  3214. else
  3215. {
  3216. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3217. }
  3218. }
  3219. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3220. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3221. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3222. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3223. string names = "";
  3224. foreach (string clientName in nameArray)
  3225. {
  3226. names += clientName + ",";
  3227. }
  3228. if (!string.IsNullOrWhiteSpace(names))
  3229. {
  3230. string str = "--";
  3231. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3232. if (!string.IsNullOrEmpty(translateResult))
  3233. {
  3234. str = translateResult;
  3235. str = _airTicketResRep.Processing(str);
  3236. }
  3237. table.Range.Bookmarks["ClientName"].Text = str;
  3238. }
  3239. else
  3240. {
  3241. table.Range.Bookmarks["ClientName"].Text = "--";
  3242. }
  3243. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3244. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3245. table.Range.Bookmarks["JointTicket"].Text = "--";
  3246. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3247. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3248. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3249. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3250. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3251. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3252. #endregion
  3253. #region 循环数据处理
  3254. List<AirInfo> airs = new List<AirInfo>();
  3255. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3256. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3257. for (int i = 0; i < FlightsCode.Length; i++)
  3258. {
  3259. AirInfo air = new AirInfo();
  3260. string[] tempstr = DayArray[i]
  3261. .Replace("\r\n", string.Empty)
  3262. .Replace("\\r\\n", string.Empty)
  3263. .TrimStart().TrimEnd()
  3264. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3265. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3266. string starCity = "";
  3267. if (star_Three != null)
  3268. {
  3269. string str2 = "--";
  3270. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3271. if (!string.IsNullOrEmpty(translateResult2))
  3272. {
  3273. str2 = translateResult2;
  3274. str2 = _airTicketResRep.Processing(str2);
  3275. }
  3276. starCity = str2;
  3277. }
  3278. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3279. string EndCity = "";
  3280. if (End_Three != null)
  3281. {
  3282. string str1 = "--";
  3283. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3284. if (!string.IsNullOrEmpty(translateResult1))
  3285. {
  3286. str1 = translateResult1;
  3287. str1 = _airTicketResRep.Processing(str1);
  3288. }
  3289. EndCity = str1;
  3290. }
  3291. air.Destination = starCity + "/" + EndCity;
  3292. air.Flight = FlightsCode[i];
  3293. string str = "--";
  3294. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3295. if (!string.IsNullOrEmpty(translateResult))
  3296. {
  3297. str = translateResult;
  3298. str = _airTicketResRep.Processing(str);
  3299. }
  3300. air.SeatingClass = str;
  3301. string dateTime = tempstr[2];
  3302. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3303. air.FlightDate = DateTemp;
  3304. air.DepartureTime = tempstr[5];
  3305. air.LandingTime = tempstr[6];
  3306. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3307. air.TicketStatus = "--";
  3308. air.Luggage = "--";
  3309. air.DepartureTerminal = "--";
  3310. air.LandingTerminal = "--";
  3311. airs.Add(air);
  3312. }
  3313. int row = 13;
  3314. for (int i = 0; i < airs.Count; i++)
  3315. {
  3316. if (airs.Count > 2)
  3317. {
  3318. for (int j = 0; j < airs.Count - 2; j++)
  3319. {
  3320. var CopyRow = table.Rows[12].Clone(true);
  3321. table.Rows.Add(CopyRow);
  3322. }
  3323. }
  3324. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3325. int index = 0;
  3326. foreach (PropertyInfo property in properties)
  3327. {
  3328. string value = property.GetValue(airs[i]).ToString();
  3329. Cell ishcel0 = table.Rows[row].Cells[index];
  3330. Paragraph p = new Paragraph(doc);
  3331. string s = value;
  3332. p.AppendChild(new Run(doc, s));
  3333. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3334. ishcel0.AppendChild(p);
  3335. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3336. //ishcel0.CellFormat.VerticalAlignment=
  3337. index++;
  3338. }
  3339. row++;
  3340. }
  3341. #endregion
  3342. Paragraph lastParagraph = new Paragraph(doc);
  3343. //第一个表格末尾加段落
  3344. table.ParentNode.InsertAfter(lastParagraph, table);
  3345. //复制第一个表格
  3346. Table cloneTable = (Table)table.Clone(true);
  3347. //在文档末尾段落后面加入复制的表格
  3348. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3349. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3350. {
  3351. int rownewsIndex = 13;
  3352. for (int i = 0; i < 2; i++)
  3353. {
  3354. var CopyRow = table.Rows[12].Clone(true);
  3355. table.Rows.RemoveAt(13);
  3356. table.Rows.Add(CopyRow);
  3357. rownewsIndex++;
  3358. }
  3359. }
  3360. else
  3361. {
  3362. table.Rows.RemoveAt(12);
  3363. }
  3364. cloneTable.Rows.RemoveAt(12);
  3365. }
  3366. if (_AirTicketReservations.Count != 0)
  3367. {
  3368. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3369. if (FlightsCode.Length != 0)
  3370. {
  3371. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3372. if (_AirCompany != null)
  3373. {
  3374. string str = "--";
  3375. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3376. if (!string.IsNullOrEmpty(translateResult))
  3377. {
  3378. str = translateResult;
  3379. str = _airTicketResRep.Processing(str);
  3380. }
  3381. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3382. }
  3383. else
  3384. {
  3385. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3386. }
  3387. }
  3388. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3389. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3390. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3391. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3392. string names = "";
  3393. foreach (string clientName in nameArray)
  3394. {
  3395. names += clientName + ",";
  3396. }
  3397. if (!string.IsNullOrWhiteSpace(names))
  3398. {
  3399. string str = "--";
  3400. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3401. if (!string.IsNullOrEmpty(translateResult))
  3402. {
  3403. str = translateResult;
  3404. str = _airTicketResRep.Processing(str);
  3405. }
  3406. table.Range.Bookmarks["ClientName"].Text = str;
  3407. }
  3408. else
  3409. {
  3410. table.Range.Bookmarks["ClientName"].Text = "--";
  3411. }
  3412. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3413. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3414. table.Range.Bookmarks["JointTicket"].Text = "--";
  3415. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3416. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3417. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3418. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3419. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3420. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3421. }
  3422. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3423. //保存合并后的文档
  3424. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3425. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3426. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3427. return Ok(JsonView(true, "成功!", rst));
  3428. }
  3429. }
  3430. }
  3431. catch (Exception ex)
  3432. {
  3433. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3434. throw;
  3435. }
  3436. }
  3437. #endregion
  3438. #region 团组增减款项 --> 其他款项
  3439. /// <summary>
  3440. /// 团组增减款项下拉框绑定
  3441. /// </summary>
  3442. /// <param name="dto"></param>
  3443. /// <returns></returns>
  3444. [HttpPost]
  3445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3446. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3447. {
  3448. #region 参数验证
  3449. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3450. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3451. #endregion
  3452. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3453. }
  3454. /// <summary>
  3455. /// 根据团组Id查询团组增减款项
  3456. /// </summary>
  3457. /// <param name="dto"></param>
  3458. /// <returns></returns>
  3459. [HttpPost]
  3460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3461. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3462. {
  3463. #region 参数验证
  3464. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3465. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3466. #endregion
  3467. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3468. }
  3469. /// <summary>
  3470. /// 团组增减款项操作(Status:1.新增,2.修改)
  3471. /// </summary>
  3472. /// <param name="dto"></param>
  3473. /// <returns></returns>
  3474. [HttpPost]
  3475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3476. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3477. {
  3478. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3479. if (groupData.Code != 200)
  3480. {
  3481. return Ok(JsonView(false, groupData.Msg));
  3482. }
  3483. #region 应用推送
  3484. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3485. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3486. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3487. //自动审核
  3488. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3489. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3490. //2024-10-21 新增LZ UID
  3491. var userIds = new List<int>() { 21 };
  3492. string title = $"系统通知";
  3493. string content = "";
  3494. var diId = dto.DiId;
  3495. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3496. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3497. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3498. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3499. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3500. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3501. #endregion
  3502. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3503. }
  3504. /// <summary>
  3505. /// 团组增减款项操作 删除
  3506. /// </summary>
  3507. /// <param name="dto"></param>
  3508. /// <returns></returns>
  3509. [HttpPost]
  3510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3511. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3512. {
  3513. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3514. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3515. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3516. if (res.Code == 0)
  3517. {
  3518. return Ok(JsonView(true, "删除成功!"));
  3519. }
  3520. return Ok(JsonView(false, "删除失败!"));
  3521. }
  3522. /// <summary>
  3523. /// 根据团组增减款项Id查询
  3524. /// </summary>
  3525. /// <param name="dto"></param>
  3526. /// <returns></returns>
  3527. [HttpPost]
  3528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3529. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3530. {
  3531. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3532. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3533. }
  3534. /// <summary>
  3535. /// 查询供应商名称
  3536. /// </summary>
  3537. /// <param name="dto"></param>
  3538. /// <returns></returns>
  3539. [HttpPost]
  3540. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3541. {
  3542. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3543. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3544. ?? new List<Grp_DecreasePayments>();
  3545. dbResult = dbResult.Distinct(new
  3546. ProductComparer()).ToList();
  3547. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3548. {
  3549. x.Id,
  3550. x.SupplierAddress,
  3551. x.SupplierArea,
  3552. x.SupplierContact,
  3553. x.SupplierContactNumber,
  3554. x.SupplierEmail,
  3555. x.SupplierName,
  3556. x.SupplierSocialAccount,
  3557. x.SupplierTypeId,
  3558. }).ToList());
  3559. return Ok(jw);
  3560. }
  3561. /// <summary>
  3562. /// 团组增减款项 OTA匹配
  3563. /// </summary>
  3564. /// <param name="file"></param>
  3565. /// <returns></returns>
  3566. [HttpPost]
  3567. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3568. {
  3569. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3570. string fileName = file.FileName;
  3571. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3572. {
  3573. return Ok(JsonView(false, "请上传Excel文件!"));
  3574. }
  3575. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3576. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3577. if (!Directory.Exists(path))
  3578. {
  3579. Directory.CreateDirectory(path);
  3580. }
  3581. var filePath = @$"{path}/{fileName}";
  3582. //保存文件
  3583. using (FileStream fs = System.IO.File.Create(filePath))
  3584. {
  3585. file.CopyTo(fs);
  3586. fs.Flush();
  3587. }
  3588. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3589. //读取ExcelFile
  3590. DataTable dt = ConvertExcelToDataTable(filePath);
  3591. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3592. dt.TableName = "TB";
  3593. //修改table列名
  3594. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3595. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3596. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3597. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3598. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3599. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3600. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3601. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3602. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3603. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3604. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3605. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3606. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3607. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3608. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3609. var otaOrderNos = new List<string>();
  3610. foreach (DataRow item in dt.Rows)
  3611. {
  3612. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3613. }
  3614. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3615. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3616. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3617. .Select((dp, di) => new
  3618. {
  3619. dp.PriceName,
  3620. dp.OTAOrderNo,
  3621. dp.FeeTotal,
  3622. di.TeamName,
  3623. })
  3624. .ToListAsync();
  3625. foreach (DataRow item in dt.Rows)
  3626. {
  3627. var otaOrderNo = item["OTAOrderNo"].ToString();
  3628. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3629. if (oaData == null) continue;
  3630. item["GroupName"] = oaData.TeamName;
  3631. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3632. }
  3633. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3634. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3635. List<DataTable> datas = new List<DataTable>();
  3636. datas.Add(dt);
  3637. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3638. return Ok(JsonView(true, "操作成功", new { url = url }));
  3639. }
  3640. #region
  3641. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3642. {
  3643. // 创建Workbook对象
  3644. Workbook workbook = new Workbook(excelFilePath);
  3645. // 获取第一个工作表
  3646. Worksheet worksheet = workbook.Worksheets[0];
  3647. // 将工作表转换为DataTable
  3648. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3649. return dataTable;
  3650. }
  3651. #endregion
  3652. #endregion
  3653. #region 文件上传、删除
  3654. /// <summary>
  3655. /// region 文件上传 可以带参数
  3656. /// </summary>
  3657. /// <param name="file"></param>
  3658. /// <returns></returns>
  3659. [HttpPost]
  3660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3661. public async Task<IActionResult> UploadProject(IFormFile file)
  3662. {
  3663. //var TypeName = Request.Headers["TypeName"].ToString();
  3664. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3665. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3666. ////文件名称
  3667. //string projectFileName = file.FileName;
  3668. ////上传的文件的路径
  3669. //string filePath = $"{fileDir}/{projectFileName}";
  3670. //if (TypeName == "A")//A代表团组增减款项
  3671. //{
  3672. // filePath = fileDir + $@"\团组增减款项相关文件";
  3673. // if (!Directory.Exists(filePath))
  3674. // {
  3675. // Directory.CreateDirectory(filePath);
  3676. // }
  3677. // //上传的文件的路径
  3678. // filePath += $@"\{projectFileName}";
  3679. //}
  3680. //else if (TypeName == "B")//B代表商邀相关文件
  3681. //{
  3682. // //上传的文件的路径
  3683. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3684. // if (!Directory.Exists(filePath))
  3685. // {
  3686. // Directory.CreateDirectory(filePath);
  3687. // }
  3688. // //上传的文件的路径
  3689. // filePath = $@"\{projectFileName}";
  3690. //}
  3691. //try
  3692. //{
  3693. // using (FileStream fs = System.IO.File.Create(filePath))
  3694. // {
  3695. // file.CopyTo(fs);
  3696. // fs.Flush();
  3697. // }
  3698. //}
  3699. //catch (Exception ex)
  3700. //{
  3701. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3702. //}
  3703. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3704. try
  3705. {
  3706. var TypeName = Request.Headers["TypeName"].ToString();
  3707. if (file != null)
  3708. {
  3709. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3710. //文件名称
  3711. string projectFileName = file.FileName;
  3712. //上传的文件的路径
  3713. string filePath = $"{fileDir}/{projectFileName}";
  3714. if (TypeName == "A")//A代表团组增减款项
  3715. {
  3716. if (!Directory.Exists(fileDir))
  3717. {
  3718. Directory.CreateDirectory(fileDir);
  3719. }
  3720. //上传的文件的路径
  3721. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3722. }
  3723. else if (TypeName == "B")//B代表商邀相关文件
  3724. {
  3725. if (!Directory.Exists(fileDir))
  3726. {
  3727. Directory.CreateDirectory(fileDir);
  3728. }
  3729. //上传的文件的路径
  3730. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3731. }
  3732. using (FileStream fs = System.IO.File.Create(filePath))
  3733. {
  3734. file.CopyTo(fs);
  3735. fs.Flush();
  3736. }
  3737. return Ok(JsonView(true, "上传成功!", projectFileName));
  3738. }
  3739. else
  3740. {
  3741. return Ok(JsonView(false, "上传失败!"));
  3742. }
  3743. }
  3744. catch (Exception ex)
  3745. {
  3746. return Ok(JsonView(false, "程序错误!"));
  3747. }
  3748. }
  3749. /// <summary>
  3750. /// 删除指定文件
  3751. /// </summary>
  3752. /// <param name="dto"></param>
  3753. /// <returns></returns>
  3754. [HttpPost]
  3755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3756. public async Task<IActionResult> DelFile(DelFileDto dto)
  3757. {
  3758. try
  3759. {
  3760. var TypeName = Request.Headers["TypeName"].ToString();
  3761. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3762. string filePath = "";
  3763. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3764. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3765. int id = 0;
  3766. if (TypeName == "A")
  3767. {
  3768. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3769. // 删除该文件
  3770. System.IO.File.Delete(filePath);
  3771. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3772. .Where(a => a.Id == dto.Id)
  3773. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3774. .ExecuteCommandAsync();
  3775. }
  3776. else if (TypeName == "B")
  3777. {
  3778. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3779. // 删除该文件
  3780. System.IO.File.Delete(filePath);
  3781. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3782. if (info != null)
  3783. {
  3784. string[] files = new string[] { };
  3785. if (!string.IsNullOrEmpty(info.Attachment))
  3786. {
  3787. try
  3788. {
  3789. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3790. }
  3791. catch (Exception)
  3792. {
  3793. files = new List<string>() { info.Attachment }.ToArray();
  3794. }
  3795. }
  3796. if (files.Length > 0)
  3797. {
  3798. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3799. string filePath2 = string.Empty;
  3800. if (files1.Length > 0)
  3801. {
  3802. filePath2 = JsonConvert.SerializeObject(files1);
  3803. }
  3804. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3805. .Where(a => a.Id == dto.Id)
  3806. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3807. .ExecuteCommandAsync();
  3808. }
  3809. }
  3810. }
  3811. if (id != 0)
  3812. {
  3813. return Ok(JsonView(true, "成功!"));
  3814. }
  3815. else
  3816. {
  3817. return Ok(JsonView(false, "失败!"));
  3818. }
  3819. }
  3820. catch (Exception ex)
  3821. {
  3822. return Ok(JsonView(false, "程序错误!"));
  3823. throw;
  3824. }
  3825. }
  3826. /// <summary>
  3827. /// 文件上传多个文件 可以带参数
  3828. /// </summary>
  3829. /// <param name="file"></param>
  3830. /// <returns></returns>
  3831. [HttpPost]
  3832. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3833. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3834. {
  3835. try
  3836. {
  3837. var TypeName = Request.Headers["TypeName"].ToString();
  3838. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3839. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3840. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3841. var filePahts = new List<string>();
  3842. foreach (var file in files)
  3843. {
  3844. //文件名称
  3845. string projectFileName = file.FileName;
  3846. //上传的文件的路径
  3847. string filePath = $"{fileDir}/{projectFileName}";
  3848. if (TypeName == "A")//A代表团组增减款项
  3849. {
  3850. if (!Directory.Exists(fileDir))
  3851. {
  3852. Directory.CreateDirectory(fileDir);
  3853. }
  3854. //上传的文件的路径
  3855. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3856. }
  3857. else if (TypeName == "B")//B代表商邀相关文件
  3858. {
  3859. if (!Directory.Exists(fileDir))
  3860. {
  3861. Directory.CreateDirectory(fileDir);
  3862. }
  3863. //上传的文件的路径
  3864. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3865. }
  3866. using (FileStream fs = System.IO.File.Create(filePath))
  3867. {
  3868. file.CopyTo(fs);
  3869. fs.Flush();
  3870. }
  3871. filePahts.Add(projectFileName);
  3872. }
  3873. return Ok(JsonView(true, "上传成功!", filePahts));
  3874. }
  3875. catch (Exception ex)
  3876. {
  3877. return Ok(JsonView(false, "程序错误!"));
  3878. }
  3879. }
  3880. #endregion
  3881. #region 商邀费用录入
  3882. /// <summary>
  3883. /// 根据团组Id查询商邀费用列表
  3884. /// </summary>
  3885. /// <param name="dto"></param>
  3886. /// <returns></returns>
  3887. [HttpPost]
  3888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3889. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3890. {
  3891. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3892. if (groupData.Code != 0)
  3893. {
  3894. return Ok(JsonView(false, groupData.Msg));
  3895. }
  3896. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3897. }
  3898. /// <summary>
  3899. /// 商邀费用列表
  3900. /// 下载文件
  3901. /// </summary>
  3902. /// <param name="dto"></param>
  3903. /// <returns></returns>
  3904. [HttpGet("{id}")]
  3905. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3906. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3907. {
  3908. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3909. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3910. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3911. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3912. var filePaths = new List<string>();
  3913. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3914. try
  3915. {
  3916. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3917. }
  3918. catch (Exception ex)
  3919. {
  3920. filePaths.Add(info.Attachment);
  3921. }
  3922. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3923. for (int i = 0; i < filePaths.Count; i++)
  3924. {
  3925. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3926. }
  3927. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3928. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3929. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3930. {
  3931. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3932. {
  3933. foreach (string filePath in filePaths)
  3934. {
  3935. if (System.IO.File.Exists(filePath))
  3936. {
  3937. // 获取文件名
  3938. string fileName = Path.GetFileName(filePath);
  3939. // 将文件添加到ZIP归档中
  3940. zipArchive.CreateEntryFromFile(filePath, fileName);
  3941. }
  3942. }
  3943. }
  3944. }
  3945. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3946. }
  3947. /// <summary>
  3948. /// 商邀费用 Info Page 基础数据源
  3949. /// </summary>
  3950. /// <param name="dto"></param>
  3951. /// <returns></returns>
  3952. [HttpPost]
  3953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3954. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3955. {
  3956. try
  3957. {
  3958. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3959. if (groupData.Code != 0)
  3960. {
  3961. return Ok(JsonView(false, groupData.Msg));
  3962. }
  3963. return Ok(JsonView(true, "操作成功", groupData.Data));
  3964. }
  3965. catch (Exception ex)
  3966. {
  3967. return Ok(JsonView(false, ex.Message));
  3968. throw;
  3969. }
  3970. }
  3971. /// <summary>
  3972. /// 根据商邀费用ID查询C表和商邀费用数据
  3973. /// </summary>
  3974. /// <param name="dto"></param>
  3975. /// <returns></returns>
  3976. [HttpPost]
  3977. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3978. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3979. {
  3980. try
  3981. {
  3982. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3983. if (groupData.Code != 0)
  3984. {
  3985. return Ok(JsonView(false, groupData.Msg));
  3986. }
  3987. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3988. }
  3989. catch (Exception ex)
  3990. {
  3991. return Ok(JsonView(false, ex.Message));
  3992. throw;
  3993. }
  3994. }
  3995. /// <summary>
  3996. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3997. /// </summary>
  3998. /// <param name="dto"></param>
  3999. /// <returns></returns>
  4000. [HttpPost]
  4001. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4002. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4003. {
  4004. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4005. if (groupData.Code != 0)
  4006. {
  4007. return Ok(JsonView(false, groupData.Msg));
  4008. }
  4009. #region 应用推送
  4010. try
  4011. {
  4012. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4013. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4014. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4015. //2024-10-21 新增LZ UID
  4016. var userIds = new List<int>() { 21 };
  4017. string title = $"系统通知";
  4018. string content = "";
  4019. var diId = dto.DiId;
  4020. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4021. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4022. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4023. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4024. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4025. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4026. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4027. }
  4028. catch (Exception ex)
  4029. {
  4030. }
  4031. #endregion
  4032. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4033. }
  4034. /// <summary>
  4035. /// 商邀删除
  4036. /// </summary>
  4037. /// <param name="dto"></param>
  4038. /// <returns></returns>
  4039. [HttpPost]
  4040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4041. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4042. {
  4043. try
  4044. {
  4045. _sqlSugar.BeginTran();
  4046. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4047. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4048. {
  4049. IsDel = 1,
  4050. DeleteUserId = dto.DeleteUserId,
  4051. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4052. })
  4053. .Where(it => it.Id == dto.Id)
  4054. .ExecuteCommand();
  4055. if (res1 > 0)
  4056. {
  4057. int _diId = 0;
  4058. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4059. if (_ioaInfo != null)
  4060. {
  4061. _diId = _ioaInfo.DiId;
  4062. }
  4063. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4064. .SetColumns(a => new Grp_CreditCardPayment()
  4065. {
  4066. IsDel = 1,
  4067. DeleteUserId = dto.DeleteUserId,
  4068. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4069. })
  4070. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4071. .ExecuteCommand();
  4072. if (res2 > 0)
  4073. {
  4074. _sqlSugar.CommitTran();
  4075. return Ok(JsonView(true, "删除成功!"));
  4076. }
  4077. }
  4078. _sqlSugar.RollbackTran();
  4079. return Ok(JsonView(false, "删除失败"));
  4080. }
  4081. catch (Exception ex)
  4082. {
  4083. _sqlSugar.RollbackTran();
  4084. return Ok(JsonView(false, ex.Message));
  4085. }
  4086. }
  4087. /// <summary>
  4088. /// 团组模块文件上传
  4089. /// </summary>
  4090. /// <param name="dto"></param>
  4091. /// <returns></returns>
  4092. [HttpPost]
  4093. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4094. {
  4095. var jw = JsonView(false);
  4096. long M = 1024 * 1024;
  4097. if (dto.Files == null || dto.Files.Count == 0)
  4098. {
  4099. jw.Msg = "无文件信息!";
  4100. return Ok(jw);
  4101. }
  4102. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4103. {
  4104. jw.Msg = "文件大小超过20M!";
  4105. return Ok(jw);
  4106. }
  4107. //var nameSp = dto.File.FileName.Split(".");
  4108. //if (nameSp.Length < 2)
  4109. //{
  4110. // jw.Msg = "拓展名称有误!";
  4111. // return Ok(jw);
  4112. //}
  4113. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4114. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4115. //{
  4116. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4117. // return Ok(jw);
  4118. //}
  4119. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4120. if (Ctable == null)
  4121. {
  4122. jw.Msg = "Ctable指向有误!";
  4123. return Ok(jw);
  4124. }
  4125. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4126. if (groupInfo == null)
  4127. {
  4128. jw.Msg = "团组信息不存在!";
  4129. return Ok(jw);
  4130. }
  4131. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4132. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4133. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4134. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4135. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4136. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4137. try
  4138. {
  4139. if (!Directory.Exists(fileBase))
  4140. {
  4141. Directory.CreateDirectory(fileBase);
  4142. }
  4143. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4144. foreach (var fileStream in dto.Files)
  4145. {
  4146. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4147. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4148. {
  4149. Cid = dto.Cid,
  4150. CreateTime = DateTime.Now,
  4151. CreateUserId = dto.Userid,
  4152. Ctable = dto.Ctable,
  4153. Diid = dto.Diid,
  4154. IsDel = 0,
  4155. FilePath = saveFilePath,
  4156. FileName = fileStream.FileName
  4157. };
  4158. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4159. {
  4160. fileStream.CopyTo(fs);
  4161. fs.Flush();
  4162. }
  4163. saveArr.Add(file);
  4164. }
  4165. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4166. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4167. jw = JsonView(true, "保存成功!", new
  4168. {
  4169. count = addResult,
  4170. filesName = saveArr.Select(x => x.FileName)
  4171. });
  4172. }
  4173. catch (Exception ex)
  4174. {
  4175. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4176. {
  4177. count = 0,
  4178. filesName = new string[0],
  4179. });
  4180. }
  4181. return Ok(jw);
  4182. }
  4183. /// <summary>
  4184. /// 查询各模块已保存文件
  4185. /// </summary>
  4186. /// <param name="dto"></param>
  4187. /// <returns></returns>
  4188. [HttpPost]
  4189. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4190. {
  4191. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4192. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4193. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4194. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4195. {
  4196. expression = Expressionable.Create<Grp_GroupModelFile>()
  4197. .And(x => visaIds.Contains(x.CreateUserId));
  4198. }
  4199. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4200. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4201. .Where(expression.ToExpression())
  4202. .ToList();
  4203. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4204. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4205. {
  4206. x.FileName,
  4207. x.Id,
  4208. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4209. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4210. })));
  4211. }
  4212. /// <summary>
  4213. /// 下载该团组下的所有文件
  4214. /// </summary>
  4215. /// <param name="dto"></param>
  4216. /// <returns></returns>
  4217. [HttpPost]
  4218. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4219. {
  4220. var jw = JsonView(false);
  4221. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4222. if (groupInfo == null)
  4223. {
  4224. jw.Msg = "团组信息不存在!";
  4225. return Ok(jw);
  4226. }
  4227. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4228. var isModule = Convert.ToBoolean(dto.isModule);
  4229. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4230. IOOperatorHelper io = new IOOperatorHelper();
  4231. if (isModule)
  4232. {
  4233. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4234. foreach (var moduleArr in moduleGroup)
  4235. {
  4236. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4237. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4238. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4239. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4240. foreach (var item in moduleArr)
  4241. {
  4242. if (System.IO.File.Exists(item.FilePath))
  4243. {
  4244. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4245. {
  4246. byte[] bytes = new byte[fileStream.Length];
  4247. fileStream.Read(bytes, 0, bytes.Length);
  4248. fileStream.Close();
  4249. Stream stream = new MemoryStream(bytes);
  4250. chiZips.Add(item.FileName, stream);
  4251. }
  4252. }
  4253. }
  4254. if (chiZips.Count > 0)
  4255. {
  4256. var byts = io.ConvertZipStream(chiZips);
  4257. Stream stream = new MemoryStream(byts);
  4258. Zips.Add(key.Name + "_.zip", stream);
  4259. }
  4260. }
  4261. }
  4262. else
  4263. {
  4264. foreach (var item in dbQuery)
  4265. {
  4266. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4267. {
  4268. byte[] bytes = new byte[fileStream.Length];
  4269. fileStream.Read(bytes, 0, bytes.Length);
  4270. fileStream.Close();
  4271. Stream stream = new MemoryStream(bytes);
  4272. while (Zips.Keys.Contains(item.FileName))
  4273. {
  4274. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4275. }
  4276. Zips.Add(item.FileName, stream);
  4277. }
  4278. }
  4279. }
  4280. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4281. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4282. if (Zips.Count > 0)
  4283. {
  4284. var byts = io.ConvertZipStream(Zips);
  4285. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4286. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4287. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4288. }
  4289. else
  4290. {
  4291. jw.Msg = "暂无生成文件!";
  4292. }
  4293. return Ok(jw);
  4294. }
  4295. /// <summary>
  4296. /// 下载该团组下此模块的所有文件
  4297. /// </summary>
  4298. /// <param name="dto"></param>
  4299. /// <returns></returns>
  4300. [HttpPost]
  4301. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4302. {
  4303. var jw = JsonView(false);
  4304. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4305. if (groupInfo == null)
  4306. {
  4307. jw.Msg = "团组信息不存在!";
  4308. return Ok(jw);
  4309. }
  4310. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4311. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4312. && x.IsDel == 0);
  4313. if (key == null)
  4314. {
  4315. jw.Msg = "Ctable指向错误!";
  4316. return Ok(jw);
  4317. }
  4318. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4319. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4320. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4321. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4322. IOOperatorHelper io = new IOOperatorHelper();
  4323. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4324. foreach (var item in dbQuery)
  4325. {
  4326. if (System.IO.File.Exists(item.FilePath))
  4327. {
  4328. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4329. {
  4330. byte[] bytes = new byte[fileStream.Length];
  4331. fileStream.Read(bytes, 0, bytes.Length);
  4332. fileStream.Close();
  4333. Stream stream = new MemoryStream(bytes);
  4334. while (Zips.Keys.Contains(item.FileName))
  4335. {
  4336. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4337. }
  4338. Zips.Add(item.FileName, stream);
  4339. }
  4340. }
  4341. }
  4342. if (Zips.Count > 0)
  4343. {
  4344. var byts = io.ConvertZipStream(Zips);
  4345. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4346. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4347. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4348. }
  4349. else
  4350. {
  4351. jw.Msg = "暂无生成文件!";
  4352. }
  4353. return Ok(jw);
  4354. }
  4355. /// <summary>
  4356. /// 删除该团组下的指定文件
  4357. /// </summary>
  4358. /// <param name="dto"></param>
  4359. /// <returns></returns>
  4360. [HttpPost]
  4361. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4362. {
  4363. var jw = JsonView(false);
  4364. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4365. if (sing == null)
  4366. {
  4367. jw.Msg = "暂无";
  4368. return Ok(jw);
  4369. }
  4370. if (System.IO.File.Exists(sing.FilePath))
  4371. {
  4372. try
  4373. {
  4374. System.IO.File.Delete(sing.FilePath);
  4375. }
  4376. catch (Exception ex)
  4377. {
  4378. jw.Msg = "删除失败!" + ex.Message;
  4379. return Ok(jw);
  4380. }
  4381. }
  4382. sing.IsDel = 1;
  4383. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4384. sing.DeleteUserId = dto.UserId;
  4385. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4386. jw = JsonView(true, "删除成功!");
  4387. return Ok(jw);
  4388. }
  4389. #endregion
  4390. #region 团组英文资料
  4391. /// <summary>
  4392. /// 查询团组英文所有资料
  4393. /// </summary>
  4394. /// <param name="dto"></param>
  4395. /// <returns></returns>
  4396. [HttpPost]
  4397. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4398. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4399. {
  4400. try
  4401. {
  4402. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4403. if (groupData.Code != 0)
  4404. {
  4405. return Ok(JsonView(false, groupData.Msg));
  4406. }
  4407. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4408. }
  4409. catch (Exception ex)
  4410. {
  4411. return Ok(JsonView(false, "程序错误!"));
  4412. throw;
  4413. }
  4414. }
  4415. /// <summary>
  4416. /// 团组英文资料操作(Status:1.新增,2.修改)
  4417. /// </summary>
  4418. /// <param name="dto"></param>
  4419. /// <returns></returns>
  4420. [HttpPost]
  4421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4422. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4423. {
  4424. try
  4425. {
  4426. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4427. if (groupData.Code != 0)
  4428. {
  4429. return Ok(JsonView(false, groupData.Msg));
  4430. }
  4431. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4432. }
  4433. catch (Exception ex)
  4434. {
  4435. return Ok(JsonView(false, "程序错误!"));
  4436. throw;
  4437. }
  4438. }
  4439. /// <summary>
  4440. /// 团组英文资料Id查询数据
  4441. /// </summary>
  4442. /// <param name="dto"></param>
  4443. /// <returns></returns>
  4444. [HttpPost]
  4445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4446. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4447. {
  4448. try
  4449. {
  4450. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4451. if (_DelegationEnData != null)
  4452. {
  4453. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4454. }
  4455. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4456. }
  4457. catch (Exception ex)
  4458. {
  4459. return Ok(JsonView(false, "程序错误!"));
  4460. throw;
  4461. }
  4462. }
  4463. /// <summary>
  4464. /// 团组英文资料删除
  4465. /// </summary>
  4466. /// <param name="dto"></param>
  4467. /// <returns></returns>
  4468. [HttpPost]
  4469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4470. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4471. {
  4472. try
  4473. {
  4474. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4475. if (!res)
  4476. {
  4477. return Ok(JsonView(false, "删除失败"));
  4478. }
  4479. return Ok(JsonView(true, "删除成功!"));
  4480. }
  4481. catch (Exception ex)
  4482. {
  4483. return Ok(JsonView(false, "程序错误!"));
  4484. throw;
  4485. }
  4486. }
  4487. #endregion
  4488. #region 导出邀请函
  4489. /// <summary>
  4490. /// 导出邀请函页面初始化
  4491. /// </summary>
  4492. /// <param name="dto"></param>
  4493. /// <returns></returns>
  4494. [HttpPost]
  4495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4496. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4497. {
  4498. try
  4499. {
  4500. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4501. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4502. if (dto.DiId == 0)
  4503. {
  4504. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4505. }
  4506. else
  4507. {
  4508. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4509. }
  4510. return Ok(JsonView(true, "查询成功!", new
  4511. {
  4512. deleClient = crm_Deles,
  4513. delegations = grp_Delegations
  4514. }));
  4515. }
  4516. catch (Exception ex)
  4517. {
  4518. return Ok(JsonView(false, "程序错误!"));
  4519. throw;
  4520. }
  4521. }
  4522. /// <summary>
  4523. /// 导出邀请函
  4524. /// </summary>
  4525. /// <param name="dto"></param>
  4526. /// <returns></returns>
  4527. [HttpPost]
  4528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4529. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4530. {
  4531. #region 参数验证
  4532. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4533. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4534. #endregion
  4535. try
  4536. {
  4537. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4538. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4539. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4540. From Grp_TourClientList tcl
  4541. Left Join
  4542. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4543. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4544. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4545. From Crm_DeleClient dc
  4546. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4547. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4548. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4549. Where dc.IsDel = 0) temp
  4550. On temp.DcId =tcl.ClientId
  4551. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4552. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4553. List<string> texts = new List<string>();
  4554. if (datas.Count != 0)
  4555. {
  4556. foreach (TourClientListDetailsView item in datas)
  4557. {
  4558. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4559. {
  4560. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4561. }
  4562. else
  4563. {
  4564. string name = item.LastName + item.FirstName;
  4565. texts.Add(name);
  4566. }
  4567. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4568. {
  4569. if (!transDic.ContainsKey(item.Job))
  4570. {
  4571. texts.Add(item.Job);
  4572. }
  4573. }
  4574. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4575. {
  4576. texts.Add(item.CompanyFullName);
  4577. }
  4578. }
  4579. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4580. if (transData.Count > 0)
  4581. {
  4582. foreach (TranslateResult item in transData)
  4583. {
  4584. if (!transDic.ContainsKey(item.Query))
  4585. {
  4586. transDic.Add(item.Query, item.Translation);
  4587. }
  4588. }
  4589. }
  4590. List<GuestList> list = new List<GuestList>();
  4591. foreach (TourClientListDetailsView dele in datas)
  4592. {
  4593. GuestList guestList = new GuestList();
  4594. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4595. {
  4596. guestList.Name = dele.Pinyin;
  4597. }
  4598. else
  4599. {
  4600. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4601. guestList.Name = Name;
  4602. }
  4603. if (dele.Sex == 0)
  4604. {
  4605. guestList.Sex = "Male";
  4606. }
  4607. else if (dele.Sex == 1)
  4608. {
  4609. guestList.Sex = "Female";
  4610. }
  4611. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4612. if (!string.IsNullOrEmpty(dele.Job))
  4613. {
  4614. guestList.Job = dele.Job;
  4615. }
  4616. list.Add(guestList);
  4617. }
  4618. //载入模板
  4619. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4620. DocumentBuilder builder = new DocumentBuilder(doc);
  4621. //获取word里所有表格
  4622. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4623. //获取所填表格的序数
  4624. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4625. var rowStart = tableOne.Rows[0]; //获取第1行
  4626. //循环赋值
  4627. for (int i = 0; i < list.Count; i++)
  4628. {
  4629. builder.MoveToCell(0, i + 1, 0, 0);
  4630. builder.Write(list[i].Name.ToString());
  4631. builder.MoveToCell(0, i + 1, 1, 0);
  4632. builder.Write(list[i].Sex.ToString());
  4633. builder.MoveToCell(0, i + 1, 2, 0);
  4634. builder.Write(list[i].DOB.ToString());
  4635. builder.MoveToCell(0, i + 1, 3, 0);
  4636. builder.Write(list[i].Job.ToString());
  4637. }
  4638. //删除多余行
  4639. while (tableOne.Rows.Count > list.Count + 1)
  4640. {
  4641. tableOne.Rows.RemoveAt(list.Count + 1);
  4642. }
  4643. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4644. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4645. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4646. doc.Save(filePath);
  4647. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4648. return Ok(JsonView(true, "操作成功!", Url));
  4649. }
  4650. else
  4651. {
  4652. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4653. }
  4654. }
  4655. catch (Exception ex)
  4656. {
  4657. return Ok(JsonView(false, ex.Message));
  4658. throw;
  4659. }
  4660. }
  4661. #endregion
  4662. #region 团组经理模块 出入境费用
  4663. /// <summary>
  4664. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4665. /// </summary>
  4666. /// <returns></returns>
  4667. [HttpPost]
  4668. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4669. public async Task<IActionResult> SetDayAndCostAreaChange()
  4670. {
  4671. try
  4672. {
  4673. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4674. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4675. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4676. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4677. foreach (var item in unite) //处理交集数据
  4678. {
  4679. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4680. }
  4681. foreach (var item in merge) //处理差集数据
  4682. {
  4683. int nationalTravelFeeId = 0;
  4684. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4685. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4686. else
  4687. {
  4688. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4689. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4690. }
  4691. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4692. }
  4693. //只更新dayAndCost 的 nationalTravelFeeId;
  4694. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4695. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4696. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4697. }
  4698. catch (Exception ex)
  4699. {
  4700. return Ok(JsonView(false, ex.Message));
  4701. throw;
  4702. }
  4703. }
  4704. /// <summary>
  4705. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4706. /// </summary>
  4707. /// <returns></returns>
  4708. [HttpPost]
  4709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4710. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4711. {
  4712. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4713. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4714. //SetDataInfoView
  4715. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4716. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4717. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4718. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4719. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4720. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4721. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4722. //默认币种显示
  4723. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4724. {
  4725. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4726. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4727. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4728. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4729. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4730. };
  4731. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4732. if (_currencyRate.Count > 0)
  4733. {
  4734. foreach (var item in _currencyInfos)
  4735. {
  4736. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4737. if (rateInfo != null)
  4738. {
  4739. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4740. rate1 *= 1.035M;
  4741. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4742. }
  4743. }
  4744. }
  4745. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4746. return Ok(JsonView(true, "查询成功!", new
  4747. {
  4748. GroupNameData = groupNameData.Data,
  4749. CurrencyData = _CurrencyData,
  4750. WordTypeData = _WordTypeData,
  4751. ExcelTypeData = _ExcelTypeData,
  4752. CurrencyInit = _currencyInfos,
  4753. ViewPermissionData = viewPermissionData
  4754. }));
  4755. }
  4756. /// <summary>
  4757. /// 团组模块 - 出入境费用
  4758. /// 实时汇率 tips
  4759. /// 签证费用 tips
  4760. /// 机票费用 tips
  4761. /// </summary>
  4762. /// <returns></returns>
  4763. [HttpPost]
  4764. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4765. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4766. {
  4767. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4768. //默认币种显示
  4769. var _currencyInfos = _currencyInit;
  4770. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4771. List<dynamic> reteInfos = new List<dynamic>();
  4772. if (_currencyRate.Count > 0)
  4773. {
  4774. foreach (var item in _currencyInfos)
  4775. {
  4776. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4777. if (rateInfo != null)
  4778. {
  4779. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4780. decimal rate1 = item.Rate;
  4781. rate1 *= 1.03M;
  4782. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4783. reteInfos.Add(new
  4784. {
  4785. currCode = item.CurrencyCode,
  4786. currName = item.CurrencyName,
  4787. rate = rate2,
  4788. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4789. });
  4790. }
  4791. }
  4792. }
  4793. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4794. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4795. return Ok(JsonView(true, "查询成功!", new
  4796. {
  4797. //GroupNameData = groupNameData.Data,
  4798. visaData = visaData.Data,
  4799. airData = airData.Data,
  4800. reteInfos = reteInfos
  4801. }));
  4802. }
  4803. /// <summary>
  4804. /// 团组模块 - 出入境费用 - Info
  4805. /// </summary>
  4806. /// <returns></returns>
  4807. [HttpPost]
  4808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4809. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4810. {
  4811. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4812. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4813. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4814. }
  4815. /// <summary>
  4816. /// 团组模块 - 出入境费用 - 设置view权限
  4817. /// </summary>
  4818. /// <returns></returns>
  4819. [HttpPost]
  4820. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4821. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4822. {
  4823. if (dto.CurrUserId < 1) return Ok(JsonView(false,MsgTips.UserId));
  4824. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4825. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4826. var permissions = new List<Grp_EnterExitCostPermission>();
  4827. foreach (var userId in dto.UserIds)
  4828. {
  4829. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  4830. }
  4831. if (permissions.Any())
  4832. {
  4833. _sqlSugar.BeginTran();
  4834. try
  4835. {
  4836. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  4837. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  4838. if (result < 1)
  4839. {
  4840. _sqlSugar.RollbackTran();
  4841. return Ok(JsonView(false));
  4842. }
  4843. }
  4844. catch (Exception ex)
  4845. {
  4846. _sqlSugar.RollbackTran();
  4847. return Ok(JsonView(false, ex.Message));
  4848. }
  4849. _sqlSugar.CommitTran();
  4850. return Ok(JsonView(true));
  4851. }
  4852. return Ok(JsonView(false));
  4853. }
  4854. /// <summary>
  4855. /// 团组模块 - 出入境费用 - Add And Update
  4856. /// </summary>
  4857. /// <returns></returns>
  4858. [HttpPost]
  4859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4860. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4861. {
  4862. try
  4863. {
  4864. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4865. if (dto.DayOtherPriceData.Any())
  4866. {
  4867. var inserList = dto.DayOtherPriceData
  4868. .Where(x => x.Id == 0)
  4869. .Select(x => new Grp_DayOtherPrice
  4870. {
  4871. Cost = x.Cost,
  4872. Id = x.Id,
  4873. CreateTime = DateTime.Now,
  4874. CreateUserId = dto.UserId,
  4875. Currency = x.Currency,
  4876. Diid = x.DiId,
  4877. Index = x.Index,
  4878. IsDel = 0,
  4879. SetDataId = x.SetDataId,
  4880. SubTotal = x.SubTotal,
  4881. Remark = x.Remark
  4882. })
  4883. .ToList();
  4884. var updateList = dto.DayOtherPriceData
  4885. .Where(x => x.Id != 0)
  4886. .Select(x => new Grp_DayOtherPrice
  4887. {
  4888. Cost = x.Cost,
  4889. Id = x.Id,
  4890. CreateTime = DateTime.Now,
  4891. CreateUserId = dto.UserId,
  4892. Currency = x.Currency,
  4893. Diid = x.DiId,
  4894. Index = x.Index,
  4895. IsDel = 0,
  4896. SetDataId = x.SetDataId,
  4897. SubTotal = x.SubTotal,
  4898. Remark = x.Remark
  4899. })
  4900. .ToList();
  4901. //添加
  4902. _sqlSugar.BeginTran();
  4903. if (inserList.Any())
  4904. {
  4905. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4906. }
  4907. if (updateList.Any())
  4908. {
  4909. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4910. }
  4911. _sqlSugar.CommitTran();
  4912. }
  4913. if (data.Code != 0)
  4914. {
  4915. return Ok(JsonView(false, data.Msg));
  4916. }
  4917. //生成默认文件pdf并且通知人员
  4918. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4919. {
  4920. DiId = dto.DiId,
  4921. ExportType = 1,
  4922. SubTypeId = 1005
  4923. }, "pdf");
  4924. //发送通知
  4925. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4926. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4927. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4928. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4929. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4930. //汇率信息记录
  4931. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4932. return Ok(JsonView(true, data.Msg, data.Data));
  4933. }
  4934. catch (Exception ex)
  4935. {
  4936. return Ok(JsonView(false, ex.Message));
  4937. }
  4938. }
  4939. /// <summary>
  4940. /// 团组模块 - 出入境费用 - Confirm 费用
  4941. /// </summary>
  4942. /// <returns></returns>
  4943. [HttpPost]
  4944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4945. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4946. {
  4947. //TODO:测试完毕需把对应的用户ID更改
  4948. //1、数据表添加字段
  4949. //2、更改字段接口()
  4950. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4951. //3、确认成功 给财务发送消息
  4952. if (_view.Code == 200)
  4953. {
  4954. if (dto.Type == 1)
  4955. {
  4956. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4957. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4958. }
  4959. }
  4960. return Ok(_view);
  4961. }
  4962. /// <summary>
  4963. /// 团组模块 - 出入境费用 - File download
  4964. /// </summary>
  4965. /// <param name="dto"></param>
  4966. /// <returns></returns>
  4967. [HttpPost]
  4968. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4969. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4970. {
  4971. try
  4972. {
  4973. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4974. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4975. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4976. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4977. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4978. 3 团组成员名单 1 团组成员名单", ""));
  4979. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  4980. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4981. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4982. //数据源
  4983. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4984. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4985. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4986. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4987. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4988. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4989. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  4990. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4991. .Select((x, a, b) => new
  4992. {
  4993. x.Index,
  4994. itemName = a.Name,
  4995. CurrencyStr = b.Name,
  4996. x.Cost,
  4997. x.SubTotal,
  4998. x.Remark
  4999. })
  5000. .OrderBy((x) => x.Index)
  5001. .ToList(); //其他款项费用
  5002. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5003. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5004. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5005. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5006. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5007. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5008. .Select((tcl, dc, cc) => new ClientInfo
  5009. {
  5010. LastName = dc.LastName,
  5011. FirstName = dc.FirstName,
  5012. Sex = dc.Sex,
  5013. Birthday = dc.BirthDay,
  5014. Company = cc.CompanyFullName,
  5015. Job = dc.Job
  5016. })
  5017. .ToList();
  5018. foreach (var item in DeleClientList)
  5019. {
  5020. EncryptionProcessor.DecryptProperties(item);
  5021. }
  5022. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5023. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5024. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5025. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5026. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5027. if (dto.ExportType == 1) //明细表
  5028. {
  5029. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5030. {
  5031. //获取模板
  5032. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5033. //载入模板
  5034. Document doc = new Document(tempPath);
  5035. DocumentBuilder builder = new DocumentBuilder(doc);
  5036. //利用键值对存放数据
  5037. Dictionary<string, string> dic = new Dictionary<string, string>();
  5038. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5039. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5040. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5041. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5042. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5043. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5044. //境内费用(其他费用)
  5045. if (_EnterExitCosts.ChoiceOne == 1)
  5046. {
  5047. string row1_1 = "";
  5048. if (_EnterExitCosts.Visa > 0)
  5049. {
  5050. //insidePayTotal += _EnterExitCosts.Visa;
  5051. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5052. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5053. {
  5054. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5055. }
  5056. }
  5057. string row1_2 = "";
  5058. if (_EnterExitCosts.YiMiao > 0)
  5059. {
  5060. //insidePayTotal += _EnterExitCosts.YiMiao;
  5061. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5062. }
  5063. if (_EnterExitCosts.HeSuan > 0)
  5064. {
  5065. //insidePayTotal += _EnterExitCosts.HeSuan;
  5066. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5067. }
  5068. if (_EnterExitCosts.Service > 0)
  5069. {
  5070. //insidePayTotal += _EnterExitCosts.Service;
  5071. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5072. }
  5073. string row1_3 = "";
  5074. if (_EnterExitCosts.Safe > 0)
  5075. {
  5076. //insidePayTotal += _EnterExitCosts.Safe;
  5077. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5078. }
  5079. if (_EnterExitCosts.Ticket > 0)
  5080. {
  5081. //insidePayTotal += _EnterExitCosts.Ticket;
  5082. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5083. }
  5084. string row1 = "";
  5085. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5086. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5087. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5088. row1 += $"备注:{_EnterExitCosts.Remark}";
  5089. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5090. dic.Add("Row1Str", row1);
  5091. }
  5092. string airTotalStr = string.Empty,
  5093. airPriceStr = string.Empty;
  5094. //经济舱
  5095. if (_EnterExitCosts.SumJJC == 1)
  5096. {
  5097. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5098. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5099. }
  5100. //公务舱
  5101. if (_EnterExitCosts.SumGWC == 1)
  5102. {
  5103. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5104. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5105. }
  5106. //头等舱
  5107. if (_EnterExitCosts.SumTDC == 1)
  5108. {
  5109. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5110. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5111. }
  5112. string twoItemRemark = "备注:";
  5113. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark))
  5114. {
  5115. twoItemRemark = _EnterExitCosts.TwoItemRemark;
  5116. }
  5117. dic.Add("AirTotalStr", airTotalStr);
  5118. dic.Add("AirPriceStr", airPriceStr);
  5119. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5120. dic.Add("TwoItemRemark", twoItemRemark);
  5121. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5122. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5123. int table1Row = 0,
  5124. table2Row = 0,
  5125. table3Row = 0,
  5126. table4Row = 0,
  5127. table5Row = 0;
  5128. //住宿费
  5129. if (_EnterExitCosts.ChoiceThree == 1)
  5130. {
  5131. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5132. table1Row = dac1.Count;
  5133. #region 填充word表格内容
  5134. for (int i = 0; i < dac1.Count; i++)
  5135. {
  5136. Grp_DayAndCost dac = dac1[i];
  5137. if (dac == null) continue;
  5138. builder.MoveToCell(0, i, 0, 0);
  5139. builder.Write("第" + dac.Days.ToString() + "晚:");
  5140. builder.MoveToCell(0, i, 1, 0);
  5141. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5142. //builder.Write(dac.Place == null ? "" : dac.Place);
  5143. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5144. builder.MoveToCell(0, i, 2, 0);
  5145. builder.Write("费用标准:");
  5146. string curr = "";
  5147. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5148. if (currData != null)
  5149. {
  5150. curr = currData.Name;
  5151. }
  5152. builder.MoveToCell(0, i, 3, 0);
  5153. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5154. builder.MoveToCell(0, i, 4, 0);
  5155. builder.Write("费用小计:");
  5156. builder.MoveToCell(0, i, 5, 0);
  5157. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5158. }
  5159. #endregion
  5160. }
  5161. else dic.Add("SubZS", "0.00");
  5162. //删除多余行
  5163. while (table1.Rows.Count > table1Row)
  5164. {
  5165. table1.Rows.RemoveAt(table1Row);
  5166. }
  5167. //伙食费
  5168. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5169. if (_EnterExitCosts.ChoiceFour == 1)
  5170. {
  5171. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5172. table2Row = dac2.Count;
  5173. #region 填充word表格内容
  5174. for (int i = 0; i < dac2.Count; i++)
  5175. {
  5176. Grp_DayAndCost dac = dac2[i];
  5177. if (dac == null) continue;
  5178. builder.MoveToCell(1, i, 0, 0);
  5179. builder.Write("第" + dac.Days.ToString() + "天:");
  5180. builder.MoveToCell(1, i, 1, 0);
  5181. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5182. builder.MoveToCell(1, i, 2, 0);
  5183. builder.Write("费用标准:");
  5184. string curr = "";
  5185. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5186. if (currData != null)
  5187. {
  5188. curr = currData.Name;
  5189. }
  5190. builder.MoveToCell(1, i, 3, 0);
  5191. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5192. builder.MoveToCell(1, i, 4, 0);
  5193. builder.Write("费用小计:");
  5194. builder.MoveToCell(1, i, 5, 0);
  5195. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5196. }
  5197. #endregion
  5198. }
  5199. else dic.Add("SubHS", "0.00");
  5200. //删除多余行
  5201. while (table2.Rows.Count > table2Row)
  5202. {
  5203. table2.Rows.RemoveAt(table2Row);
  5204. }
  5205. //公杂费
  5206. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5207. if (_EnterExitCosts.ChoiceFive == 1)
  5208. {
  5209. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5210. table3Row = dac3.Count;
  5211. #region 填充word表格内容
  5212. for (int i = 0; i < dac3.Count; i++)
  5213. {
  5214. Grp_DayAndCost dac = dac3[i];
  5215. if (dac == null) continue;
  5216. builder.MoveToCell(2, i, 0, 0);
  5217. builder.Write("第" + dac.Days.ToString() + "天:");
  5218. builder.MoveToCell(2, i, 1, 0);
  5219. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5220. builder.MoveToCell(2, i, 2, 0);
  5221. builder.Write("费用标准:");
  5222. string curr = "";
  5223. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5224. if (currData != null)
  5225. {
  5226. curr = currData.Name;
  5227. }
  5228. builder.MoveToCell(2, i, 3, 0);
  5229. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5230. builder.MoveToCell(2, i, 4, 0);
  5231. builder.Write("费用小计:");
  5232. builder.MoveToCell(2, i, 5, 0);
  5233. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5234. }
  5235. //删除多余行
  5236. while (table3.Rows.Count > table3Row)
  5237. {
  5238. table3.Rows.RemoveAt(table3Row);
  5239. }
  5240. #endregion
  5241. }
  5242. else dic.Add("SubGZF", "0.00");
  5243. //删除多余行
  5244. while (table3.Rows.Count > table3Row)
  5245. {
  5246. table3.Rows.RemoveAt(table3Row);
  5247. }
  5248. //培训费
  5249. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5250. if (_EnterExitCosts.ChoiceSix == 1)
  5251. {
  5252. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5253. dic.Add("SubPX", pxStr);
  5254. table4Row = dac4.Count;
  5255. #region 填充word表格内容
  5256. for (int i = 0; i < dac4.Count; i++)
  5257. {
  5258. Grp_DayAndCost dac = dac4[i];
  5259. if (dac == null) continue;
  5260. builder.MoveToCell(3, i, 0, 0);
  5261. builder.Write("第" + dac.Days.ToString() + "天:");
  5262. builder.MoveToCell(3, i, 1, 0);
  5263. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5264. builder.MoveToCell(3, i, 2, 0);
  5265. builder.Write("费用标准:");
  5266. string curr = "";
  5267. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5268. if (currData != null)
  5269. {
  5270. curr = currData.Name;
  5271. }
  5272. builder.MoveToCell(3, i, 3, 0);
  5273. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5274. builder.MoveToCell(3, i, 4, 0);
  5275. builder.Write("费用小计:");
  5276. builder.MoveToCell(3, i, 5, 0);
  5277. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5278. }
  5279. #endregion
  5280. }
  5281. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  5282. //删除多余行
  5283. while (table4.Rows.Count > table4Row)
  5284. {
  5285. table4.Rows.RemoveAt(table4Row);
  5286. }
  5287. //其他费用
  5288. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5289. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5290. {
  5291. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5292. dic.Add("titleQi", qtStr);
  5293. table5Row = dac5.Count;
  5294. #region 填充word表格内容
  5295. for (int i = 0; i < dac5.Count; i++)
  5296. {
  5297. var dac = dac5[i];
  5298. if (dac == null) continue;
  5299. builder.MoveToCell(4, i, 0, 0);
  5300. builder.Write("第" + dac.Index.ToString() + "项:");
  5301. builder.MoveToCell(4, i, 1, 0);
  5302. builder.Write(dac.itemName);
  5303. builder.MoveToCell(4, i, 2, 0);
  5304. builder.Write("费用标准:");
  5305. builder.MoveToCell(4, i, 3, 0);
  5306. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5307. builder.MoveToCell(4, i, 4, 0);
  5308. builder.Write("费用小计:");
  5309. builder.MoveToCell(4, i, 5, 0);
  5310. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5311. builder.MoveToCell(4, i, 6, 0);
  5312. builder.Write("备注:");
  5313. builder.MoveToCell(4, i, 7, 0);
  5314. builder.Write(dac.Remark);
  5315. }
  5316. #endregion
  5317. }
  5318. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5319. //删除多余行
  5320. while (table5.Rows.Count > table5Row)
  5321. {
  5322. table5.Rows.RemoveAt(table5Row);
  5323. }
  5324. //加上其他费用
  5325. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5326. decimal subJJC = 0.00M,
  5327. subGWC = 0.00M,
  5328. subTDC = 0.00M;
  5329. //经济舱
  5330. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5331. //公务舱
  5332. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5333. //头等舱
  5334. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5335. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5336. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5337. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5338. #region 填充word模板书签内容
  5339. foreach (var key in dic.Keys)
  5340. {
  5341. Bookmark bookmark = doc.Range.Bookmarks[key];
  5342. if (bookmark != null)
  5343. {
  5344. builder.MoveToBookmark(key);
  5345. builder.Write(dic[key]);
  5346. }
  5347. }
  5348. #endregion
  5349. #region 设置页眉
  5350. string userLabel = string.Empty;
  5351. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5352. if (currUserInfo != null)
  5353. {
  5354. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5355. if (userInfo != null)
  5356. {
  5357. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5358. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5359. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5360. }
  5361. }
  5362. //设置页脚
  5363. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5364. #endregion
  5365. //文件名
  5366. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5367. AsposeHelper.removewatermark_v2180();
  5368. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5369. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5370. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5371. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5372. }
  5373. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5374. {
  5375. //获取模板
  5376. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5377. //载入模板
  5378. Document doc = new Document(tempPath);
  5379. DocumentBuilder builder = new DocumentBuilder(doc);
  5380. Dictionary<string, string> dic = new Dictionary<string, string>();
  5381. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5382. {
  5383. List<string> list = new List<string>();
  5384. try
  5385. {
  5386. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5387. foreach (var item in spilitArr)
  5388. {
  5389. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5390. var depCode = spDotandEmpty[2].Substring(0, 3);
  5391. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5392. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5393. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5394. list.Add(depName);
  5395. list.Add(arrName);
  5396. }
  5397. list = list.Distinct().ToList();
  5398. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5399. }
  5400. catch (Exception)
  5401. {
  5402. dic.Add("ReturnCode", "行程录入不正确!");
  5403. }
  5404. }
  5405. else
  5406. {
  5407. dic.Add("ReturnCode", "未录入行程!");
  5408. }
  5409. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5410. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5411. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5412. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5413. {
  5414. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5415. dic.Add("Day", sp.Days.ToString());
  5416. }
  5417. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5418. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5419. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5420. //dic.Add("Names", Names);
  5421. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5422. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5423. decimal dac1totalPrice = 0.00M;
  5424. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5425. foreach (var dac in dac1)
  5426. {
  5427. if (dac.SubTotal == 0.00M)
  5428. {
  5429. continue;
  5430. }
  5431. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5432. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5433. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5434. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5435. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5436. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5437. builder.Write(currency);//币种
  5438. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5439. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5440. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5441. builder.Write("");//人数
  5442. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5443. builder.Write("");//天数
  5444. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5445. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5446. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5447. decimal rate = 0.00M;
  5448. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5449. builder.Write(rate.ToString("#0.0000"));//汇率
  5450. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5451. decimal rbmPrice = dac.SubTotal;
  5452. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5453. accommodationStartIndex++;
  5454. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5455. }
  5456. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5457. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5458. {
  5459. table1.Rows.RemoveAt(i - 1);
  5460. foodandotherStartIndex--;
  5461. }
  5462. if (dac2.Count == dac3.Count)//国家 币种 金额
  5463. {
  5464. for (int i = 0; i < dac2.Count; i++)
  5465. {
  5466. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5467. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5468. }
  5469. }
  5470. decimal dac2totalPrice = 0.00M;
  5471. foreach (var dac in dac2)
  5472. {
  5473. if (dac.SubTotal == 0)
  5474. {
  5475. continue;
  5476. }
  5477. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5478. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5479. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5480. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5481. builder.Write(currency);//币种
  5482. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5483. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5484. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5485. builder.Write("");//人数
  5486. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5487. builder.Write("");//天数
  5488. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5489. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5490. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5491. decimal rate = 0.00M;
  5492. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5493. builder.Write(rate.ToString("#0.0000"));//汇率
  5494. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5495. decimal rbmPrice = dac.SubTotal;
  5496. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5497. foodandotherStartIndex++;
  5498. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5499. }
  5500. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5501. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5502. {
  5503. table1.Rows.RemoveAt(i - 1);
  5504. }
  5505. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5506. string otherFeeStr = "";
  5507. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5508. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5509. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5510. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5511. foreach (var otherInfo in dac5)
  5512. {
  5513. otherFeeStr += $"{otherInfo.itemName}{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5514. }
  5515. #endregion
  5516. if (otherFeeStr.Length > 0)
  5517. {
  5518. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5519. otherFeeStr = $"({otherFeeStr})";
  5520. dic.Add("OtherFeeStr", otherFeeStr);
  5521. }
  5522. //总计
  5523. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5524. //国际旅费
  5525. string outsideAir = string.Empty;
  5526. string allPriceAir = string.Empty;
  5527. if (_EnterExitCosts.SumJJC == 1)
  5528. {
  5529. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5530. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5531. }
  5532. if (_EnterExitCosts.SumGWC == 1)
  5533. {
  5534. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5535. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5536. }
  5537. if (_EnterExitCosts.SumTDC == 1)
  5538. {
  5539. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5540. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5541. }
  5542. dic.Add("InTravelPrice", $"({outsideAir})");
  5543. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5544. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5545. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5546. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5547. foreach (var key in dic.Keys)
  5548. {
  5549. builder.MoveToBookmark(key);
  5550. builder.Write(dic[key]);
  5551. }
  5552. //模板文件名
  5553. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5554. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5555. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5556. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5557. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5558. }
  5559. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5560. {
  5561. //获取模板
  5562. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5563. //载入模板
  5564. WorkbookDesigner designer = new WorkbookDesigner();
  5565. designer.Workbook = new Workbook(tempPath);
  5566. Dictionary<string, string> dic = new Dictionary<string, string>();
  5567. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5568. {
  5569. List<string> list = new List<string>();
  5570. try
  5571. {
  5572. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5573. foreach (var item in spilitArr)
  5574. {
  5575. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5576. var depCode = spDotandEmpty[2].Substring(0, 3);
  5577. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5578. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5579. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5580. list.Add(depName);
  5581. list.Add(arrName);
  5582. }
  5583. list = list.Distinct().ToList();
  5584. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5585. }
  5586. catch (Exception)
  5587. {
  5588. dic.Add("ReturnCode", "行程录入不正确!");
  5589. }
  5590. }
  5591. else
  5592. {
  5593. dic.Add("ReturnCode", "未录入行程!");
  5594. }
  5595. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5596. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5597. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5598. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5599. {
  5600. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5601. dic.Add("Day", sp.Days.ToString());
  5602. }
  5603. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5604. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5605. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5606. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5607. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5608. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5609. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5610. designer.SetDataSource("Name", Names);
  5611. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5612. designer.SetDataSource("Day", dic["Day"] + "天");
  5613. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5614. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5615. int startIndex = 10;
  5616. const int startIndexcopy = 10;
  5617. if (dac2.Count == dac3.Count)//国家 币种 金额
  5618. {
  5619. for (int i = 0; i < dac2.Count; i++)
  5620. {
  5621. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5622. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5623. }
  5624. }
  5625. DataTable dtdac1 = new DataTable();
  5626. List<string> place = new List<string>();
  5627. dtdac1.Columns.AddRange(new DataColumn[] {
  5628. new DataColumn(){ ColumnName = "city"},
  5629. new DataColumn(){ ColumnName = "curr"},
  5630. new DataColumn(){ ColumnName = "criterion"},
  5631. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5632. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5633. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5634. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5635. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5636. });
  5637. DataTable dtdac2 = new DataTable();
  5638. dtdac2.Columns.AddRange(new DataColumn[] {
  5639. new DataColumn(){ ColumnName = "city"},
  5640. new DataColumn(){ ColumnName = "curr"},
  5641. new DataColumn(){ ColumnName = "criterion"},
  5642. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5643. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5644. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5645. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5646. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5647. });
  5648. dtdac1.TableName = "tb1";
  5649. dtdac2.TableName = "tb2";
  5650. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5651. foreach (var item in dac1)
  5652. {
  5653. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5654. if (place.Contains(item.Place))
  5655. {
  5656. continue;
  5657. }
  5658. DataRow row = dtdac1.NewRow();
  5659. row["city"] = item.Place;
  5660. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5661. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5662. row["curr"] = currency;
  5663. row["rate"] = rate.ToString("#0.0000");
  5664. row["criterion"] = item.Cost.ToString("#0.00");
  5665. row["number"] = 1;
  5666. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5667. //row["costRMB"] = rbmPrice;
  5668. dtdac1.Rows.Add(row);
  5669. place.Add(item.Place);
  5670. }
  5671. place = new List<string>();
  5672. foreach (var item in dac2)
  5673. {
  5674. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5675. if (place.Contains(item.Place))
  5676. {
  5677. continue;
  5678. }
  5679. DataRow row = dtdac2.NewRow();
  5680. row["city"] = item.Place;
  5681. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5682. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5683. row["curr"] = currency;
  5684. row["rate"] = rate.ToString("#0.0000");
  5685. row["criterion"] = item.Cost.ToString("#0.00");
  5686. row["number"] = 1;
  5687. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5688. //row["cost"] = item.SubTotal;
  5689. //row["costRMB"] = rbmPrice;
  5690. dtdac2.Rows.Add(row);
  5691. place.Add(item.Place);
  5692. //dac2totalPrice += rbmPrice;
  5693. }
  5694. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5695. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5696. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5697. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5698. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5699. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5700. string cell4Str1 = string.Empty;
  5701. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5702. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5703. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5704. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5705. string cellStr = $" 5.其他费用(";
  5706. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5707. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5708. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5709. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5710. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5711. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5712. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5713. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5714. foreach (var otherInfo in dac5)
  5715. {
  5716. cellStr += $"{otherInfo.itemName}{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5717. }
  5718. #endregion
  5719. if (cellStr.Length > 8)
  5720. {
  5721. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5722. }
  5723. cellStr += ")";
  5724. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5725. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5726. decimal pxFee = dac4.Sum(it => it.Cost);
  5727. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5728. string celllastStr1 = "";
  5729. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5730. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5731. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5732. celllastStr1 += $",国际旅费 元";
  5733. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5734. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5735. designer.SetDataSource("cell4Str", cell4Str);
  5736. designer.SetDataSource("cellStr", cellStr);
  5737. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5738. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5739. designer.SetDataSource("celllastStr", celllastStr);
  5740. Workbook wb = designer.Workbook;
  5741. var sheet = wb.Worksheets[0];
  5742. //绑定datatable数据集
  5743. designer.SetDataSource(dtdac1);
  5744. designer.SetDataSource(dtdac2);
  5745. designer.Process();
  5746. var rowStart = dtdac1.Rows.Count;
  5747. while (rowStart > 0)
  5748. {
  5749. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5750. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5751. startIndex++;
  5752. rowStart--;
  5753. }
  5754. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5755. startIndex += 1; //总计行
  5756. rowStart = dtdac2.Rows.Count;
  5757. while (rowStart > 0)
  5758. {
  5759. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5760. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5761. startIndex++;
  5762. rowStart--;
  5763. }
  5764. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5765. wb.CalculateFormula(true);
  5766. //模板文件名
  5767. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5768. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5769. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5770. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5771. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5772. }
  5773. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5774. {
  5775. //获取模板
  5776. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5777. //载入模板
  5778. Document doc = new Document(tempPath);
  5779. DocumentBuilder builder = new DocumentBuilder(doc);
  5780. Dictionary<string, string> dic = new Dictionary<string, string>();
  5781. dic.Add("GroupName", _DelegationInfo.TeamName);
  5782. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5783. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5784. string missionLeaderJob = "";//负责人job
  5785. int groupNumber = 0; //团人数
  5786. if (DeleClientList.Count > 0)
  5787. {
  5788. missionLeader = DeleClientList[0]?.Name ?? "";
  5789. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5790. }
  5791. dic.Add("MissionLeader", missionLeader); //团负责人
  5792. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5793. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5794. #region MyRegion
  5795. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5796. //{
  5797. // List<string> list = new List<string>();
  5798. // try
  5799. // {
  5800. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5801. // foreach (var item in spilitArr)
  5802. // {
  5803. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5804. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5805. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5806. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5807. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5808. // list.Add(depName);
  5809. // list.Add(arrName);
  5810. // }
  5811. // list = list.Distinct().ToList();
  5812. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5813. // }
  5814. // catch (Exception)
  5815. // {
  5816. // dic.Add("ReturnCode", "行程录入不正确!");
  5817. // }
  5818. //}
  5819. //else
  5820. //{
  5821. // dic.Add("ReturnCode", "未录入行程!");
  5822. //}
  5823. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5824. dic.Add("ReturnCode", string.Join("、", countrys));
  5825. #endregion
  5826. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5827. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5828. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5829. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5830. //{
  5831. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5832. // dic.Add("Day", sp.Days.ToString());
  5833. //}
  5834. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5835. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5836. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5837. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5838. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5839. //培训人员名单
  5840. int cultivateRowIndex = 7;
  5841. foreach (var item in DeleClientList)
  5842. {
  5843. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5844. builder.Write(item.Name);
  5845. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5846. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5847. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5848. string birthDay = "";
  5849. if (item.Birthday != null)
  5850. {
  5851. DateTime dt = Convert.ToDateTime(item.Birthday);
  5852. birthDay = $"{dt.Year}.{dt.Month}";
  5853. }
  5854. builder.Write(birthDay);
  5855. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5856. builder.Write(item.Company);
  5857. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5858. builder.Write(item.Job);
  5859. cultivateRowIndex++;
  5860. }
  5861. //删除多余行
  5862. //cultivateRowIndex -= 2;
  5863. int delRows = 10 + 7 - cultivateRowIndex;
  5864. if (delRows > 0)
  5865. {
  5866. for (int i = 0; i < delRows; i++)
  5867. {
  5868. table1.Rows.RemoveAt(cultivateRowIndex);
  5869. //cultivateRowIndex++;
  5870. }
  5871. }
  5872. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5873. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5874. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5875. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5876. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5877. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5878. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5879. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5880. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5881. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5882. //其他费用
  5883. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5884. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5885. //其他费用合计
  5886. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5887. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5888. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5889. //公务舱合计
  5890. //国际旅费
  5891. string outsideJJ = "";
  5892. string allPriceJJ = "";
  5893. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5894. {
  5895. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5896. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5897. }
  5898. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5899. {
  5900. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5901. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5902. }
  5903. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5904. {
  5905. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5906. dic.Add("AirFeeTotal", airFeeTotalStr);
  5907. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5908. dic.Add("FeeTotal", feeTotalStr);
  5909. }
  5910. foreach (var key in dic.Keys)
  5911. {
  5912. builder.MoveToBookmark(key);
  5913. builder.Write(dic[key]);
  5914. }
  5915. //模板文件名
  5916. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5917. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5918. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5919. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5920. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5921. }
  5922. }
  5923. else if (dto.ExportType == 2) //表格
  5924. {
  5925. //利用键值对存放数据
  5926. Dictionary<string, string> dic = new Dictionary<string, string>();
  5927. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5928. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5929. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5930. dic.Add("Day", sp.Days.ToString());
  5931. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5932. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5933. {
  5934. //获取模板
  5935. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5936. //载入模板
  5937. Document doc = new Document(tempPath);
  5938. DocumentBuilder builder = new DocumentBuilder(doc);
  5939. dic.Add("TeamName", _DelegationInfo.TeamName);
  5940. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5941. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5942. string missionLeaderName = "",
  5943. missionLeaderJob = "";
  5944. if (DeleClientList.Count > 0)
  5945. {
  5946. missionLeaderName = DeleClientList[0].Name;
  5947. missionLeaderJob = DeleClientList[0].Job;
  5948. }
  5949. dic.Add("MissionLeaderName", missionLeaderName);
  5950. dic.Add("MissionLeaderJob", missionLeaderJob);
  5951. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5952. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5953. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5954. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5955. int rowCount = 10;//总人数行
  5956. int startRowIndex = 7; //起始行
  5957. for (int i = 0; i < DeleClientList.Count; i++)
  5958. {
  5959. builder.MoveToCell(0, startRowIndex, 0, 0);
  5960. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5961. builder.MoveToCell(0, startRowIndex, 1, 0);
  5962. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5963. builder.Write(sex);//性别
  5964. builder.MoveToCell(0, startRowIndex, 2, 0);
  5965. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5966. builder.MoveToCell(0, startRowIndex, 3, 0);
  5967. builder.Write(DeleClientList[i].Company);//工作单位
  5968. builder.MoveToCell(0, startRowIndex, 4, 0);
  5969. builder.Write(DeleClientList[i].Job);//职务及级别
  5970. builder.MoveToCell(0, startRowIndex, 5, 0);
  5971. builder.Write("");//人员属性
  5972. builder.MoveToCell(0, startRowIndex, 6, 0);
  5973. builder.Write("");//上次出国时间
  5974. startRowIndex++;
  5975. }
  5976. int nullRow = rowCount - DeleClientList.Count;//空行
  5977. for (int i = 0; i < nullRow; i++)
  5978. {
  5979. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5980. }
  5981. foreach (var key in dic.Keys)
  5982. {
  5983. builder.MoveToBookmark(key);
  5984. builder.Write(dic[key]);
  5985. }
  5986. //模板文件名
  5987. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5988. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5989. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5990. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5991. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5992. }
  5993. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5994. {
  5995. //获取模板
  5996. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5997. //载入模板
  5998. Document doc = new Document(tempPath);
  5999. DocumentBuilder builder = new DocumentBuilder(doc);
  6000. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6001. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6002. dic.Add("Names", Names);
  6003. int accommodationRows = 12, foodandotherRows = 12;
  6004. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6005. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6006. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6007. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6008. int accommodationStartIndex = 6;
  6009. decimal dac1totalPrice = 0.00M;
  6010. foreach (var dac in dac1)
  6011. {
  6012. if (dac.SubTotal == 0)
  6013. {
  6014. continue;
  6015. }
  6016. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6017. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6018. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6019. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6020. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6021. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6022. builder.Write(currency);//币种
  6023. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6024. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6025. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6026. builder.Write("");//人数
  6027. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6028. builder.Write("");//天数
  6029. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6030. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6031. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6032. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6033. builder.Write(rate.ToString("#0.0000"));//汇率
  6034. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6035. decimal rbmPrice = rate * dac.SubTotal;
  6036. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6037. accommodationStartIndex++;
  6038. dac1totalPrice += rbmPrice;
  6039. }
  6040. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6041. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6042. builder.Write("小计");
  6043. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6044. builder.Write(dac1totalPrice.ToString("#0.00"));
  6045. accommodationStartIndex++;
  6046. int nullRow = accommodationRows - dac1.Count;
  6047. //删除空行
  6048. //if (nullRow > 0)
  6049. //{
  6050. // int rowIndex = accommodationStartIndex;
  6051. // for (int i = 0; i < nullRow; i++)
  6052. // {
  6053. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6054. // row.Remove();
  6055. // rowIndex++;
  6056. // }
  6057. //}
  6058. if (dac2.Count == dac3.Count)//国家 币种 金额
  6059. {
  6060. for (int i = 0; i < dac2.Count; i++)
  6061. {
  6062. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6063. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6064. }
  6065. }
  6066. int foodandotherStartIndex = 19;//
  6067. decimal dac2totalPrice = 0.00M;
  6068. foreach (var dac in dac2)
  6069. {
  6070. if (dac.SubTotal == 0)
  6071. {
  6072. continue;
  6073. }
  6074. //foodandotherStartIndex = 12;
  6075. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6076. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6077. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6078. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6079. builder.Write(currency);//币种
  6080. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6081. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6082. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6083. builder.Write("");//人数
  6084. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6085. builder.Write("");//天数
  6086. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6087. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6088. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6089. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6090. builder.Write(rate.ToString("#0.0000"));//汇率
  6091. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6092. decimal rbmPrice = rate * dac.SubTotal;
  6093. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6094. foodandotherStartIndex++;
  6095. dac2totalPrice += rbmPrice;
  6096. }
  6097. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6098. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6099. //删除空行
  6100. //if (dac2.Count < foodandotherRows)
  6101. //{
  6102. // while (table2.Rows.Count > dac2.Count)
  6103. // {
  6104. // table2.Rows.RemoveAt(dac2.Count);
  6105. // }
  6106. //}
  6107. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6108. string otherFeeStr = "";
  6109. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6110. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6111. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6112. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6113. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6114. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6115. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6116. foreach (var otherInfo in dac5)
  6117. {
  6118. otherFeeStr += $"{otherInfo.itemName}{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6119. }
  6120. #endregion
  6121. if (otherFeeStr.Length > 0)
  6122. {
  6123. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6124. otherFeeStr = $"({otherFeeStr})";
  6125. dic.Add("OtherFeeStr", otherFeeStr);
  6126. }
  6127. foreach (var key in dic.Keys)
  6128. {
  6129. builder.MoveToBookmark(key);
  6130. builder.Write(dic[key]);
  6131. }
  6132. //模板文件名
  6133. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6134. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6135. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6136. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6137. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6138. }
  6139. }
  6140. else if (dto.ExportType == 3)
  6141. {
  6142. if (dto.SubTypeId == 1) //团组成员名单
  6143. {
  6144. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6145. //获取模板
  6146. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6147. //载入模板
  6148. Document doc = new Document(tempPath);
  6149. DocumentBuilder builder = new DocumentBuilder(doc);
  6150. //获取word里所有表格
  6151. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6152. //获取所填表格的序数
  6153. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6154. var rowStart = tableOne.Rows[0]; //获取第1行
  6155. //循环赋值
  6156. for (int i = 0; i < DeleClientList.Count; i++)
  6157. {
  6158. builder.MoveToCell(0, i + 1, 0, 0);
  6159. builder.Write(DeleClientList[i].Name);
  6160. builder.MoveToCell(0, i + 1, 1, 0);
  6161. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6162. builder.Write(sex);
  6163. builder.MoveToCell(0, i + 1, 2, 0);
  6164. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6165. builder.MoveToCell(0, i + 1, 3, 0);
  6166. builder.Write(DeleClientList[i].Company);
  6167. builder.MoveToCell(0, i + 1, 4, 0);
  6168. builder.Write(DeleClientList[i].Job);
  6169. }
  6170. //删除多余行
  6171. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6172. {
  6173. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6174. }
  6175. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6176. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6177. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6178. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6179. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6180. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6181. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6182. }
  6183. }
  6184. return Ok(JsonView(400, "操作失败!", ""));
  6185. }
  6186. catch (Exception ex)
  6187. {
  6188. return Ok(JsonView(400, ex.Message, ""));
  6189. }
  6190. }
  6191. /// <summary>
  6192. /// 获取三公费用标准city
  6193. /// </summary>
  6194. /// <param name="placeData"></param>
  6195. /// <param name="nationalTravelFeeId"></param>
  6196. /// <returns></returns>
  6197. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6198. {
  6199. string _city = string.Empty;
  6200. if (placeData.Count < 1) return _city;
  6201. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6202. if (data == null) return _city;
  6203. string country = data.Country;
  6204. string city = data.City;
  6205. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6206. else _city = city;
  6207. return _city;
  6208. }
  6209. /// <summary>
  6210. /// 团组模块 - 出入境费用 - 明细表导出
  6211. /// </summary>
  6212. /// <returns></returns>
  6213. [HttpPost]
  6214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6215. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6216. {
  6217. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6218. if (data.Code != 0)
  6219. {
  6220. return Ok(JsonView(false, data.Msg));
  6221. }
  6222. return Ok(JsonView(true, data.Msg, data.Data));
  6223. }
  6224. /// <summary>
  6225. /// 团组模块 - 出入境费用 - 一键清空
  6226. /// </summary>
  6227. /// <returns></returns>
  6228. [HttpPost]
  6229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6230. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6231. {
  6232. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6233. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6234. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6235. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6236. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6237. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6238. .SetColumns(x => new Grp_DayOtherPrice
  6239. {
  6240. IsDel = 1,
  6241. DeleteUserId = dto.UserId,
  6242. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6243. })
  6244. .ExecuteCommandAsync();
  6245. if (_view.Code == 0)
  6246. {
  6247. return Ok(JsonView(true, "操作成功"));
  6248. }
  6249. return Ok(JsonView(false, "操作失败"));
  6250. }
  6251. /// <summary>
  6252. /// 团组模块 - 出入境费用 - 子项删除
  6253. /// </summary>
  6254. /// <returns></returns>
  6255. [HttpPost]
  6256. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6257. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6258. {
  6259. try
  6260. {
  6261. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6262. if (data.Code != 0)
  6263. {
  6264. return Ok(JsonView(false, data.Msg));
  6265. }
  6266. return Ok(JsonView(true, "操作成功!", data.Data));
  6267. }
  6268. catch (Exception ex)
  6269. {
  6270. return Ok(JsonView(false, ex.Message));
  6271. }
  6272. }
  6273. /// <summary>
  6274. /// 删除三公其他费用
  6275. /// </summary>
  6276. /// <param name="dto"></param>
  6277. /// <returns></returns>
  6278. [HttpPost]
  6279. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6280. {
  6281. var jw = JsonView(false,"删除失败!");
  6282. var data = new Grp_DayOtherPrice()
  6283. {
  6284. Id = dto.Id,
  6285. IsDel = 1,
  6286. DeleteUserId = dto.DeleteUserId,
  6287. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6288. };
  6289. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6290. if (del > 0)
  6291. {
  6292. jw.Code = 200;
  6293. jw.Msg = "删除成功!";
  6294. }
  6295. return Ok(jw);
  6296. }
  6297. /// <summary>
  6298. /// 团组模块 - 出入境国家费用标准 List
  6299. /// </summary>
  6300. /// <returns></returns>
  6301. [HttpPost]
  6302. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6303. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6304. {
  6305. try
  6306. {
  6307. Stopwatch sw = new Stopwatch();
  6308. sw.Start();
  6309. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6310. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6311. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6312. Where gntf.Isdel = 0");
  6313. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6314. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6315. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6316. //foreach (var item in nationalTravel)
  6317. //{
  6318. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6319. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6320. // if (otherData != null)
  6321. // {
  6322. // cityData.Remove(otherData);
  6323. // cityData.Add(otherData);
  6324. // }
  6325. // nationalTravelFeeData1.Add(new
  6326. // {
  6327. // Country = item.Country,
  6328. // CityData = cityData
  6329. // });
  6330. //}
  6331. sw.Stop();
  6332. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6333. }
  6334. catch (Exception ex)
  6335. {
  6336. return Ok(JsonView(false, ex.Message));
  6337. throw;
  6338. }
  6339. }
  6340. /// <summary>
  6341. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6342. /// </summary>
  6343. /// <returns></returns>
  6344. [HttpPost]
  6345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6346. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6347. {
  6348. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6349. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6350. List<string> countryData = new List<string>();
  6351. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6352. countryData = countryData.Distinct().ToList();
  6353. List<dynamic> dataSource = new List<dynamic>();
  6354. foreach (var item in countryData)
  6355. {
  6356. List<string> cityData1 = new List<string>();
  6357. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6358. var countryData2 = new
  6359. {
  6360. CountryName = item,
  6361. CityData = cityData1
  6362. };
  6363. dataSource.Add(countryData2);
  6364. }
  6365. return Ok(JsonView(true, "查询成功!", dataSource));
  6366. }
  6367. /// <summary>
  6368. /// 团组模块 - 出入境国家费用标准 Page List
  6369. /// </summary>
  6370. /// <returns></returns>
  6371. [HttpPost]
  6372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6373. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6374. {
  6375. int portId = dto.PortType;
  6376. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6377. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6378. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6379. string whereSql = string.Empty;
  6380. if (!string.IsNullOrEmpty(dto.Country))
  6381. {
  6382. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6383. }
  6384. if (!string.IsNullOrEmpty(dto.City))
  6385. {
  6386. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6387. }
  6388. string pageSql = string.Format(@"Select * From (
  6389. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6390. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6391. From Grp_NationalTravelFee gntf
  6392. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6393. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6394. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6395. RefAsync<int> total = 0;
  6396. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6397. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6398. }
  6399. /// <summary>
  6400. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6401. /// </summary>
  6402. /// <returns></returns>
  6403. [HttpPost]
  6404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6405. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6406. {
  6407. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6408. int portId = dto.PortType;
  6409. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6410. string whereSql = string.Empty;
  6411. if (!string.IsNullOrEmpty(dto.Country))
  6412. {
  6413. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6414. }
  6415. if (!string.IsNullOrEmpty(dto.City))
  6416. {
  6417. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6418. }
  6419. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6420. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6421. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6422. From Grp_NationalTravelFee gntf
  6423. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6424. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6425. Where gntf.Isdel = 0 {0} ", whereSql);
  6426. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6427. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6428. }
  6429. /// <summary>
  6430. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6431. /// </summary>
  6432. /// <returns></returns>
  6433. [HttpPost]
  6434. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6435. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6436. {
  6437. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6438. if (data.Code != 0)
  6439. {
  6440. return Ok(JsonView(false, data.Msg));
  6441. }
  6442. return Ok(JsonView(true, "操作成功!", data.Data));
  6443. }
  6444. /// <summary>
  6445. /// 团组模块 - 出入境国家费用标准 - Del
  6446. /// </summary>
  6447. /// <returns></returns>
  6448. [HttpPost]
  6449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6450. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6451. {
  6452. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6453. {
  6454. Id = dto.Id,
  6455. DeleteUserId = dto.DeleteUserId,
  6456. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6457. IsDel = 1
  6458. };
  6459. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6460. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6461. .WhereColumns(it => new { it.Id })
  6462. .ExecuteCommandAsync();
  6463. if (delStatus <= 0)
  6464. {
  6465. return Ok(JsonView(false, "删除失败!"));
  6466. }
  6467. return Ok(JsonView(true, "操作成功!"));
  6468. }
  6469. /// <summary>
  6470. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6471. /// 注:Get 请求Headers 加 Token
  6472. /// </summary>
  6473. /// <param name="groupId"></param>
  6474. /// <returns></returns>
  6475. [HttpGet("{groupId}")]
  6476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6477. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6478. {
  6479. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6480. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6481. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6482. data.ForEach(x =>
  6483. {
  6484. x.CreateUserId = _currUserInfo.UserId;
  6485. });
  6486. if (data.Any())
  6487. {
  6488. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6489. if (add > 0)
  6490. {
  6491. return Ok(JsonView(true, "操作成功!"));
  6492. }
  6493. }
  6494. return Ok(JsonView(false, "未操作!"));
  6495. }
  6496. #endregion
  6497. #region 团组经理模块 出入境费用-草稿
  6498. /// <summary>
  6499. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6500. /// </summary>
  6501. /// <returns></returns>
  6502. [HttpPost]
  6503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6504. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6505. {
  6506. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6507. .Where(x => x.IsDel == 0)
  6508. .OrderByDescending(x => x.CreateTime)
  6509. .Select(x => new { x.Id, x.DraftName })
  6510. .ToListAsync();
  6511. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6512. //SetDataInfoView
  6513. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6514. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6515. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6516. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6517. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6518. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6519. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6520. //默认币种显示
  6521. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  6522. {
  6523. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  6524. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  6525. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  6526. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  6527. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  6528. };
  6529. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6530. if (_currencyRate.Count > 0)
  6531. {
  6532. foreach (var item in _currencyInfos)
  6533. {
  6534. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6535. if (rateInfo != null)
  6536. {
  6537. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6538. rate1 *= 1.035M;
  6539. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6540. }
  6541. }
  6542. }
  6543. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6544. return Ok(JsonView(true, "查询成功!", new
  6545. {
  6546. DraftNameDatas = draftNameDatas,
  6547. CurrencyData = _CurrencyData,
  6548. WordTypeData = _WordTypeData,
  6549. ExcelTypeData = _ExcelTypeData,
  6550. CurrencyInit = _currencyInfos,
  6551. ViewPermissionData = viewPermissionData
  6552. }));
  6553. }
  6554. /// <summary>
  6555. /// 团组模块 - 出入境费用-草稿
  6556. /// 实时汇率 tips
  6557. /// 签证费用 tips
  6558. /// 机票费用 tips
  6559. /// </summary>
  6560. /// <returns></returns>
  6561. [HttpPost]
  6562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6563. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6564. {
  6565. //var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6566. //默认币种显示
  6567. var _currencyInfos = _currencyInit;
  6568. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6569. List<dynamic> reteInfos = new List<dynamic>();
  6570. if (_currencyRate.Count > 0)
  6571. {
  6572. foreach (var item in _currencyInfos)
  6573. {
  6574. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6575. if (rateInfo != null)
  6576. {
  6577. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6578. decimal rate1 = item.Rate;
  6579. rate1 *= 1.03M;
  6580. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6581. reteInfos.Add(new
  6582. {
  6583. currCode = item.CurrencyCode,
  6584. currName = item.CurrencyName,
  6585. rate = rate2,
  6586. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6587. });
  6588. }
  6589. }
  6590. }
  6591. //var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  6592. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6593. return Ok(JsonView(true, "查询成功!", new
  6594. {
  6595. //GroupNameData = groupNameData.Data,
  6596. //visaData = visaData.Data,
  6597. //airData = airData.Data,
  6598. reteInfos = reteInfos
  6599. }));
  6600. }
  6601. /// <summary>
  6602. /// 团组模块 - 出入境费用-草稿 - Info
  6603. /// </summary>
  6604. /// <returns></returns>
  6605. [HttpPost]
  6606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6607. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6608. {
  6609. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6610. }
  6611. /// <summary>
  6612. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6613. /// </summary>
  6614. /// <returns></returns>
  6615. [HttpPost]
  6616. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6617. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6618. {
  6619. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6620. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6621. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6622. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6623. foreach (var userId in dto.UserIds)
  6624. {
  6625. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6626. }
  6627. if (permissions.Any())
  6628. {
  6629. _sqlSugar.BeginTran();
  6630. try
  6631. {
  6632. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6633. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6634. if (result < 1)
  6635. {
  6636. _sqlSugar.RollbackTran();
  6637. return Ok(JsonView(false));
  6638. }
  6639. }
  6640. catch (Exception ex)
  6641. {
  6642. _sqlSugar.RollbackTran();
  6643. return Ok(JsonView(false, ex.Message));
  6644. }
  6645. _sqlSugar.CommitTran();
  6646. return Ok(JsonView(true));
  6647. }
  6648. return Ok(JsonView(false));
  6649. }
  6650. /// <summary>
  6651. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6652. /// </summary>
  6653. /// <returns></returns>
  6654. [HttpPost]
  6655. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6656. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6657. {
  6658. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6659. if (data.Code != 0)
  6660. {
  6661. return Ok(JsonView(false, data.Msg));
  6662. }
  6663. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6664. //汇率信息记录
  6665. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6666. return Ok(JsonView(true, data.Msg, data.Data));
  6667. }
  6668. /// <summary>
  6669. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6670. /// </summary>
  6671. /// <param name="dto"></param>
  6672. /// <returns></returns>
  6673. [HttpPost]
  6674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6675. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6676. {
  6677. try
  6678. {
  6679. var id = dto.Id;
  6680. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6681. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6682. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6683. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6684. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6685. 3 团组成员名单 1 团组成员名单", ""));
  6686. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6687. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6688. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6689. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6690. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6691. //数据源
  6692. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6693. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6694. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6695. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6696. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6697. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6698. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6699. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6700. .Select((x, a, b) => new
  6701. {
  6702. x.Index,
  6703. itemName = a.Name,
  6704. CurrencyStr = b.Name,
  6705. x.Cost,
  6706. x.SubTotal,
  6707. x.Remark
  6708. })
  6709. .OrderBy((x) => x.Index)
  6710. .ToList(); //其他款项费用
  6711. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6712. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6713. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6714. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6715. if (dto.ExportType == 1) //明细表
  6716. {
  6717. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6718. {
  6719. //获取模板
  6720. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6721. //载入模板
  6722. Document doc = new Document(tempPath);
  6723. DocumentBuilder builder = new DocumentBuilder(doc);
  6724. //利用键值对存放数据
  6725. Dictionary<string, string> dic = new Dictionary<string, string>();
  6726. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6727. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6728. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6729. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6730. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6731. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6732. //境内费用(其他费用)
  6733. if (_EnterExitCosts.ChoiceOne == 1)
  6734. {
  6735. string row1_1 = "";
  6736. if (_EnterExitCosts.Visa > 0)
  6737. {
  6738. //insidePayTotal += _EnterExitCosts.Visa;
  6739. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6740. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6741. {
  6742. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6743. }
  6744. }
  6745. string row1_2 = "";
  6746. if (_EnterExitCosts.YiMiao > 0)
  6747. {
  6748. //insidePayTotal += _EnterExitCosts.YiMiao;
  6749. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6750. }
  6751. if (_EnterExitCosts.HeSuan > 0)
  6752. {
  6753. //insidePayTotal += _EnterExitCosts.HeSuan;
  6754. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6755. }
  6756. if (_EnterExitCosts.Service > 0)
  6757. {
  6758. //insidePayTotal += _EnterExitCosts.Service;
  6759. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6760. }
  6761. string row1_3 = "";
  6762. if (_EnterExitCosts.Safe > 0)
  6763. {
  6764. //insidePayTotal += _EnterExitCosts.Safe;
  6765. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6766. }
  6767. if (_EnterExitCosts.Ticket > 0)
  6768. {
  6769. //insidePayTotal += _EnterExitCosts.Ticket;
  6770. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6771. }
  6772. string row1 = "";
  6773. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6774. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6775. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6776. row1 += $"备注:{_EnterExitCosts.Remark}";
  6777. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6778. dic.Add("Row1Str", row1);
  6779. }
  6780. string airTotalStr = string.Empty,
  6781. airPriceStr = string.Empty;
  6782. //经济舱
  6783. if (_EnterExitCosts.SumJJC == 1)
  6784. {
  6785. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6786. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6787. }
  6788. //公务舱
  6789. if (_EnterExitCosts.SumGWC == 1)
  6790. {
  6791. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6792. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6793. }
  6794. //头等舱
  6795. if (_EnterExitCosts.SumTDC == 1)
  6796. {
  6797. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6798. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6799. }
  6800. string twoItemRemark = "备注:";
  6801. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark))
  6802. {
  6803. twoItemRemark = _EnterExitCosts.TwoItemRemark;
  6804. }
  6805. dic.Add("AirTotalStr", airTotalStr);
  6806. dic.Add("AirPriceStr", airPriceStr);
  6807. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6808. dic.Add("TwoItemRemark", twoItemRemark);
  6809. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6810. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6811. int table1Row = 0,
  6812. table2Row = 0,
  6813. table3Row = 0,
  6814. table4Row = 0,
  6815. table5Row = 0;
  6816. //住宿费
  6817. if (_EnterExitCosts.ChoiceThree == 1)
  6818. {
  6819. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6820. table1Row = dac1.Count;
  6821. #region 填充word表格内容
  6822. for (int i = 0; i < dac1.Count; i++)
  6823. {
  6824. var dac = dac1[i];
  6825. if (dac == null) continue;
  6826. builder.MoveToCell(0, i, 0, 0);
  6827. builder.Write("第" + dac.Days.ToString() + "晚:");
  6828. builder.MoveToCell(0, i, 1, 0);
  6829. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6830. //builder.Write(dac.Place == null ? "" : dac.Place);
  6831. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6832. builder.MoveToCell(0, i, 2, 0);
  6833. builder.Write("费用标准:");
  6834. string curr = "";
  6835. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6836. if (currData != null)
  6837. {
  6838. curr = currData.Name;
  6839. }
  6840. builder.MoveToCell(0, i, 3, 0);
  6841. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6842. builder.MoveToCell(0, i, 4, 0);
  6843. builder.Write("费用小计:");
  6844. builder.MoveToCell(0, i, 5, 0);
  6845. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6846. }
  6847. #endregion
  6848. }
  6849. else dic.Add("SubZS", "0.00");
  6850. //删除多余行
  6851. while (table1.Rows.Count > table1Row)
  6852. {
  6853. table1.Rows.RemoveAt(table1Row);
  6854. }
  6855. //伙食费
  6856. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6857. if (_EnterExitCosts.ChoiceFour == 1)
  6858. {
  6859. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6860. table2Row = dac2.Count;
  6861. #region 填充word表格内容
  6862. for (int i = 0; i < dac2.Count; i++)
  6863. {
  6864. var dac = dac2[i];
  6865. if (dac == null) continue;
  6866. builder.MoveToCell(1, i, 0, 0);
  6867. builder.Write("第" + dac.Days.ToString() + "天:");
  6868. builder.MoveToCell(1, i, 1, 0);
  6869. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6870. builder.MoveToCell(1, i, 2, 0);
  6871. builder.Write("费用标准:");
  6872. string curr = "";
  6873. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6874. if (currData != null)
  6875. {
  6876. curr = currData.Name;
  6877. }
  6878. builder.MoveToCell(1, i, 3, 0);
  6879. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6880. builder.MoveToCell(1, i, 4, 0);
  6881. builder.Write("费用小计:");
  6882. builder.MoveToCell(1, i, 5, 0);
  6883. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6884. }
  6885. #endregion
  6886. }
  6887. else dic.Add("SubHS", "0.00");
  6888. //删除多余行
  6889. while (table2.Rows.Count > table2Row)
  6890. {
  6891. table2.Rows.RemoveAt(table2Row);
  6892. }
  6893. //公杂费
  6894. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6895. if (_EnterExitCosts.ChoiceFive == 1)
  6896. {
  6897. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6898. table3Row = dac3.Count;
  6899. #region 填充word表格内容
  6900. for (int i = 0; i < dac3.Count; i++)
  6901. {
  6902. var dac = dac3[i];
  6903. if (dac == null) continue;
  6904. builder.MoveToCell(2, i, 0, 0);
  6905. builder.Write("第" + dac.Days.ToString() + "天:");
  6906. builder.MoveToCell(2, i, 1, 0);
  6907. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6908. builder.MoveToCell(2, i, 2, 0);
  6909. builder.Write("费用标准:");
  6910. string curr = "";
  6911. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6912. if (currData != null)
  6913. {
  6914. curr = currData.Name;
  6915. }
  6916. builder.MoveToCell(2, i, 3, 0);
  6917. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6918. builder.MoveToCell(2, i, 4, 0);
  6919. builder.Write("费用小计:");
  6920. builder.MoveToCell(2, i, 5, 0);
  6921. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6922. }
  6923. //删除多余行
  6924. while (table3.Rows.Count > table3Row)
  6925. {
  6926. table3.Rows.RemoveAt(table3Row);
  6927. }
  6928. #endregion
  6929. }
  6930. else dic.Add("SubGZF", "0.00");
  6931. //删除多余行
  6932. while (table3.Rows.Count > table3Row)
  6933. {
  6934. table3.Rows.RemoveAt(table3Row);
  6935. }
  6936. //培训费
  6937. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6938. if (_EnterExitCosts.ChoiceSix == 1)
  6939. {
  6940. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6941. dic.Add("SubPX", pxStr);
  6942. table4Row = dac4.Count;
  6943. #region 填充word表格内容
  6944. for (int i = 0; i < dac4.Count; i++)
  6945. {
  6946. var dac = dac4[i];
  6947. if (dac == null) continue;
  6948. builder.MoveToCell(3, i, 0, 0);
  6949. builder.Write("第" + dac.Days.ToString() + "天:");
  6950. builder.MoveToCell(3, i, 1, 0);
  6951. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6952. builder.MoveToCell(3, i, 2, 0);
  6953. builder.Write("费用标准:");
  6954. string curr = "";
  6955. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6956. if (currData != null)
  6957. {
  6958. curr = currData.Name;
  6959. }
  6960. builder.MoveToCell(3, i, 3, 0);
  6961. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6962. builder.MoveToCell(3, i, 4, 0);
  6963. builder.Write("费用小计:");
  6964. builder.MoveToCell(3, i, 5, 0);
  6965. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6966. }
  6967. #endregion
  6968. }
  6969. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  6970. //删除多余行
  6971. while (table4.Rows.Count > table4Row)
  6972. {
  6973. table4.Rows.RemoveAt(table4Row);
  6974. }
  6975. //其他费用
  6976. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6977. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6978. {
  6979. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6980. dic.Add("titleQi", qtStr);
  6981. table5Row = dac5.Count;
  6982. #region 填充word表格内容
  6983. for (int i = 0; i < dac5.Count; i++)
  6984. {
  6985. var dac = dac5[i];
  6986. if (dac == null) continue;
  6987. builder.MoveToCell(4, i, 0, 0);
  6988. builder.Write("第" + dac.Index.ToString() + "项:");
  6989. builder.MoveToCell(4, i, 1, 0);
  6990. builder.Write(dac.itemName);
  6991. builder.MoveToCell(4, i, 2, 0);
  6992. builder.Write("费用标准:");
  6993. builder.MoveToCell(4, i, 3, 0);
  6994. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6995. builder.MoveToCell(4, i, 4, 0);
  6996. builder.Write("费用小计:");
  6997. builder.MoveToCell(4, i, 5, 0);
  6998. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6999. builder.MoveToCell(4, i, 6, 0);
  7000. builder.Write("备注:");
  7001. builder.MoveToCell(4, i, 7, 0);
  7002. builder.Write(dac.Remark);
  7003. }
  7004. #endregion
  7005. }
  7006. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7007. //删除多余行
  7008. while (table5.Rows.Count > table5Row)
  7009. {
  7010. table5.Rows.RemoveAt(table5Row);
  7011. }
  7012. //加上其他费用
  7013. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7014. decimal subJJC = 0.00M,
  7015. subGWC = 0.00M,
  7016. subTDC = 0.00M;
  7017. //经济舱
  7018. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7019. //公务舱
  7020. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7021. //头等舱
  7022. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7023. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7024. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7025. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7026. #region 填充word模板书签内容
  7027. foreach (var key in dic.Keys)
  7028. {
  7029. Bookmark bookmark = doc.Range.Bookmarks[key];
  7030. if (bookmark != null)
  7031. {
  7032. builder.MoveToBookmark(key);
  7033. builder.Write(dic[key]);
  7034. }
  7035. }
  7036. #endregion
  7037. //文件名
  7038. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7039. strFileName = CommonFun.ValidFileName(strFileName);
  7040. AsposeHelper.removewatermark_v2180();
  7041. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7042. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7043. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7044. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7045. }
  7046. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7047. {
  7048. //获取模板
  7049. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7050. //载入模板
  7051. Document doc = new Document(tempPath);
  7052. DocumentBuilder builder = new DocumentBuilder(doc);
  7053. Dictionary<string, string> dic = new Dictionary<string, string>();
  7054. string returnCodeLabel = string.Empty;
  7055. if (nationalTravelFeeData.Any())
  7056. {
  7057. List<string> list = new List<string>();
  7058. foreach (var item in nationalTravelFeeData)
  7059. {
  7060. list.Add($"{item.Country}({item.City})");
  7061. }
  7062. list = list.Distinct().ToList();
  7063. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7064. }
  7065. var countryLabel = string.Empty;
  7066. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7067. if (countryData.Any())
  7068. {
  7069. countryLabel = string.Join("、", countryData);
  7070. }
  7071. dic.Add("ReturnCodeAir", returnCodeLabel);
  7072. dic.Add("VisitStartDate", "-");
  7073. dic.Add("VisitEndDate", "-");
  7074. dic.Add("Day", "-");
  7075. dic.Add("VisitCountry", countryLabel);
  7076. dic.Add("ClientUnit", "-");
  7077. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7078. //dic.Add("Names", Names);
  7079. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7080. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7081. decimal dac1totalPrice = 0.00M;
  7082. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7083. foreach (var dac in dac1)
  7084. {
  7085. if (dac.SubTotal == 0.00M)
  7086. {
  7087. continue;
  7088. }
  7089. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7090. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7091. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7092. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7093. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7094. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7095. builder.Write(currency);//币种
  7096. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7097. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7098. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7099. builder.Write("");//人数
  7100. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7101. builder.Write("");//天数
  7102. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7103. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7104. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7105. decimal rate = 0.00M;
  7106. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7107. builder.Write(rate.ToString("#0.0000"));//汇率
  7108. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7109. decimal rbmPrice = dac.SubTotal;
  7110. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7111. accommodationStartIndex++;
  7112. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7113. }
  7114. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7115. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7116. {
  7117. table1.Rows.RemoveAt(i - 1);
  7118. foodandotherStartIndex--;
  7119. }
  7120. if (dac2.Count == dac3.Count)//国家 币种 金额
  7121. {
  7122. for (int i = 0; i < dac2.Count; i++)
  7123. {
  7124. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7125. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7126. }
  7127. }
  7128. decimal dac2totalPrice = 0.00M;
  7129. foreach (var dac in dac2)
  7130. {
  7131. if (dac.SubTotal == 0)
  7132. {
  7133. continue;
  7134. }
  7135. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7136. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7137. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7138. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7139. builder.Write(currency);//币种
  7140. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7141. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7142. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7143. builder.Write("");//人数
  7144. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7145. builder.Write("");//天数
  7146. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7147. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7148. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7149. decimal rate = 0.00M;
  7150. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7151. builder.Write(rate.ToString("#0.0000"));//汇率
  7152. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7153. decimal rbmPrice = dac.SubTotal;
  7154. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7155. foodandotherStartIndex++;
  7156. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7157. }
  7158. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7159. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7160. {
  7161. table1.Rows.RemoveAt(i - 1);
  7162. }
  7163. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7164. string otherFeeStr = "";
  7165. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7166. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7167. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7168. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7169. foreach (var otherInfo in dac5)
  7170. {
  7171. otherFeeStr += $"{otherInfo.itemName}{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7172. }
  7173. #endregion
  7174. if (otherFeeStr.Length > 0)
  7175. {
  7176. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7177. otherFeeStr = $"({otherFeeStr})";
  7178. dic.Add("OtherFeeStr", otherFeeStr);
  7179. }
  7180. //总计
  7181. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7182. //国际旅费
  7183. string outsideAir = string.Empty;
  7184. string allPriceAir = string.Empty;
  7185. if (_EnterExitCosts.SumJJC == 1)
  7186. {
  7187. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7188. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7189. }
  7190. if (_EnterExitCosts.SumGWC == 1)
  7191. {
  7192. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7193. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7194. }
  7195. if (_EnterExitCosts.SumTDC == 1)
  7196. {
  7197. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7198. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7199. }
  7200. dic.Add("InTravelPrice", $"({outsideAir})");
  7201. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7202. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7203. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7204. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7205. foreach (var key in dic.Keys)
  7206. {
  7207. builder.MoveToBookmark(key);
  7208. builder.Write(dic[key]);
  7209. }
  7210. //模板文件名
  7211. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7212. strFileName = CommonFun.ValidFileName(strFileName);
  7213. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7214. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7215. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7216. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7217. }
  7218. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7219. {
  7220. //获取模板
  7221. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7222. //载入模板
  7223. WorkbookDesigner designer = new WorkbookDesigner();
  7224. designer.Workbook = new Workbook(tempPath);
  7225. Dictionary<string, string> dic = new Dictionary<string, string>();
  7226. string returnCodeLabel = string.Empty;
  7227. if (nationalTravelFeeData.Any())
  7228. {
  7229. List<string> list = new List<string>();
  7230. foreach (var item in nationalTravelFeeData)
  7231. {
  7232. list.Add($"{item.Country}({item.City})");
  7233. }
  7234. list = list.Distinct().ToList();
  7235. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7236. }
  7237. var countryLabel = string.Empty;
  7238. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7239. if (countryData.Any())
  7240. {
  7241. countryLabel = string.Join("、", countryData);
  7242. }
  7243. dic.Add("ReturnCodeAir", returnCodeLabel);
  7244. dic.Add("VisitStartDate", "-");
  7245. dic.Add("VisitEndDate", "-");
  7246. dic.Add("Day", "0");
  7247. dic.Add("VisitCountry", countryLabel);
  7248. dic.Add("ClientUnit", "-");
  7249. designer.SetDataSource("ClientUnit", "-");
  7250. designer.SetDataSource("VisitCountry", countryLabel);
  7251. designer.SetDataSource("Group", "-");
  7252. designer.SetDataSource("ClientUnitTitle", "-");
  7253. designer.SetDataSource("Name", "-");
  7254. designer.SetDataSource("VisitStartDate", "-" );
  7255. designer.SetDataSource("Day", "0");
  7256. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7257. designer.SetDataSource("ReturnCodeAir", "-");
  7258. int startIndex = 10;
  7259. const int startIndexcopy = 10;
  7260. if (dac2.Count == dac3.Count)//国家 币种 金额
  7261. {
  7262. for (int i = 0; i < dac2.Count; i++)
  7263. {
  7264. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7265. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7266. }
  7267. }
  7268. DataTable dtdac1 = new DataTable();
  7269. List<string> place = new List<string>();
  7270. dtdac1.Columns.AddRange(new DataColumn[] {
  7271. new DataColumn(){ ColumnName = "city"},
  7272. new DataColumn(){ ColumnName = "curr"},
  7273. new DataColumn(){ ColumnName = "criterion"},
  7274. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7275. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7276. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7277. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7278. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7279. });
  7280. DataTable dtdac2 = new DataTable();
  7281. dtdac2.Columns.AddRange(new DataColumn[] {
  7282. new DataColumn(){ ColumnName = "city"},
  7283. new DataColumn(){ ColumnName = "curr"},
  7284. new DataColumn(){ ColumnName = "criterion"},
  7285. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7286. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7287. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7288. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7289. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7290. });
  7291. dtdac1.TableName = "tb1";
  7292. dtdac2.TableName = "tb2";
  7293. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7294. foreach (var item in dac1)
  7295. {
  7296. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7297. if (place.Contains(item.Place))
  7298. {
  7299. continue;
  7300. }
  7301. DataRow row = dtdac1.NewRow();
  7302. row["city"] = item.Place;
  7303. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7304. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7305. row["curr"] = currency;
  7306. row["rate"] = rate.ToString("#0.0000");
  7307. row["criterion"] = item.Cost.ToString("#0.00");
  7308. row["number"] = 1;
  7309. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7310. //row["costRMB"] = rbmPrice;
  7311. dtdac1.Rows.Add(row);
  7312. place.Add(item.Place);
  7313. }
  7314. place = new List<string>();
  7315. foreach (var item in dac2)
  7316. {
  7317. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7318. if (place.Contains(item.Place))
  7319. {
  7320. continue;
  7321. }
  7322. DataRow row = dtdac2.NewRow();
  7323. row["city"] = item.Place;
  7324. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7325. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7326. row["curr"] = currency;
  7327. row["rate"] = rate.ToString("#0.0000");
  7328. row["criterion"] = item.Cost.ToString("#0.00");
  7329. row["number"] = 1;
  7330. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7331. //row["cost"] = item.SubTotal;
  7332. //row["costRMB"] = rbmPrice;
  7333. dtdac2.Rows.Add(row);
  7334. place.Add(item.Place);
  7335. //dac2totalPrice += rbmPrice;
  7336. }
  7337. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7338. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7339. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7340. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7341. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  7342. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  7343. string cell4Str1 = string.Empty;
  7344. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  7345. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  7346. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  7347. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7348. string cellStr = $" 5.其他费用(";
  7349. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7350. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7351. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7352. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7353. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7354. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7355. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7356. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7357. foreach (var otherInfo in dac5)
  7358. {
  7359. cellStr += $"{otherInfo.itemName}{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7360. }
  7361. #endregion
  7362. if (cellStr.Length > 8)
  7363. {
  7364. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7365. }
  7366. cellStr += ")";
  7367. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7368. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7369. decimal pxFee = dac4.Sum(it => it.Cost);
  7370. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7371. string celllastStr1 = "";
  7372. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  7373. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  7374. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  7375. celllastStr1 += $",国际旅费 元";
  7376. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  7377. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7378. designer.SetDataSource("cell4Str", cell4Str);
  7379. designer.SetDataSource("cellStr", cellStr);
  7380. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7381. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7382. designer.SetDataSource("celllastStr", celllastStr);
  7383. Workbook wb = designer.Workbook;
  7384. var sheet = wb.Worksheets[0];
  7385. //绑定datatable数据集
  7386. designer.SetDataSource(dtdac1);
  7387. designer.SetDataSource(dtdac2);
  7388. designer.Process();
  7389. var rowStart = dtdac1.Rows.Count;
  7390. while (rowStart > 0)
  7391. {
  7392. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7393. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7394. startIndex++;
  7395. rowStart--;
  7396. }
  7397. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7398. startIndex += 1; //总计行
  7399. rowStart = dtdac2.Rows.Count;
  7400. while (rowStart > 0)
  7401. {
  7402. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7403. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7404. startIndex++;
  7405. rowStart--;
  7406. }
  7407. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7408. wb.CalculateFormula(true);
  7409. //模板文件名
  7410. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7411. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7412. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7413. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7414. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7415. }
  7416. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7417. {
  7418. //获取模板
  7419. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7420. //载入模板
  7421. Document doc = new Document(tempPath);
  7422. DocumentBuilder builder = new DocumentBuilder(doc);
  7423. Dictionary<string, string> dic = new Dictionary<string, string>();
  7424. dic.Add("GroupName", "-");
  7425. dic.Add("ClientUnit", "-");
  7426. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7427. string missionLeaderJob = "";//负责人job
  7428. int groupNumber = 0; //团人数
  7429. dic.Add("MissionLeader", "-"); //团负责人
  7430. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7431. dic.Add("GroupNumber", "0"); //团人数
  7432. dic.Add("Day", "0");
  7433. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7434. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7435. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7436. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7437. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7438. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7439. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7440. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7441. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7442. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7443. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7444. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7445. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7446. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7447. //其他费用
  7448. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7449. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7450. //其他费用合计
  7451. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7452. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7453. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7454. //公务舱合计
  7455. //国际旅费
  7456. string outsideJJ = "";
  7457. string allPriceJJ = "";
  7458. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7459. {
  7460. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7461. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7462. }
  7463. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7464. {
  7465. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7466. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7467. }
  7468. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7469. {
  7470. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7471. dic.Add("AirFeeTotal", airFeeTotalStr);
  7472. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7473. dic.Add("FeeTotal", feeTotalStr);
  7474. }
  7475. foreach (var key in dic.Keys)
  7476. {
  7477. builder.MoveToBookmark(key);
  7478. builder.Write(dic[key]);
  7479. }
  7480. //模板文件名
  7481. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7482. strFileName = CommonFun.ValidFileName(strFileName);
  7483. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7484. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7485. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7486. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7487. }
  7488. }
  7489. else if (dto.ExportType == 2) //表格
  7490. {
  7491. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7492. }
  7493. else if (dto.ExportType == 3)
  7494. {
  7495. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7496. }
  7497. return Ok(JsonView(400, "只可导出明细表!", ""));
  7498. }
  7499. catch (Exception ex)
  7500. {
  7501. return Ok(JsonView(400, ex.Message, ""));
  7502. }
  7503. }
  7504. /// <summary>
  7505. /// 获取三公费用标准city
  7506. /// </summary>
  7507. /// <param name="placeData"></param>
  7508. /// <param name="nationalTravelFeeId"></param>
  7509. /// <returns></returns>
  7510. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7511. {
  7512. string _city = string.Empty;
  7513. if (!placeData.Any()) return _city;
  7514. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7515. if (data == null) return _city;
  7516. string country = data.Country;
  7517. string city = data.City;
  7518. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7519. else _city = city;
  7520. return _city;
  7521. }
  7522. /// <summary>
  7523. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7524. /// </summary>
  7525. /// <returns></returns>
  7526. [HttpPost]
  7527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7528. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7529. {
  7530. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7531. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7532. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7533. if (_view.Code == 0)
  7534. {
  7535. return Ok(JsonView(true, "操作成功"));
  7536. }
  7537. return Ok(JsonView(false, "操作失败"));
  7538. }
  7539. /// <summary>
  7540. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7541. /// </summary>
  7542. /// <returns></returns>
  7543. [HttpPost]
  7544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7545. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7546. {
  7547. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7548. if (data.Code != 0)
  7549. {
  7550. return Ok(JsonView(false, data.Msg));
  7551. }
  7552. return Ok(JsonView(true, "操作成功!", data.Data));
  7553. }
  7554. /// <summary>
  7555. /// 三公其他费用草稿 删除
  7556. /// </summary>
  7557. /// <param name="dto"></param>
  7558. /// <returns></returns>
  7559. [HttpPost]
  7560. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7561. {
  7562. var jw = JsonView(false, "删除失败!");
  7563. var data = new Grp_DayOtherPriceDraft()
  7564. {
  7565. Id = dto.Id,
  7566. IsDel = 1,
  7567. DeleteUserId = dto.DeleteUserId,
  7568. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7569. };
  7570. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7571. if (del > 0)
  7572. {
  7573. jw.Code = 200;
  7574. jw.Msg = "删除成功!";
  7575. }
  7576. return Ok(jw);
  7577. }
  7578. /// <summary>
  7579. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7580. /// </summary>
  7581. /// <param name="dto"></param>
  7582. /// <returns></returns>
  7583. [HttpPost]
  7584. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7585. {
  7586. var jw = JsonView(false);
  7587. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7588. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new {x.Id,x.DraftName }).ToListAsync();
  7589. jw.Code = StatusCodes.Status200OK;
  7590. jw.Msg = "操作成功!";
  7591. jw.Data = new { groupNameDatas= groupNameDatas.Data, draftNames = draftDatas };
  7592. return Ok(jw);
  7593. }
  7594. /// <summary>
  7595. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7596. /// </summary>
  7597. /// <param name="dto"></param>
  7598. /// <returns></returns>
  7599. [HttpPost]
  7600. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7601. {
  7602. int userId = dto.UserId,
  7603. portId = dto.PortType,
  7604. groupId = dto.GroupId,
  7605. draftId = dto.DraftId;
  7606. _portTypeData.Add(1);
  7607. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7608. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7609. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7610. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7611. _sqlSugar.BeginTran();
  7612. try
  7613. {
  7614. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7615. if (draftDatas == null)
  7616. {
  7617. _sqlSugar.RollbackTran();
  7618. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7619. }
  7620. //验证可覆盖已有数据 两边创建人需为同一人;
  7621. int draftCreateUserId = draftDatas.CreateUserId,
  7622. formalCreateUserId = 0;
  7623. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7624. if (formalData != null)
  7625. {
  7626. formalCreateUserId = formalData.CreateUserId;
  7627. if (draftCreateUserId != formalCreateUserId)
  7628. {
  7629. _sqlSugar.RollbackTran();
  7630. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7631. }
  7632. }
  7633. var permissionUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  7634. var userIds = permissionUsers.Select(x => x.Id).ToList();
  7635. var permissions = new List<Grp_EnterExitCostPermission>();
  7636. if (userIds.Any())
  7637. {
  7638. foreach (var userId1 in userIds)
  7639. {
  7640. permissions.Add(new Grp_EnterExitCostPermission() {
  7641. GroupId = groupId,
  7642. UserId = userId1,
  7643. CreateUserId = dto.UserId
  7644. });
  7645. }
  7646. }
  7647. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7648. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7649. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7650. newExterData.DiId = groupId;
  7651. newExterData.CreateUserId = userId;
  7652. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7653. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7654. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7655. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7656. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7657. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7658. //数据如果存在执行删除
  7659. if (enterExitCostInfo != null)
  7660. {
  7661. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7662. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7663. .Where(x => x.Id == enterExitCostInfo.Id)
  7664. .ExecuteCommand();
  7665. _sqlSugar.Updateable<Grp_DayAndCost>()
  7666. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7667. .Where(x => x.DiId == groupId)
  7668. .ExecuteCommand();
  7669. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7670. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7671. .Where(x => x.Diid == groupId)
  7672. .ExecuteCommand();
  7673. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7674. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7675. .Where(x => x.GroupId == groupId)
  7676. .ExecuteCommand();
  7677. }
  7678. //执行insert
  7679. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7680. if (insertId < 1)
  7681. {
  7682. _sqlSugar.RollbackTran();
  7683. return Ok(JsonView(false, "草稿数据导入失败!"));
  7684. }
  7685. if (permissions.Any()) _sqlSugar.Insertable(permissions).ExecuteCommand();
  7686. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7687. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7688. _sqlSugar.CommitTran();
  7689. //执行操作之后
  7690. //生成默认文件pdf并且通知人员
  7691. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7692. {
  7693. DiId = groupId,
  7694. ExportType = 1,
  7695. SubTypeId = 1005
  7696. }, "pdf");
  7697. //发送通知
  7698. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7699. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7700. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7701. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7702. //汇率信息记录
  7703. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7704. return Ok(JsonView(true));
  7705. }
  7706. catch (Exception ex)
  7707. {
  7708. _sqlSugar.RollbackTran();
  7709. return Ok(JsonView(false,ex.Message));
  7710. }
  7711. }
  7712. #endregion
  7713. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7714. /// <summary>
  7715. /// 获取币种基础数据(含逻辑处理)
  7716. /// </summary>
  7717. /// <returns></returns>
  7718. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7719. {
  7720. //默认币种显示
  7721. var _currencyInfos = _currencyInit;
  7722. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  7723. if (_currencyRate.Count > 0)
  7724. {
  7725. foreach (var item in _currencyInfos)
  7726. {
  7727. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7728. if (rateInfo != null)
  7729. {
  7730. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  7731. rate1 *= 1.035M;
  7732. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7733. }
  7734. }
  7735. }
  7736. return _currencyInfos;
  7737. }
  7738. /// <summary>
  7739. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7740. /// </summary>
  7741. /// <returns></returns>
  7742. [HttpPost]
  7743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7744. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7745. {
  7746. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7747. //SetDataInfoView
  7748. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7749. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7750. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7751. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7752. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7753. //默认币种显示
  7754. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7755. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7756. return Ok(JsonView(true, "查询成功!", new
  7757. {
  7758. WordTypeData = _WordTypeData,
  7759. ExcelTypeData = _ExcelTypeData,
  7760. CurrencyInit = _currencyInfos,
  7761. viewPermissionData = viewPermissionData
  7762. }));
  7763. }
  7764. /// <summary>
  7765. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7766. /// </summary>
  7767. /// <returns></returns>
  7768. [HttpPost]
  7769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7770. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7771. {
  7772. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7773. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7774. RefAsync<int> total = 0;
  7775. int diId = 0;
  7776. var status = int.TryParse(dto.GroupName, out diId);
  7777. string sql = string.Format(@"SELECT
  7778. Id,
  7779. TeamName GroupName,
  7780. CASE WHEN EXISTS (
  7781. SELECT
  7782. 1
  7783. FROM
  7784. Grp_EnterExitCost
  7785. WHERE
  7786. IsDel = 0
  7787. AND DiId = di.Id
  7788. ) THEN 1 ELSE 0 END AS [IsNull],
  7789. CASE WHEN EXISTS(
  7790. SELECT
  7791. TOP 1 *
  7792. FROM
  7793. Grp_EnterExitCost
  7794. WHERE
  7795. IsDel = 0
  7796. AND DiId = di.Id
  7797. AND CreateUserId = {0}
  7798. ORDER BY
  7799. CreateTime DESC
  7800. ) THEN 1 ELSE 0 END AS [IsEdit],
  7801. CASE WHEN EXISTS(
  7802. SELECT
  7803. TOP 1 *
  7804. FROM
  7805. Grp_EnterExitCost
  7806. WHERE
  7807. IsDel = 0
  7808. AND DiId = di.Id
  7809. AND CreateUserId = {0}
  7810. ORDER BY
  7811. CreateTime DESC
  7812. ) THEN 1 WHEN EXISTS(
  7813. SELECT
  7814. TOP 1 *
  7815. FROM
  7816. Grp_EnterExitCostPermission
  7817. WHERE
  7818. IsDel = 0
  7819. AND GroupId = di.Id
  7820. AND Permission = 1
  7821. AND UserId = {0}
  7822. ORDER BY
  7823. CreateTime DESC
  7824. ) THEN 1 ELSE 0 END AS [IsView]
  7825. FROM
  7826. Grp_DelegationInfo di
  7827. WHERE
  7828. di.Isdel = 0 ",dto.CurrUserId);
  7829. var data = await _sqlSugar.SqlQueryable<EnterExitCostMobileGroupView>(sql)
  7830. .Where(x => !string.IsNullOrEmpty(x.GroupName))
  7831. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7832. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.GroupName.Contains(dto.GroupName))
  7833. .OrderByDescending(x => x.Id)
  7834. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7835. return Ok(JsonView(true, "查询成功!", data, total));
  7836. }
  7837. /// <summary>
  7838. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7839. /// </summary>
  7840. /// <returns></returns>
  7841. [HttpPost]
  7842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7843. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7844. {
  7845. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7846. RefAsync<int> total = 0;
  7847. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7848. .Where(x => x.IsDel == 0 && x.STid == 66)
  7849. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7850. .Select(x => new
  7851. {
  7852. id = x.Id,
  7853. name = x.Name,
  7854. remark = x.Remark,
  7855. })
  7856. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7857. return Ok(JsonView(true, "查询成功!", data, total));
  7858. }
  7859. /// <summary>
  7860. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7861. /// </summary>
  7862. /// <returns></returns>
  7863. [HttpPost]
  7864. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7865. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7866. {
  7867. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7868. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7869. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7870. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7871. var groupOtherRateData = groupRateData.TeamRates;
  7872. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7873. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  7874. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  7875. groupOtherRateData = groupOtherRateData
  7876. .Select(x => new TeamRateDescAddCurrencyIdView {
  7877. CurrencyId = x.CurrencyId,
  7878. CurrencyName = x.CurrencyName,
  7879. CurrencyCode = x.CurrencyCode,
  7880. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  7881. }).ToList();
  7882. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  7883. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData= groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  7884. }
  7885. /// <summary>
  7886. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  7887. /// </summary>
  7888. /// <returns></returns>
  7889. [HttpPost]
  7890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7891. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  7892. {
  7893. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7894. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7895. var tipsData = new List<int>() {1,2,3 };
  7896. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  7897. if (dto.TipsType == 1)
  7898. {
  7899. //默认币种显示
  7900. var _currencyInfos = _currencyInit;
  7901. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  7902. List<dynamic> reteInfos = new List<dynamic>();
  7903. if (_currencyRate.Count > 0)
  7904. {
  7905. foreach (var item in _currencyInfos)
  7906. {
  7907. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7908. if (rateInfo != null)
  7909. {
  7910. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  7911. decimal rate1 = item.Rate;
  7912. rate1 *= 1.03M;
  7913. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7914. reteInfos.Add(new
  7915. {
  7916. currCode = item.CurrencyCode,
  7917. currName = item.CurrencyName,
  7918. rate = rate2,
  7919. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  7920. });
  7921. }
  7922. }
  7923. }
  7924. return Ok(JsonView(true, "查询成功!", reteInfos));
  7925. }
  7926. else if (dto.TipsType == 2)
  7927. {
  7928. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  7929. return Ok(JsonView(true, "查询成功!", visaData.Data));
  7930. }
  7931. else if (dto.TipsType == 3)
  7932. {
  7933. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  7934. return Ok(JsonView(true, "查询成功!", airData.Data));
  7935. }
  7936. return Ok(JsonView(false));
  7937. }
  7938. /// <summary>
  7939. /// 团组模块 - 出入境国家费用标准-移动端 List
  7940. /// </summary>
  7941. /// <returns></returns>
  7942. [HttpPost]
  7943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7944. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  7945. {
  7946. Stopwatch sw = new Stopwatch();
  7947. sw.Start();
  7948. RefAsync<int> total = 0;
  7949. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7950. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  7951. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  7952. .Where((ntf, sd, u) => ntf.IsDel == 0)
  7953. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  7954. .Select((ntf, sd, u) => new
  7955. {
  7956. Id = ntf.Id,
  7957. Area = $"{ntf.Country}-{ntf.City}",
  7958. Currency = ntf.Currency,
  7959. CurrencyCode = sd.Name,
  7960. CurrencyName = sd.Remark,
  7961. RoomCost = ntf.RoomCost,
  7962. FoodCost = ntf.FoodCost,
  7963. PublicCost = ntf.PublicCost,
  7964. LastUpdateUserId = ntf.LastUpdateUserId,
  7965. LastUpdateUserName = u.CnName,
  7966. LastUpdateTime = ntf.LastUpdateTime,
  7967. })
  7968. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7969. sw.Stop();
  7970. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data,total));
  7971. }
  7972. /// <summary>
  7973. /// 团组模块 - 出入境费用-移动端 - Info
  7974. /// </summary>
  7975. /// <returns></returns>
  7976. [HttpPost]
  7977. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7978. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  7979. {
  7980. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7981. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7982. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  7983. return Ok(data);
  7984. }
  7985. /// <summary>
  7986. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  7987. /// </summary>
  7988. /// <returns></returns>
  7989. [HttpPost]
  7990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7991. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  7992. {
  7993. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7994. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7995. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7996. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7997. var mobileInfo = new EnterExitCostMobileParentInfoView();
  7998. mobileInfo.DiId = dto.DiId;
  7999. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8000. if (eecInfo == null) return Ok(mobileInfo);
  8001. //验证查看权限
  8002. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8003. if (!isView) return Ok(JsonView(false, msg));
  8004. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8005. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8006. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8007. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8008. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8009. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8010. {
  8011. SubId = dac.Id,
  8012. DiId = dac.DiId,
  8013. Type = dac.Type,
  8014. Days = dac.Days,
  8015. NationalTravelFeeId = dac.NationalTravelFeeId,
  8016. Arae = $"{ntf.Country}-{ntf.City}",
  8017. Cost = dac.Cost,
  8018. Currency = dac.Currency,
  8019. CurrencyName = sd.Name,
  8020. SubTotal = dac.SubTotal,
  8021. })
  8022. .ToList();
  8023. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8024. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8025. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8026. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8027. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8028. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8029. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8030. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8031. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8032. //其他款项
  8033. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8034. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8035. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8036. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8037. .OrderBy((dop, sd1, sd2) => dop.Index)
  8038. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8039. {
  8040. SubId = dop.Id,
  8041. DiId = dop.Diid,
  8042. Index = dop.Index,
  8043. SetDataId = dop.SetDataId,
  8044. SetDataName = sd1.Name,
  8045. Cost = dop.Cost,
  8046. Currency = dop.Currency,
  8047. CurrencyName = sd2.Remark,
  8048. SubTotal = dop.SubTotal,
  8049. Remark = dop.Remark,
  8050. })
  8051. .ToArray();
  8052. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8053. return Ok(mobileInfo);
  8054. }
  8055. /// <summary>
  8056. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8057. /// </summary>
  8058. /// <returns></returns>
  8059. [HttpPost]
  8060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8061. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8062. {
  8063. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8064. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8065. //验证查看权限
  8066. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8067. if (!isView) return Ok(JsonView(false, msg));
  8068. var userIds = Array.Empty<int>();
  8069. userIds = await _sqlSugar
  8070. .Queryable<Grp_EnterExitCostPermission>()
  8071. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8072. .Select(x => x.UserId)
  8073. .ToArrayAsync();
  8074. return Ok(userIds);
  8075. }
  8076. /// <summary>
  8077. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8078. /// </summary>
  8079. /// <returns></returns>
  8080. [HttpPost]
  8081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8082. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8083. {
  8084. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8085. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8086. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8087. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8088. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8089. //验证查看权限
  8090. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8091. if (!isView) return Ok(JsonView(false, msg));
  8092. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8093. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8094. var subType = dto.SubType;
  8095. if (subType == 1) //1:境内费用
  8096. {
  8097. var oneData = new ChoiceOneMobileSubInfoView()
  8098. {
  8099. Id = eecInfo.Id,
  8100. ChoiceOne = eecInfo.ChoiceOne,
  8101. ChoiceOneTotalCost = eecInfo.InsidePay,
  8102. Visa = eecInfo.Visa,
  8103. VisaRemark = eecInfo.VisaRemark,
  8104. YiMiao = eecInfo.YiMiao,
  8105. HeSuan = eecInfo.HeSuan,
  8106. Service = eecInfo.Service,
  8107. Ticket = eecInfo.Ticket,
  8108. Safe = eecInfo.Safe,
  8109. FirstItemRemark = eecInfo.FirstItemRemark
  8110. };
  8111. return Ok(JsonView(oneData));
  8112. }
  8113. else if (subType == 2) //2:国际旅费
  8114. {
  8115. var twoData = new ChoiceTwoMobileSubInfoView() {
  8116. Id = eecInfo.Id,
  8117. ChoiceTwoJJ = eecInfo.SumJJC,
  8118. OutsideJJPay = eecInfo.OutsideJJPay,
  8119. ChoiceTwoGW = eecInfo.SumGWC,
  8120. OutsideGWPay = eecInfo.OutsideGWPay,
  8121. ChoiceTwoTD = eecInfo.SumTDC,
  8122. OutsideTDPay = eecInfo.OutsideTDPay,
  8123. AirJJ = eecInfo.AirJJ,
  8124. AirGW = eecInfo.AirGW,
  8125. AirTD = eecInfo.AirTD,
  8126. CityTranffic = eecInfo.CityTranffic,
  8127. TwoItemRemark = eecInfo.TwoItemRemark
  8128. };
  8129. return Ok(JsonView(twoData));
  8130. }
  8131. else if (subType == 3) //3:住宿费
  8132. {
  8133. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8134. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8135. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8136. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8137. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8138. {
  8139. SubId = dac.Id,
  8140. DiId = dac.DiId,
  8141. Type = dac.Type,
  8142. Days = dac.Days,
  8143. NationalTravelFeeId = dac.NationalTravelFeeId,
  8144. Arae = $"{ntf.Country}-{ntf.City}",
  8145. Cost = dac.Cost,
  8146. Currency = dac.Currency,
  8147. CurrencyName = sd.Name,
  8148. SubTotal = dac.SubTotal,
  8149. })
  8150. .ToArray();
  8151. var data = new ChoiceMobileSubInfo3To6View() {
  8152. ParentId = eecInfo.Id,
  8153. Choice = eecInfo.ChoiceThree,
  8154. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8155. Details = dayAndCostDatas
  8156. };
  8157. return Ok(JsonView(data));
  8158. }
  8159. else if (subType == 4) //4:伙食费
  8160. {
  8161. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8162. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8163. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8164. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8165. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8166. {
  8167. SubId = dac.Id,
  8168. DiId = dac.DiId,
  8169. Type = dac.Type,
  8170. Days = dac.Days,
  8171. NationalTravelFeeId = dac.NationalTravelFeeId,
  8172. Arae = $"{ntf.Country}-{ntf.City}",
  8173. Cost = dac.Cost,
  8174. Currency = dac.Currency,
  8175. CurrencyName = sd.Name,
  8176. SubTotal = dac.SubTotal,
  8177. })
  8178. .ToArray();
  8179. var data = new ChoiceMobileSubInfo3To6View()
  8180. {
  8181. ParentId = eecInfo.Id,
  8182. Choice = eecInfo.ChoiceFour,
  8183. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8184. Details = dayAndCostDatas
  8185. };
  8186. return Ok(JsonView(data));
  8187. }
  8188. else if (subType == 5) //5:公杂费
  8189. {
  8190. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8191. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8192. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8193. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8194. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8195. {
  8196. SubId = dac.Id,
  8197. DiId = dac.DiId,
  8198. Type = dac.Type,
  8199. Days = dac.Days,
  8200. NationalTravelFeeId = dac.NationalTravelFeeId,
  8201. Arae = $"{ntf.Country}-{ntf.City}",
  8202. Cost = dac.Cost,
  8203. Currency = dac.Currency,
  8204. CurrencyName = sd.Name,
  8205. SubTotal = dac.SubTotal,
  8206. })
  8207. .ToArray();
  8208. var data = new ChoiceMobileSubInfo3To6View()
  8209. {
  8210. ParentId = eecInfo.Id,
  8211. Choice = eecInfo.ChoiceFive,
  8212. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8213. Details = dayAndCostDatas
  8214. };
  8215. return Ok(JsonView(data));
  8216. }
  8217. else if (subType == 6) //6:培训费
  8218. {
  8219. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8220. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8221. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8222. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8223. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8224. {
  8225. SubId = dac.Id,
  8226. DiId = dac.DiId,
  8227. Type = dac.Type,
  8228. Days = dac.Days,
  8229. NationalTravelFeeId = dac.NationalTravelFeeId,
  8230. Arae = $"{ntf.Country}-{ntf.City}",
  8231. Cost = dac.Cost,
  8232. Currency = dac.Currency,
  8233. CurrencyName = sd.Name,
  8234. SubTotal = dac.SubTotal,
  8235. })
  8236. .ToArray();
  8237. var data = new ChoiceMobileSubInfo3To6View()
  8238. {
  8239. ParentId = eecInfo.Id,
  8240. Choice = eecInfo.ChoiceSix,
  8241. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8242. Details = dayAndCostDatas
  8243. };
  8244. return Ok(JsonView(data));
  8245. }
  8246. else if (subType == 7) //7:其他
  8247. {
  8248. //其他款项
  8249. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8250. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8251. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8252. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8253. .OrderBy((dop, sd1, sd2) => dop.Index)
  8254. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8255. {
  8256. SubId = dop.Id,
  8257. DiId = dop.Diid,
  8258. Index = dop.Index,
  8259. SetDataId = dop.SetDataId,
  8260. SetDataName = sd1.Name,
  8261. Cost = dop.Cost,
  8262. Currency = dop.Currency,
  8263. CurrencyName = sd2.Name,
  8264. SubTotal = dop.SubTotal,
  8265. Remark = dop.Remark,
  8266. })
  8267. .ToArray();
  8268. var data = new ChoiceSevenMobileSubInfoView()
  8269. {
  8270. ParentId = eecInfo.Id,
  8271. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8272. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8273. Details = otherData
  8274. };
  8275. return Ok(JsonView(data));
  8276. }
  8277. return Ok(JsonView(false));
  8278. }
  8279. #region op
  8280. /// <summary>
  8281. /// 移动端更新费用消息通知
  8282. /// </summary>
  8283. /// <param name="diid"></param>
  8284. /// <param name="id"></param>
  8285. /// <param name="currUserId"></param>
  8286. private async Task EnterExitCostMobileOpNotice(int diid, int id,int currUserId)
  8287. {
  8288. try
  8289. {
  8290. ////生成默认文件pdf并且通知人员
  8291. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8292. //{
  8293. // DiId = diid,
  8294. // ExportType = 1,
  8295. // SubTypeId = 1005
  8296. //}, "pdf");
  8297. ////发送通知
  8298. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8299. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8300. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8301. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8302. ////汇率信息记录
  8303. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8304. }
  8305. catch (Exception ex)
  8306. {
  8307. //记录日志
  8308. throw;
  8309. }
  8310. }
  8311. /// <summary>
  8312. /// 验证出入境费用数据是否存在
  8313. /// 不存在添加
  8314. /// </summary>
  8315. /// <param name="diId"></param>
  8316. /// <param name="currUserId"></param>
  8317. /// <returns></returns>
  8318. /// <exception cref="CustomException"></exception>
  8319. private async Task<int> EnterExitCostVerifyIsNull(int diId,int currUserId)
  8320. {
  8321. var parentId = 0;
  8322. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8323. if (info != null) {
  8324. parentId = info.Id;
  8325. }
  8326. else
  8327. {
  8328. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8329. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8330. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8331. parentId = addId;
  8332. }
  8333. return parentId;
  8334. }
  8335. /// <summary>
  8336. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8337. /// </summary>
  8338. /// <returns></returns>
  8339. [HttpPost]
  8340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8341. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8342. {
  8343. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8344. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8345. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8346. //验证编辑权限
  8347. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8348. if (!isEdit) return Ok(JsonView(false, msg));
  8349. var permissions = new List<Grp_EnterExitCostPermission>();
  8350. foreach (var userId in dto.UserIds)
  8351. {
  8352. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8353. }
  8354. if (permissions.Any())
  8355. {
  8356. _sqlSugar.BeginTran();
  8357. try
  8358. {
  8359. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8360. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8361. if (result < 1)
  8362. {
  8363. _sqlSugar.RollbackTran();
  8364. return Ok(JsonView(false));
  8365. }
  8366. }
  8367. catch (Exception ex)
  8368. {
  8369. _sqlSugar.RollbackTran();
  8370. return Ok(JsonView(false, ex.Message));
  8371. }
  8372. _sqlSugar.CommitTran();
  8373. return Ok(JsonView(true));
  8374. }
  8375. return Ok(JsonView(false));
  8376. }
  8377. /// <summary>
  8378. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8379. /// </summary>
  8380. /// <returns></returns>
  8381. [HttpPost]
  8382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8383. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8384. {
  8385. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8386. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8387. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8388. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8389. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8390. int id = dto.Id;
  8391. if (id <= 0) //add
  8392. {
  8393. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8394. if (add < 1) return Ok(JsonView(false));
  8395. id = add;
  8396. }
  8397. else //update
  8398. {
  8399. //验证编辑权限
  8400. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8401. if (!isEdit) return Ok(JsonView(false, msg));
  8402. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8403. if (upd < 1) return Ok(JsonView(false));
  8404. }
  8405. #region 汇率变更时更改币种相关费用
  8406. var opDayCosts = new List<Grp_DayAndCost>();
  8407. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8408. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8409. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8410. .LeftJoin<Sys_SetData>((dac,sd) => dac.Currency == sd.Id)
  8411. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8412. .Select((dac, sd) => new {
  8413. dac.Id,
  8414. dac.DiId,
  8415. CurrencyCode = sd.Name,
  8416. dac.Cost
  8417. })
  8418. .ToList();
  8419. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8420. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8421. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8422. .Select((dop, sd) => new {
  8423. dop.Id,
  8424. dop.Diid,
  8425. CurrencyCode = sd.Name,
  8426. dop.Cost
  8427. })
  8428. .ToList();
  8429. if (dayCosts.Count > 0)
  8430. {
  8431. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8432. foreach (var dc in new_dayCosts)
  8433. {
  8434. var thisCurrency = dc.Key.ToUpper();
  8435. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8436. if (thisRate == 0.00M) continue;
  8437. foreach (var dcSub in dc)
  8438. {
  8439. opDayCosts.Add(new Grp_DayAndCost() {
  8440. Id = dcSub.Id,
  8441. DiId = dcSub.DiId,
  8442. Cost = dcSub.Cost,
  8443. SubTotal = dcSub.Cost * thisRate,
  8444. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8445. });
  8446. }
  8447. }
  8448. if (opDayCosts.Count > 0)
  8449. {
  8450. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8451. }
  8452. }
  8453. if (dayOtherCosts.Count > 0)
  8454. {
  8455. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8456. foreach (var dc in new_dayOtherCosts)
  8457. {
  8458. var thisCurrency = dc.Key.ToUpper();
  8459. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8460. if (thisRate == 0.00M) continue;
  8461. foreach (var dcSub in dc)
  8462. {
  8463. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8464. {
  8465. Id = dcSub.Id,
  8466. Diid = dcSub.Diid,
  8467. Cost = dcSub.Cost,
  8468. SubTotal = dcSub.Cost * thisRate,
  8469. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8470. });
  8471. }
  8472. }
  8473. if (opDayOtherCosts.Count > 0)
  8474. {
  8475. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8476. }
  8477. }
  8478. #endregion
  8479. //消息通知
  8480. await EnterExitCostMobileOpNotice(dto.DiId, id,dto.CurrUserId);
  8481. //汇率信息记录
  8482. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8483. return Ok(JsonView(new { parentId = id }));
  8484. }
  8485. /// <summary>
  8486. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8487. /// </summary>
  8488. /// <returns></returns>
  8489. [HttpPost]
  8490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8491. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8492. {
  8493. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8494. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8495. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8496. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8497. int id = dto.Id;
  8498. if (id <= 0) //add
  8499. {
  8500. checkboxInfo.CreateUserId = dto.CurrUserId;
  8501. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8502. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8503. if (add < 1) return Ok(JsonView(false));
  8504. }
  8505. else //update
  8506. {
  8507. //验证编辑权限
  8508. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8509. if (!isEdit) return Ok(JsonView(false, msg));
  8510. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8511. .UpdateColumns(x => new {
  8512. x.ChoiceOne,
  8513. x.ChoiceTwo,
  8514. x.SumJJC,
  8515. x.SumGWC,
  8516. x.SumTDC,
  8517. x.ChoiceThree,
  8518. x.ChoiceFour,
  8519. x.ChoiceFive,
  8520. x.ChoiceSix,
  8521. x.OtherExpenses_Checked
  8522. })
  8523. .Where(x => x.Id == id)
  8524. .ExecuteCommandAsync();
  8525. if (upd < 1) return Ok(JsonView(false));
  8526. }
  8527. return Ok(JsonView(new { parentId = id }));
  8528. }
  8529. /// <summary>
  8530. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8531. /// </summary>
  8532. /// <returns></returns>
  8533. [HttpPost]
  8534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8535. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8536. {
  8537. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId,isSelected = dto.IsSelected;
  8538. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8539. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8540. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8541. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8542. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8543. var checkboxInfo = new Grp_EnterExitCost() {
  8544. Id = id,
  8545. DiId = diId,
  8546. CreateUserId = currUserId
  8547. };
  8548. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8549. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8550. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8551. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8552. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8553. if (id <= 0) //add
  8554. {
  8555. checkboxInfo.CreateUserId = dto.CurrUserId;
  8556. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8557. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8558. if (add < 1) return Ok(JsonView(false));
  8559. }
  8560. else //update
  8561. {
  8562. //验证编辑权限
  8563. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8564. if (!isEdit) return Ok(JsonView(false, msg));
  8565. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8566. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8567. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8568. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8569. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8570. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8571. .Where(x => x.Id == id)
  8572. .ExecuteCommandAsync();
  8573. if (upd < 1) return Ok(JsonView(false));
  8574. }
  8575. return Ok(JsonView(new { parentId = id }));
  8576. }
  8577. /// <summary>
  8578. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8579. /// </summary>
  8580. /// <returns></returns>
  8581. [HttpPost]
  8582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8583. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8584. {
  8585. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8586. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8587. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8588. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8589. info.FirstItemRemark = dto.FirstItemRemark;
  8590. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8591. int id = dto.Id;
  8592. if (id <= 0) //add
  8593. {
  8594. info.CreateUserId = dto.CurrUserId;
  8595. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8596. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8597. if (add < 1) return Ok(JsonView(false));
  8598. id = add;
  8599. }
  8600. else //update
  8601. {
  8602. //验证编辑权限
  8603. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8604. if (!isEdit) return Ok(JsonView(false, msg));
  8605. var upd = await _sqlSugar.Updateable(info)
  8606. .UpdateColumns(x => new {
  8607. x.ChoiceOne,
  8608. x.InsidePay,
  8609. x.VisaRemark,
  8610. x.Visa,
  8611. x.Service,
  8612. x.Safe,
  8613. x.Ticket,
  8614. x.HeSuan,
  8615. x.YiMiao,
  8616. x.FirstItemRemark
  8617. })
  8618. .Where(x => x.Id == id)
  8619. .ExecuteCommandAsync();
  8620. if (upd < 1) return Ok(JsonView(false));
  8621. }
  8622. //消息通知
  8623. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8624. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8625. }
  8626. /// <summary>
  8627. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8628. /// </summary>
  8629. /// <returns></returns>
  8630. [HttpPost]
  8631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8632. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8633. {
  8634. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8635. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8636. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8637. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8638. info.OutsideJJPay = dto.OutsideJJPay;
  8639. info.OutsideGWPay = dto.OutsideGWPay;
  8640. info.OutsideTDPay = dto.OutsideTDPay;
  8641. info.AirJJ = dto.AirJJ;
  8642. info.AirGW = dto.AirGW;
  8643. info.AirTD = dto.AirTD;
  8644. info.CityTranffic = dto.CityTranffic;
  8645. info.TwoItemRemark = dto.TwoItemRemark;
  8646. info.SumJJC = dto.ChoiceTwoJJ;
  8647. info.SumGWC = dto.ChoiceTwoGW;
  8648. info.SumTDC = dto.ChoiceTwoTD;
  8649. int id = dto.Id;
  8650. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8651. if (id <= 0) //add
  8652. {
  8653. info.CreateUserId = dto.CurrUserId;
  8654. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8655. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8656. if (addId <= 0) return Ok(JsonView(false));
  8657. id = addId;
  8658. }
  8659. else //update
  8660. {
  8661. //验证编辑权限
  8662. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8663. if (!isEdit) return Ok(JsonView(false, msg));
  8664. var upd = await _sqlSugar.Updateable(info)
  8665. .UpdateColumns(x => new {
  8666. x.SumJJC,
  8667. x.OutsideJJPay,
  8668. x.SumGWC,
  8669. x.OutsideGWPay,
  8670. x.SumTDC,
  8671. x.OutsideTDPay,
  8672. x.AirJJ,
  8673. x.AirGW,
  8674. x.AirTD,
  8675. x.CityTranffic,
  8676. x.TwoItemRemark
  8677. })
  8678. .Where(x => x.Id == id)
  8679. .ExecuteCommandAsync();
  8680. if (upd <1) return Ok(JsonView(false));
  8681. }
  8682. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8683. gwcItemTotal = info.AirGW + info.CityTranffic;
  8684. tdcItemTotal = info.AirTD + info.CityTranffic;
  8685. //消息通知
  8686. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8687. return Ok(JsonView(new
  8688. {
  8689. parentId = id,
  8690. choiceTwoJJ = dto.ChoiceTwoJJ,
  8691. jjcItemTotal = jjcItemTotal,
  8692. choiceTwoGW = dto.ChoiceTwoGW,
  8693. gwcItemTotal = gwcItemTotal,
  8694. choiceTwoTD = dto.ChoiceTwoTD,
  8695. tdcItemTotal = tdcItemTotal
  8696. }));
  8697. }
  8698. /// <summary>
  8699. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8700. /// </summary>
  8701. /// <returns></returns>
  8702. [HttpPost]
  8703. [ApiExplorerSettings(IgnoreApi = true)]
  8704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8705. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8706. {
  8707. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8708. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8709. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8710. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8711. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8712. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8713. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8714. var infos = infos1.Select(x => new Grp_DayAndCost
  8715. {
  8716. Id = x.Id,
  8717. DiId = dto.DiId,
  8718. Type = dto.FeeType,
  8719. Days = x.Days,
  8720. NationalTravelFeeId = x.NationalTravelFeeId,
  8721. Cost = x.Cost,
  8722. Currency = x.Currency,
  8723. SubTotal = x.SubTotal,
  8724. CreateUserId = dto.CurrUserId
  8725. })
  8726. .ToList();
  8727. var adds = infos.Where(x => x.Id <= 0).ToList();
  8728. var upds = infos.Where(x => x.Id > 0).ToList();
  8729. if (adds.Count > 0)
  8730. {
  8731. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8732. if (add < 1) return Ok(JsonView(false));
  8733. }
  8734. if (upds.Count > 0)
  8735. {
  8736. var upd = await _sqlSugar.Updateable(adds)
  8737. .UpdateColumns(x => new
  8738. {
  8739. x.Days,
  8740. x.NationalTravelFeeId,
  8741. x.Cost,
  8742. x.Currency,
  8743. x.SubTotal
  8744. })
  8745. .WhereColumns(x => new { x.Id })
  8746. .ExecuteCommandAsync();
  8747. if (upd < 1) return Ok(JsonView(false));
  8748. }
  8749. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8750. //消息通知
  8751. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8752. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8753. return Ok(JsonView(new { itemTotal = itemTotal }));
  8754. }
  8755. /// <summary>
  8756. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8757. /// </summary>
  8758. /// <returns></returns>
  8759. [HttpPost]
  8760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8761. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8762. {
  8763. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8764. int subId = dto.SubId, feeType = dto.FeeType;
  8765. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8766. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8767. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8768. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8769. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8770. subInfo.Id = subId;
  8771. subInfo.DiId = dto.DiId;
  8772. if (feeType == 3) subInfo.Type = 1;
  8773. else if (feeType == 4) subInfo.Type = 2;
  8774. else if (feeType == 5) subInfo.Type = 3;
  8775. else if (feeType == 6) subInfo.Type = 4;
  8776. subInfo.CreateUserId = dto.CurrUserId;
  8777. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8778. if (parentId < 1) return Ok(JsonView(false));
  8779. //子表op
  8780. if (subId < 1)
  8781. {
  8782. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8783. if (subAdd < 1) return Ok(JsonView(false));
  8784. }
  8785. else
  8786. {
  8787. //验证编辑权限
  8788. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8789. if (!isEdit) return Ok(JsonView(false, msg));
  8790. var subUpd = await _sqlSugar.Updateable(subInfo)
  8791. .UpdateColumns(x => new
  8792. {
  8793. x.Days,
  8794. x.NationalTravelFeeId,
  8795. x.Cost,
  8796. x.Currency,
  8797. x.SubTotal
  8798. })
  8799. .WhereColumns(x => new { x.Id })
  8800. .ExecuteCommandAsync();
  8801. if (subUpd < 1) return Ok(JsonView(false));
  8802. }
  8803. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8804. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8805. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8806. }
  8807. /// <summary>
  8808. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8809. /// </summary>
  8810. /// <returns></returns>
  8811. [HttpPost]
  8812. [ApiExplorerSettings(IgnoreApi = true)]
  8813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8814. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8815. {
  8816. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8817. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8818. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8819. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8820. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8821. {
  8822. Id = x.Id,
  8823. Diid = dto.DiId,
  8824. SetDataId = x.SetDataId,
  8825. Index = x.Index,
  8826. Cost = x.Cost,
  8827. Currency = x.Currency,
  8828. SubTotal = x.SubTotal,
  8829. CreateUserId = dto.CurrUserId,
  8830. Remark = x.Remark
  8831. }).ToList();
  8832. var adds = infos.Where(x => x.Id <= 0).ToList();
  8833. var upds = infos.Where(x => x.Id > 0).ToList();
  8834. if (adds.Count > 0)
  8835. {
  8836. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8837. if (add < 1) return Ok(JsonView(false));
  8838. }
  8839. if (upds.Count > 0)
  8840. {
  8841. var upd = await _sqlSugar.Updateable(adds)
  8842. .UpdateColumns(x => new
  8843. {
  8844. x.Index,
  8845. x.SetDataId,
  8846. x.Cost,
  8847. x.Currency,
  8848. x.SubTotal,
  8849. x.Remark
  8850. })
  8851. .WhereColumns(x => new { x.Id })
  8852. .ExecuteCommandAsync();
  8853. if (upd < 1) return Ok(JsonView(false));
  8854. }
  8855. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8856. //消息通知
  8857. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8858. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8859. return Ok(JsonView(new { itemTotal = itemTotal }));
  8860. }
  8861. /// <summary>
  8862. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8863. /// </summary>
  8864. /// <returns></returns>
  8865. [HttpPost]
  8866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8867. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8868. {
  8869. int subId = dto.SubId;
  8870. int diId = dto.Diid;
  8871. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8872. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8873. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8874. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8875. subInfo.Id = subId;
  8876. subInfo.Diid = dto.Diid;
  8877. subInfo.CreateUserId = dto.CurrUserId;
  8878. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8879. if (parentId < 1) return Ok(JsonView(false));
  8880. #region 子表op
  8881. if (subId < 1)//add
  8882. {
  8883. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8884. if (subAdd < 1) return Ok(JsonView(false));
  8885. }
  8886. else //upd
  8887. {
  8888. //验证编辑权限
  8889. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  8890. if (!isEdit) return Ok(JsonView(false, msg));
  8891. var subUpd = await _sqlSugar.Updateable(subInfo)
  8892. .UpdateColumns(x => new
  8893. {
  8894. x.Index,
  8895. x.SetDataId,
  8896. x.Cost,
  8897. x.Currency,
  8898. x.SubTotal,
  8899. x.Remark
  8900. })
  8901. .WhereColumns(x => new { x.Id })
  8902. .ExecuteCommandAsync();
  8903. if (subUpd < 1) return Ok(JsonView(false));
  8904. }
  8905. #endregion
  8906. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  8907. //消息通知
  8908. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  8909. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8910. }
  8911. /// <summary>
  8912. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  8913. /// </summary>
  8914. /// <returns></returns>
  8915. [HttpPost]
  8916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8917. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  8918. {
  8919. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8920. if (data.Code != 0)
  8921. {
  8922. return Ok(JsonView(false, data.Msg));
  8923. }
  8924. return Ok(JsonView(true, "操作成功!", data.Data));
  8925. }
  8926. /// <summary>
  8927. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  8928. /// </summary>
  8929. /// <param name="dto"></param>
  8930. /// <returns></returns>
  8931. [HttpPost]
  8932. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  8933. {
  8934. var data = new Grp_DayOtherPrice()
  8935. {
  8936. Id = dto.Id,
  8937. IsDel = 1,
  8938. DeleteUserId = dto.DeleteUserId,
  8939. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8940. };
  8941. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8942. if (del > 0) return Ok(JsonView(true,"删除成功!"));
  8943. return Ok(JsonView(false,"删除失败!"));
  8944. }
  8945. #endregion
  8946. #endregion
  8947. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  8948. /// <summary>
  8949. /// 出入境费用-草稿 移动端
  8950. /// 获取币种基础数据(含逻辑处理)
  8951. /// </summary>
  8952. /// <returns></returns>
  8953. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  8954. {
  8955. //默认币种显示
  8956. var _currencyInfos = _currencyInit;
  8957. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  8958. if (_currencyRate.Count > 0)
  8959. {
  8960. foreach (var item in _currencyInfos)
  8961. {
  8962. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  8963. if (rateInfo != null)
  8964. {
  8965. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  8966. rate1 *= 1.035M;
  8967. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  8968. }
  8969. }
  8970. }
  8971. return _currencyInfos;
  8972. }
  8973. /// <summary>
  8974. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  8975. /// </summary>
  8976. /// <returns></returns>
  8977. [HttpPost]
  8978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8979. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(PortDtoBase dto)
  8980. {
  8981. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8982. //SetDataInfoView
  8983. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  8984. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  8985. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  8986. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  8987. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  8988. //默认币种显示
  8989. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  8990. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  8991. return Ok(JsonView(true, "查询成功!", new
  8992. {
  8993. WordTypeData = _WordTypeData,
  8994. ExcelTypeData = _ExcelTypeData,
  8995. CurrencyInit = _currencyInfos,
  8996. viewPermissionData= viewPermissionData
  8997. }));
  8998. }
  8999. /// <summary>
  9000. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9001. /// </summary>
  9002. /// <returns></returns>
  9003. [HttpPost]
  9004. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9005. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9006. {
  9007. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9008. RefAsync<int> total = 0;
  9009. int diId = 0;
  9010. var status = int.TryParse(dto.GroupName, out diId);
  9011. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9012. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9013. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9014. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9015. .Select(x => new
  9016. {
  9017. Id = x.Id,
  9018. GroupName = x.TeamName
  9019. })
  9020. .OrderByDescending(x => x.Id)
  9021. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9022. return Ok(JsonView(true, "查询成功!", data, total));
  9023. }
  9024. /// <summary>
  9025. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9026. /// </summary>
  9027. /// <returns></returns>
  9028. [HttpPost]
  9029. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9030. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9031. {
  9032. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9033. RefAsync<int> total = 0;
  9034. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9035. .Where(x => x.IsDel == 0 && x.STid == 66)
  9036. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9037. .Select(x => new
  9038. {
  9039. id = x.Id,
  9040. name = x.Name,
  9041. remark = x.Remark,
  9042. })
  9043. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9044. return Ok(JsonView(true, "查询成功!", data, total));
  9045. }
  9046. /// <summary>
  9047. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9048. /// </summary>
  9049. /// <returns></returns>
  9050. [HttpPost]
  9051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9052. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9053. {
  9054. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9055. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9056. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, 2274, 98);
  9057. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9058. var groupOtherRateData = groupRateData.TeamRates;
  9059. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9060. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9061. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9062. groupOtherRateData = groupOtherRateData
  9063. .Select(x => new TeamRateDescAddCurrencyIdView
  9064. {
  9065. CurrencyId = x.CurrencyId,
  9066. CurrencyName = x.CurrencyName,
  9067. CurrencyCode = x.CurrencyCode,
  9068. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9069. }).ToList();
  9070. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9071. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9072. }
  9073. /// <summary>
  9074. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9075. /// </summary>
  9076. /// <returns></returns>
  9077. [HttpPost]
  9078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9079. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9080. {
  9081. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9082. var tipsData = new List<int>() { 1, 2, 3 };
  9083. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9084. if (dto.TipsType == 1)
  9085. {
  9086. //默认币种显示
  9087. var _currencyInfos = _currencyInit;
  9088. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  9089. List<dynamic> reteInfos = new List<dynamic>();
  9090. if (_currencyRate.Count > 0)
  9091. {
  9092. foreach (var item in _currencyInfos)
  9093. {
  9094. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  9095. if (rateInfo != null)
  9096. {
  9097. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  9098. decimal rate1 = item.Rate;
  9099. rate1 *= 1.03M;
  9100. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  9101. reteInfos.Add(new
  9102. {
  9103. currCode = item.CurrencyCode,
  9104. currName = item.CurrencyName,
  9105. rate = rate2,
  9106. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  9107. });
  9108. }
  9109. }
  9110. }
  9111. return Ok(JsonView(true, "查询成功!", reteInfos));
  9112. }
  9113. else if (dto.TipsType == 2)
  9114. {
  9115. }
  9116. else if (dto.TipsType == 3)
  9117. {
  9118. }
  9119. return Ok(JsonView(false));
  9120. }
  9121. /// <summary>
  9122. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9123. /// </summary>
  9124. /// <returns></returns>
  9125. [HttpPost]
  9126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9127. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9128. {
  9129. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9130. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9131. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9132. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9133. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9134. if (eecInfo == null) return Ok(mobileInfo);
  9135. //验证查看权限
  9136. (bool isView, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId);
  9137. if (!isView) return Ok(JsonView(false, msg));
  9138. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9139. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9140. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9141. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9142. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9143. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9144. {
  9145. ParentId = dac.ParentId,
  9146. SubId = dac.Id,
  9147. Type = dac.Type,
  9148. Days = dac.Days,
  9149. NationalTravelFeeId = dac.NationalTravelFeeId,
  9150. Arae = $"{ntf.Country}-{ntf.City}",
  9151. Cost = dac.Cost,
  9152. Currency = dac.Currency,
  9153. CurrencyName = sd.Name,
  9154. SubTotal = dac.SubTotal,
  9155. })
  9156. .ToList();
  9157. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9158. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9159. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9160. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9161. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9162. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9163. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9164. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9165. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9166. //其他款项
  9167. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9168. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9169. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9170. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9171. .OrderBy((dop, sd1, sd2) => dop.Index)
  9172. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9173. {
  9174. ParentId = dop.ParentId,
  9175. SubId = dop.Id,
  9176. Index = dop.Index,
  9177. SetDataId = dop.SetDataId,
  9178. SetDataName = sd1.Name,
  9179. Cost = dop.Cost,
  9180. Currency = dop.Currency,
  9181. CurrencyName = sd2.Remark,
  9182. SubTotal = dop.SubTotal,
  9183. Remark = dop.Remark,
  9184. })
  9185. .ToArray();
  9186. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9187. return Ok(mobileInfo);
  9188. }
  9189. /// <summary>
  9190. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9191. /// </summary>
  9192. /// <returns></returns>
  9193. [HttpPost]
  9194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9195. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9196. {
  9197. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9198. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9199. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9200. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9201. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9202. //验证查看权限
  9203. (bool isView, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId);
  9204. if (!isView) return Ok(JsonView(false, msg));
  9205. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9206. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9207. var subType = dto.SubType;
  9208. if (subType == 1) //1:境内费用
  9209. {
  9210. var oneData = new ChoiceOneMobileSubInfoView()
  9211. {
  9212. Id = eecInfo.Id,
  9213. ChoiceOne = eecInfo.ChoiceOne,
  9214. ChoiceOneTotalCost = eecInfo.InsidePay,
  9215. Visa = eecInfo.Visa,
  9216. VisaRemark = eecInfo.VisaRemark,
  9217. YiMiao = eecInfo.YiMiao,
  9218. HeSuan = eecInfo.HeSuan,
  9219. Service = eecInfo.Service,
  9220. Ticket = eecInfo.Ticket,
  9221. Safe = eecInfo.Safe,
  9222. FirstItemRemark = eecInfo.FirstItemRemark
  9223. };
  9224. return Ok(JsonView(oneData));
  9225. }
  9226. else if (subType == 2) //2:国际旅费
  9227. {
  9228. var twoData = new ChoiceTwoMobileSubInfoView()
  9229. {
  9230. Id = eecInfo.Id,
  9231. ChoiceTwoJJ = eecInfo.SumJJC,
  9232. OutsideJJPay = eecInfo.OutsideJJPay,
  9233. ChoiceTwoGW = eecInfo.SumGWC,
  9234. OutsideGWPay = eecInfo.OutsideGWPay,
  9235. ChoiceTwoTD = eecInfo.SumTDC,
  9236. OutsideTDPay = eecInfo.OutsideTDPay,
  9237. AirJJ = eecInfo.AirJJ,
  9238. AirGW = eecInfo.AirGW,
  9239. AirTD = eecInfo.AirTD,
  9240. CityTranffic = eecInfo.CityTranffic,
  9241. TwoItemRemark = eecInfo.TwoItemRemark
  9242. };
  9243. return Ok(JsonView(twoData));
  9244. }
  9245. else if (subType == 3) //3:住宿费
  9246. {
  9247. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9248. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9249. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9250. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9251. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9252. {
  9253. ParentId = dac.ParentId,
  9254. SubId = dac.Id,
  9255. Type = dac.Type,
  9256. Days = dac.Days,
  9257. NationalTravelFeeId = dac.NationalTravelFeeId,
  9258. Arae = $"{ntf.Country}-{ntf.City}",
  9259. Cost = dac.Cost,
  9260. Currency = dac.Currency,
  9261. CurrencyName = sd.Name,
  9262. SubTotal = dac.SubTotal,
  9263. })
  9264. .ToArray();
  9265. var data = new ChoiceDraftMobileSubInfo3To6View()
  9266. {
  9267. ParentId = eecInfo.Id,
  9268. Choice = eecInfo.ChoiceThree,
  9269. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9270. Details = dayAndCostDatas
  9271. };
  9272. return Ok(JsonView(data));
  9273. }
  9274. else if (subType == 4) //4:伙食费
  9275. {
  9276. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9277. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9278. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9279. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9280. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9281. {
  9282. ParentId = dac.ParentId,
  9283. SubId = dac.Id,
  9284. Type = dac.Type,
  9285. Days = dac.Days,
  9286. NationalTravelFeeId = dac.NationalTravelFeeId,
  9287. Arae = $"{ntf.Country}-{ntf.City}",
  9288. Cost = dac.Cost,
  9289. Currency = dac.Currency,
  9290. CurrencyName = sd.Name,
  9291. SubTotal = dac.SubTotal,
  9292. })
  9293. .ToArray();
  9294. var data = new ChoiceDraftMobileSubInfo3To6View()
  9295. {
  9296. ParentId = eecInfo.Id,
  9297. Choice = eecInfo.ChoiceFour,
  9298. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9299. Details = dayAndCostDatas
  9300. };
  9301. return Ok(JsonView(data));
  9302. }
  9303. else if (subType == 5) //5:公杂费
  9304. {
  9305. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9306. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9307. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9308. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9309. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9310. {
  9311. ParentId = dac.ParentId,
  9312. SubId = dac.Id,
  9313. Type = dac.Type,
  9314. Days = dac.Days,
  9315. NationalTravelFeeId = dac.NationalTravelFeeId,
  9316. Arae = $"{ntf.Country}-{ntf.City}",
  9317. Cost = dac.Cost,
  9318. Currency = dac.Currency,
  9319. CurrencyName = sd.Name,
  9320. SubTotal = dac.SubTotal,
  9321. })
  9322. .ToArray();
  9323. var data = new ChoiceDraftMobileSubInfo3To6View()
  9324. {
  9325. ParentId = eecInfo.Id,
  9326. Choice = eecInfo.ChoiceFive,
  9327. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9328. Details = dayAndCostDatas
  9329. };
  9330. return Ok(JsonView(data));
  9331. }
  9332. else if (subType == 6) //6:培训费
  9333. {
  9334. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9335. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9336. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9337. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9338. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9339. {
  9340. ParentId = dac.ParentId,
  9341. SubId = dac.Id,
  9342. Type = dac.Type,
  9343. Days = dac.Days,
  9344. NationalTravelFeeId = dac.NationalTravelFeeId,
  9345. Arae = $"{ntf.Country}-{ntf.City}",
  9346. Cost = dac.Cost,
  9347. Currency = dac.Currency,
  9348. CurrencyName = sd.Name,
  9349. SubTotal = dac.SubTotal,
  9350. })
  9351. .ToArray();
  9352. var data = new ChoiceDraftMobileSubInfo3To6View()
  9353. {
  9354. ParentId = eecInfo.Id,
  9355. Choice = eecInfo.ChoiceSix,
  9356. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9357. Details = dayAndCostDatas
  9358. };
  9359. return Ok(JsonView(data));
  9360. }
  9361. else if (subType == 7) //7:其他
  9362. {
  9363. //其他款项
  9364. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9365. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9366. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9367. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9368. .OrderBy((dop, sd1, sd2) => dop.Index)
  9369. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9370. {
  9371. ParentId = dop.ParentId,
  9372. SubId = dop.Id,
  9373. Index = dop.Index,
  9374. SetDataId = dop.SetDataId,
  9375. SetDataName = sd1.Name,
  9376. Cost = dop.Cost,
  9377. Currency = dop.Currency,
  9378. CurrencyName = sd2.Name,
  9379. SubTotal = dop.SubTotal,
  9380. Remark = dop.Remark,
  9381. })
  9382. .ToArray();
  9383. var data = new ChoiceSevenDraftMobileSubInfoView()
  9384. {
  9385. ParentId = eecInfo.Id,
  9386. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9387. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9388. Details = otherData
  9389. };
  9390. return Ok(JsonView(data));
  9391. }
  9392. return Ok(JsonView(false));
  9393. }
  9394. #region op
  9395. /// <summary>
  9396. /// 移动端更新费用消息通知
  9397. /// </summary>
  9398. /// <param name="diid"></param>
  9399. /// <param name="id"></param>
  9400. /// <param name="currUserId"></param>
  9401. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9402. {
  9403. try
  9404. {
  9405. ////生成默认文件pdf并且通知人员
  9406. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9407. //{
  9408. // DiId = draftId,
  9409. // ExportType = 1,
  9410. // SubTypeId = 1005
  9411. //}, "pdf");
  9412. ////发送通知
  9413. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9414. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9415. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9416. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9417. ////汇率信息记录
  9418. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9419. }
  9420. catch (Exception ex)
  9421. {
  9422. //记录日志
  9423. throw;
  9424. }
  9425. }
  9426. /// <summary>
  9427. /// 验证出入境费用数据是否存在
  9428. /// 不存在添加
  9429. /// </summary>
  9430. /// <param name="draftId"></param>
  9431. /// <param name="currUserId"></param>
  9432. /// <returns></returns>
  9433. /// <exception cref="CustomException"></exception>
  9434. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9435. {
  9436. var parentId = 0;
  9437. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9438. if (info != null) parentId = info.Id;
  9439. else
  9440. {
  9441. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9442. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9443. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9444. parentId = addId;
  9445. }
  9446. return parentId;
  9447. }
  9448. /// <summary>
  9449. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9450. /// </summary>
  9451. /// <returns></returns>
  9452. [HttpPost]
  9453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9454. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9455. {
  9456. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9457. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9458. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9459. //验证编辑权限
  9460. (bool isEdit, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId, 2);
  9461. if (!isEdit) return Ok(JsonView(false, msg));
  9462. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  9463. foreach (var userId in dto.UserIds)
  9464. {
  9465. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9466. }
  9467. if (permissions.Any())
  9468. {
  9469. _sqlSugar.BeginTran();
  9470. try
  9471. {
  9472. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9473. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9474. if (result < 1)
  9475. {
  9476. _sqlSugar.RollbackTran();
  9477. return Ok(JsonView(false));
  9478. }
  9479. }
  9480. catch (Exception ex)
  9481. {
  9482. _sqlSugar.RollbackTran();
  9483. return Ok(JsonView(false, ex.Message));
  9484. }
  9485. _sqlSugar.CommitTran();
  9486. return Ok(JsonView(true));
  9487. }
  9488. return Ok(JsonView(false));
  9489. }
  9490. /// <summary>
  9491. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9492. /// </summary>
  9493. /// <returns></returns>
  9494. [HttpPost]
  9495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9496. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9497. {
  9498. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9499. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9500. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9501. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9502. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9503. int id = dto.DraftId;
  9504. if (id <= 0) //add
  9505. {
  9506. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9507. if (add < 1) return Ok(JsonView(false));
  9508. id = add;
  9509. }
  9510. else //update
  9511. {
  9512. //验证编辑权限
  9513. (bool isEdit, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId, 2);
  9514. if (!isEdit) return Ok(JsonView(false, msg));
  9515. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9516. if (upd < 1) return Ok(JsonView(false));
  9517. }
  9518. #region 汇率变更时更改币种相关费用
  9519. var opDayCosts = new List<Grp_DayAndCostDraft>();
  9520. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  9521. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9522. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9523. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9524. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9525. .Select((dac, sd) => new
  9526. {
  9527. dac.Id,
  9528. dac.ParentId,
  9529. CurrencyCode = sd.Name,
  9530. dac.Cost
  9531. })
  9532. .ToList();
  9533. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9534. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9535. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9536. .Select((dop, sd) => new
  9537. {
  9538. dop.Id,
  9539. dop.ParentId,
  9540. CurrencyCode = sd.Name,
  9541. dop.Cost
  9542. })
  9543. .ToList();
  9544. if (dayCosts.Count > 0)
  9545. {
  9546. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9547. foreach (var dc in new_dayCosts)
  9548. {
  9549. var thisCurrency = dc.Key.ToUpper();
  9550. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9551. if (thisRate == 0.00M) continue;
  9552. foreach (var dcSub in dc)
  9553. {
  9554. opDayCosts.Add(new Grp_DayAndCostDraft()
  9555. {
  9556. Id = dcSub.Id,
  9557. ParentId = dcSub.ParentId,
  9558. Cost = dcSub.Cost,
  9559. SubTotal = dcSub.Cost * thisRate,
  9560. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9561. });
  9562. }
  9563. }
  9564. if (opDayCosts.Count > 0)
  9565. {
  9566. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9567. }
  9568. }
  9569. if (dayOtherCosts.Count > 0)
  9570. {
  9571. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9572. foreach (var dc in new_dayOtherCosts)
  9573. {
  9574. var thisCurrency = dc.Key.ToUpper();
  9575. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9576. if (thisRate == 0.00M) continue;
  9577. foreach (var dcSub in dc)
  9578. {
  9579. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  9580. {
  9581. Id = dcSub.Id,
  9582. ParentId = dcSub.ParentId,
  9583. Cost = dcSub.Cost,
  9584. SubTotal = dcSub.Cost * thisRate,
  9585. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9586. });
  9587. }
  9588. }
  9589. if (opDayOtherCosts.Count > 0)
  9590. {
  9591. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9592. }
  9593. }
  9594. #endregion
  9595. ////消息通知
  9596. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9597. ////汇率信息记录
  9598. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9599. return Ok(JsonView(new { parentId = id }));
  9600. }
  9601. /// <summary>
  9602. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  9603. /// </summary>
  9604. /// <returns></returns>
  9605. [HttpPost]
  9606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9607. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  9608. {
  9609. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9610. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9611. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9612. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9613. int id = dto.DraftId;
  9614. if (id <= 0) //add
  9615. {
  9616. checkboxInfo.CreateUserId = dto.CurrUserId;
  9617. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  9618. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9619. if (add < 1) return Ok(JsonView(false));
  9620. }
  9621. else //update
  9622. {
  9623. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9624. .UpdateColumns(x => new
  9625. {
  9626. x.ChoiceOne,
  9627. x.ChoiceTwo,
  9628. x.SumJJC,
  9629. x.SumGWC,
  9630. x.SumTDC,
  9631. x.ChoiceThree,
  9632. x.ChoiceFour,
  9633. x.ChoiceFive,
  9634. x.ChoiceSix,
  9635. x.OtherExpenses_Checked
  9636. })
  9637. .Where(x => x.Id == id)
  9638. .ExecuteCommandAsync();
  9639. if (upd < 1) return Ok(JsonView(false));
  9640. }
  9641. return Ok(JsonView(new { parentId = id }));
  9642. }
  9643. /// <summary>
  9644. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框更改
  9645. /// </summary>
  9646. /// <returns></returns>
  9647. [HttpPost]
  9648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9649. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  9650. {
  9651. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  9652. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9653. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9654. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9655. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9656. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9657. var checkboxInfo = new Grp_EnterExitCostDraft()
  9658. {
  9659. Id = draftId,
  9660. CreateUserId = currUserId
  9661. };
  9662. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9663. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9664. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9665. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9666. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9667. if (draftId <= 0) //add
  9668. {
  9669. checkboxInfo.CreateUserId = dto.CurrUserId;
  9670. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9671. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9672. if (add < 1) return Ok(JsonView(false));
  9673. }
  9674. else //update
  9675. {
  9676. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  9677. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9678. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9679. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9680. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9681. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9682. .Where(x => x.Id == draftId)
  9683. .ExecuteCommandAsync();
  9684. if (upd < 1) return Ok(JsonView(false));
  9685. }
  9686. return Ok(JsonView(new { parentId = draftId }));
  9687. }
  9688. /// <summary>
  9689. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  9690. /// </summary>
  9691. /// <returns></returns>
  9692. [HttpPost]
  9693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9694. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  9695. {
  9696. int id = dto.DraftId,currUserId = dto.CurrUserId;
  9697. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9698. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9699. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9700. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9701. info.FirstItemRemark = dto.FirstItemRemark;
  9702. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9703. if (id <= 0) //add
  9704. {
  9705. info.CreateUserId = dto.CurrUserId;
  9706. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9707. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9708. if (add < 1) return Ok(JsonView(false));
  9709. id = add;
  9710. }
  9711. else //update
  9712. {
  9713. var upd = await _sqlSugar.Updateable(info)
  9714. .UpdateColumns(x => new
  9715. {
  9716. x.ChoiceOne,
  9717. x.InsidePay,
  9718. x.VisaRemark,
  9719. x.Visa,
  9720. x.Service,
  9721. x.Safe,
  9722. x.Ticket,
  9723. x.HeSuan,
  9724. x.YiMiao,
  9725. x.FirstItemRemark
  9726. })
  9727. .Where(x => x.Id == id)
  9728. .ExecuteCommandAsync();
  9729. if (upd < 1) return Ok(JsonView(false));
  9730. }
  9731. ////消息通知
  9732. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9733. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9734. }
  9735. /// <summary>
  9736. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  9737. /// </summary>
  9738. /// <returns></returns>
  9739. [HttpPost]
  9740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9741. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  9742. {
  9743. int id = dto.DraftId;
  9744. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9745. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9746. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9747. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9748. info.OutsideJJPay = dto.OutsideJJPay;
  9749. info.OutsideGWPay = dto.OutsideGWPay;
  9750. info.OutsideTDPay = dto.OutsideTDPay;
  9751. info.AirJJ = dto.AirJJ;
  9752. info.AirGW = dto.AirGW;
  9753. info.AirTD = dto.AirTD;
  9754. info.CityTranffic = dto.CityTranffic;
  9755. info.TwoItemRemark = dto.TwoItemRemark;
  9756. info.SumJJC = dto.ChoiceTwoJJ;
  9757. info.SumGWC = dto.ChoiceTwoGW;
  9758. info.SumTDC = dto.ChoiceTwoTD;
  9759. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9760. if (id <= 0) //add
  9761. {
  9762. info.CreateUserId = dto.CurrUserId;
  9763. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9764. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9765. if (addId <= 0) return Ok(JsonView(false));
  9766. id = addId;
  9767. }
  9768. else //update
  9769. {
  9770. var upd = await _sqlSugar.Updateable(info)
  9771. .UpdateColumns(x => new
  9772. {
  9773. x.SumJJC,
  9774. x.OutsideJJPay,
  9775. x.SumGWC,
  9776. x.OutsideGWPay,
  9777. x.SumTDC,
  9778. x.OutsideTDPay,
  9779. x.AirJJ,
  9780. x.AirGW,
  9781. x.AirTD,
  9782. x.CityTranffic,
  9783. x.TwoItemRemark
  9784. })
  9785. .Where(x => x.Id == id)
  9786. .ExecuteCommandAsync();
  9787. if (upd < 1) return Ok(JsonView(false));
  9788. }
  9789. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9790. gwcItemTotal = info.AirGW + info.CityTranffic;
  9791. tdcItemTotal = info.AirTD + info.CityTranffic;
  9792. ////消息通知
  9793. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9794. return Ok(JsonView(new
  9795. {
  9796. parentId = id,
  9797. choiceTwoJJ = dto.ChoiceTwoJJ,
  9798. jjcItemTotal = jjcItemTotal,
  9799. choiceTwoGW = dto.ChoiceTwoGW,
  9800. gwcItemTotal = gwcItemTotal,
  9801. choiceTwoTD = dto.ChoiceTwoTD,
  9802. tdcItemTotal = tdcItemTotal
  9803. }));
  9804. }
  9805. /// <summary>
  9806. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9807. /// </summary>
  9808. /// <returns></returns>
  9809. [HttpPost]
  9810. [ApiExplorerSettings(IgnoreApi = true)]
  9811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9812. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  9813. {
  9814. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9815. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9816. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9817. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9818. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9819. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9820. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  9821. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  9822. {
  9823. Id = x.Id,
  9824. ParentId = dto.DraftId,
  9825. Type = dto.FeeType,
  9826. Days = x.Days,
  9827. NationalTravelFeeId = x.NationalTravelFeeId,
  9828. Cost = x.Cost,
  9829. Currency = x.Currency,
  9830. SubTotal = x.SubTotal,
  9831. CreateUserId = dto.CurrUserId
  9832. })
  9833. .ToList();
  9834. var adds = infos.Where(x => x.Id <= 0).ToList();
  9835. var upds = infos.Where(x => x.Id > 0).ToList();
  9836. if (adds.Count > 0)
  9837. {
  9838. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9839. if (add < 1) return Ok(JsonView(false));
  9840. }
  9841. if (upds.Count > 0)
  9842. {
  9843. var upd = await _sqlSugar.Updateable(adds)
  9844. .UpdateColumns(x => new
  9845. {
  9846. x.Days,
  9847. x.NationalTravelFeeId,
  9848. x.Cost,
  9849. x.Currency,
  9850. x.SubTotal
  9851. })
  9852. .WhereColumns(x => new { x.Id })
  9853. .ExecuteCommandAsync();
  9854. if (upd < 1) return Ok(JsonView(false));
  9855. }
  9856. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9857. ////消息通知
  9858. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  9859. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9860. return Ok(JsonView(new { itemTotal = itemTotal }));
  9861. }
  9862. /// <summary>
  9863. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9864. /// </summary>
  9865. /// <returns></returns>
  9866. [HttpPost]
  9867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9868. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  9869. {
  9870. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9871. int subId = dto.SubId, feeType = dto.FeeType;
  9872. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9873. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9874. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9875. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9876. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  9877. subInfo.Id = subId;
  9878. subInfo.ParentId = dto.DraftId;
  9879. if (feeType == 3) subInfo.Type = 1;
  9880. else if (feeType == 4) subInfo.Type = 2;
  9881. else if (feeType == 5) subInfo.Type = 3;
  9882. else if (feeType == 6) subInfo.Type = 4;
  9883. subInfo.CreateUserId = dto.CurrUserId;
  9884. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  9885. if (parentId < 1) return Ok(JsonView(false));
  9886. //子表op
  9887. if (subId < 1)
  9888. {
  9889. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9890. if (subAdd < 1) return Ok(JsonView(false));
  9891. }
  9892. else
  9893. {
  9894. var subUpd = await _sqlSugar.Updateable(subInfo)
  9895. .UpdateColumns(x => new
  9896. {
  9897. x.Days,
  9898. x.NationalTravelFeeId,
  9899. x.Cost,
  9900. x.Currency,
  9901. x.SubTotal
  9902. })
  9903. .WhereColumns(x => new { x.Id })
  9904. .ExecuteCommandAsync();
  9905. if (subUpd < 1) return Ok(JsonView(false));
  9906. }
  9907. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  9908. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9909. }
  9910. /// <summary>
  9911. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  9912. /// </summary>
  9913. /// <returns></returns>
  9914. [HttpPost]
  9915. [ApiExplorerSettings(IgnoreApi = true)]
  9916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9917. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  9918. {
  9919. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9920. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9921. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9922. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  9923. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  9924. {
  9925. Id = x.Id,
  9926. ParentId = dto.DraftId,
  9927. SetDataId = x.SetDataId,
  9928. Index = x.Index,
  9929. Cost = x.Cost,
  9930. Currency = x.Currency,
  9931. SubTotal = x.SubTotal,
  9932. CreateUserId = dto.CurrUserId,
  9933. Remark = x.Remark
  9934. }).ToList();
  9935. var adds = infos.Where(x => x.Id <= 0).ToList();
  9936. var upds = infos.Where(x => x.Id > 0).ToList();
  9937. if (adds.Count > 0)
  9938. {
  9939. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9940. if (add < 1) return Ok(JsonView(false));
  9941. }
  9942. if (upds.Count > 0)
  9943. {
  9944. var upd = await _sqlSugar.Updateable(adds)
  9945. .UpdateColumns(x => new
  9946. {
  9947. x.Index,
  9948. x.SetDataId,
  9949. x.Cost,
  9950. x.Currency,
  9951. x.SubTotal,
  9952. x.Remark
  9953. })
  9954. .WhereColumns(x => new { x.Id })
  9955. .ExecuteCommandAsync();
  9956. if (upd < 1) return Ok(JsonView(false));
  9957. }
  9958. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  9959. //消息通知
  9960. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  9961. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9962. return Ok(JsonView(new { itemTotal = itemTotal }));
  9963. }
  9964. /// <summary>
  9965. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  9966. /// </summary>
  9967. /// <returns></returns>
  9968. [HttpPost]
  9969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9970. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  9971. {
  9972. int subId = dto.SubId,id = dto.DarftId;
  9973. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9974. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  9975. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9976. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  9977. subInfo.Id = subId;
  9978. subInfo.ParentId = dto.DarftId;
  9979. subInfo.CreateUserId = dto.CurrUserId;
  9980. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  9981. if (parentId < 1) return Ok(JsonView(false));
  9982. #region 子表op
  9983. if (subId < 1)//add
  9984. {
  9985. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9986. if (subAdd < 1) return Ok(JsonView(false));
  9987. }
  9988. else //upd
  9989. {
  9990. var subUpd = await _sqlSugar.Updateable(subInfo)
  9991. .UpdateColumns(x => new
  9992. {
  9993. x.Index,
  9994. x.SetDataId,
  9995. x.Cost,
  9996. x.Currency,
  9997. x.SubTotal,
  9998. x.Remark
  9999. })
  10000. .WhereColumns(x => new { x.Id })
  10001. .ExecuteCommandAsync();
  10002. if (subUpd < 1) return Ok(JsonView(false));
  10003. }
  10004. #endregion
  10005. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10006. ////消息通知
  10007. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10008. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10009. }
  10010. /// <summary>
  10011. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10012. /// </summary>
  10013. /// <returns></returns>
  10014. [HttpPost]
  10015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10016. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10017. {
  10018. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10019. if (data.Code != 0)
  10020. {
  10021. return Ok(JsonView(false, data.Msg));
  10022. }
  10023. return Ok(JsonView(true, "操作成功!", data.Data));
  10024. }
  10025. /// <summary>
  10026. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10027. /// </summary>
  10028. /// <param name="dto"></param>
  10029. /// <returns></returns>
  10030. [HttpPost]
  10031. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10032. {
  10033. var data = new Grp_DayOtherPriceDraft()
  10034. {
  10035. Id = dto.Id,
  10036. IsDel = 1,
  10037. DeleteUserId = dto.DeleteUserId,
  10038. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10039. };
  10040. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10041. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10042. return Ok(JsonView(false, "删除失败!"));
  10043. }
  10044. #endregion
  10045. #endregion
  10046. #region 签证费用录入
  10047. /// <summary>
  10048. /// 根据diid查询签证费用列表
  10049. /// </summary>
  10050. /// <param name="dto"></param>
  10051. /// <returns></returns>
  10052. [HttpPost]
  10053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10054. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  10055. {
  10056. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  10057. if (groupData.Code != 0)
  10058. {
  10059. return Ok(JsonView(false, groupData.Msg));
  10060. }
  10061. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10062. }
  10063. /// <summary>
  10064. /// 根据签证费用Id查询单条数据及c表数据
  10065. /// </summary>
  10066. /// <param name="dto"></param>
  10067. /// <returns></returns>
  10068. [HttpPost]
  10069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10070. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  10071. {
  10072. Result groupData = await _visaPriceRep.PostVisaById(dto);
  10073. if (groupData.Code != 0)
  10074. {
  10075. return Ok(JsonView(false, groupData.Msg));
  10076. }
  10077. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10078. }
  10079. /// <summary>
  10080. /// 签证费用删除
  10081. /// </summary>
  10082. /// <param name="dto"></param>
  10083. /// <returns></returns>
  10084. [HttpPost]
  10085. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10086. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  10087. {
  10088. _sqlSugar.BeginTran();
  10089. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  10090. if (!res)
  10091. {
  10092. _sqlSugar.RollbackTran();
  10093. return Ok(JsonView(false, "删除失败"));
  10094. }
  10095. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  10096. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  10097. .SetColumns(a => new Grp_CreditCardPayment()
  10098. {
  10099. IsDel = 1,
  10100. DeleteUserId = dto.DeleteUserId,
  10101. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10102. })
  10103. .ExecuteCommand();
  10104. if (resSub < 1)
  10105. {
  10106. _sqlSugar.RollbackTran();
  10107. return Ok(JsonView(false, "删除失败"));
  10108. }
  10109. _sqlSugar.CommitTran();
  10110. return Ok(JsonView(true, "删除成功!"));
  10111. }
  10112. /// <summary>
  10113. /// 签证费用录入下拉框初始化
  10114. /// </summary>
  10115. /// <returns></returns>
  10116. [HttpPost]
  10117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10118. public async Task<IActionResult> VisaPriceAddSelect()
  10119. {
  10120. //支付方式
  10121. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  10122. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  10123. //币种
  10124. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  10125. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  10126. //乘客类型
  10127. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  10128. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  10129. //卡类型
  10130. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  10131. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  10132. //代办费类型
  10133. var agencyFeeTypeData = new List<dynamic>() {
  10134. new { id = 0 , Text = "未选择" },
  10135. new { id = 1 , Text = "小公务" },
  10136. new { id = 2 , Text = "大公务" },
  10137. };
  10138. //签证费用标准国家Data
  10139. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  10140. var data = new
  10141. {
  10142. Payment = _Payment,
  10143. CurrencyList = _CurrencyList,
  10144. PassengerType = _PassengerType,
  10145. BankCard = _BankCard,
  10146. AgencyFeeType = agencyFeeTypeData,
  10147. CountryFeeData = visaCountryFeeData
  10148. };
  10149. return Ok(JsonView(true, "查询成功!", data));
  10150. }
  10151. /// <summary>
  10152. /// 签证费用录入操作(Status:1.新增,2.修改)
  10153. /// </summary>
  10154. /// <param name="dto"></param>
  10155. /// <returns></returns>
  10156. [HttpPost]
  10157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10158. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  10159. {
  10160. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  10161. if (groupData.Code != 0)
  10162. {
  10163. return Ok(JsonView(false, groupData.Msg));
  10164. }
  10165. #region 应用推送
  10166. try
  10167. {
  10168. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10169. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10170. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10171. //2024-10-21 新增LZ UID
  10172. var userIds = new List<int>() { 21 };
  10173. string title = $"系统通知";
  10174. string content = "";
  10175. var diId = dto.DiId;
  10176. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10177. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10178. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10179. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10180. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10181. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10182. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10183. }
  10184. catch (Exception ex)
  10185. {
  10186. }
  10187. #endregion
  10188. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10189. }
  10190. #endregion
  10191. #region 签证提成录入
  10192. /// <summary>
  10193. /// 签证提成录入
  10194. /// 基础数据
  10195. /// </summary>
  10196. /// <param name="_dto"></param>
  10197. /// <returns></returns>
  10198. [HttpGet]
  10199. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10200. public async Task<IActionResult> VisaCommissionInit()
  10201. {
  10202. return Ok(await _visaCommissionRep.Init());
  10203. }
  10204. /// <summary>
  10205. /// 签证提成录入
  10206. /// Item
  10207. /// </summary>
  10208. /// <param name="_dto"></param>
  10209. /// <returns></returns>
  10210. [HttpPost]
  10211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10212. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  10213. {
  10214. var validator = new VisaCommissionItemDtoValidator();
  10215. var validatorRes = await validator.ValidateAsync(_dto);
  10216. if (!validatorRes.IsValid)
  10217. {
  10218. StringBuilder sb = new StringBuilder();
  10219. foreach (var item in validatorRes.Errors)
  10220. {
  10221. sb.AppendLine(item.ErrorMessage);
  10222. }
  10223. return Ok(JsonView(false, sb.ToString()));
  10224. }
  10225. return Ok(await _visaCommissionRep.Item(_dto));
  10226. }
  10227. /// <summary>
  10228. /// 签证提成录入
  10229. /// Save
  10230. /// </summary>
  10231. /// <param name="_dto"></param>
  10232. /// <returns></returns>
  10233. [HttpPost]
  10234. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10235. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  10236. {
  10237. //参数验证
  10238. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  10239. foreach (var item in _dto.Items)
  10240. {
  10241. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  10242. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  10243. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  10244. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  10245. }
  10246. return Ok(await _visaCommissionRep.Save(_dto));
  10247. }
  10248. /// <summary>
  10249. /// 签证提成录入
  10250. /// Create
  10251. /// </summary>
  10252. /// <param name="_dto"></param>
  10253. /// <returns></returns>
  10254. [HttpPost]
  10255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10256. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  10257. {
  10258. var validator = new VisaCommissionCreateDtoValidator();
  10259. var validatorRes = await validator.ValidateAsync(_dto);
  10260. if (!validatorRes.IsValid)
  10261. {
  10262. StringBuilder sb = new StringBuilder();
  10263. foreach (var item in validatorRes.Errors)
  10264. {
  10265. sb.AppendLine(item.ErrorMessage);
  10266. }
  10267. return Ok(JsonView(false, sb.ToString()));
  10268. }
  10269. return Ok(await _visaCommissionRep.Create(_dto));
  10270. }
  10271. /// <summary>
  10272. /// 签证提成录入
  10273. /// Put(编辑)
  10274. /// </summary>
  10275. /// <param name="id"></param>
  10276. /// <param name="_dto"></param>
  10277. /// <returns></returns>
  10278. [HttpPut]
  10279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10280. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  10281. {
  10282. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10283. var validator = new VisaCommissionCreateDtoValidator();
  10284. var validatorRes = await validator.ValidateAsync(_dto);
  10285. if (!validatorRes.IsValid)
  10286. {
  10287. StringBuilder sb = new StringBuilder();
  10288. foreach (var item in validatorRes.Errors)
  10289. {
  10290. sb.AppendLine(item.ErrorMessage);
  10291. }
  10292. return Ok(JsonView(false, sb.ToString()));
  10293. }
  10294. return Ok(await _visaCommissionRep.Edit(id, _dto));
  10295. }
  10296. /// <summary>
  10297. /// 签证提成录入
  10298. /// Del
  10299. /// </summary>
  10300. /// <param name="id"></param>
  10301. /// <param name="currUserId"></param>
  10302. /// <returns></returns>
  10303. [HttpPost]
  10304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10305. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  10306. {
  10307. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10308. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  10309. return Ok(await _visaCommissionRep.Del(id, currUserId));
  10310. }
  10311. #endregion
  10312. #region op费用录入
  10313. /// <summary>
  10314. /// 根据diid查询op费用列表
  10315. /// </summary>
  10316. /// <param name="dto"></param>
  10317. /// <returns></returns>
  10318. [HttpPost]
  10319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10320. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  10321. {
  10322. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  10323. if (groupData.Code != 0)
  10324. {
  10325. return Ok(JsonView(false, groupData.Msg));
  10326. }
  10327. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10328. }
  10329. /// <summary>
  10330. /// 根据op费用Id查询单条数据及c表数据
  10331. /// </summary>
  10332. /// <param name="dto"></param>
  10333. /// <returns></returns>
  10334. [HttpPost]
  10335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10336. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  10337. {
  10338. try
  10339. {
  10340. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  10341. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  10342. var data = new
  10343. {
  10344. CarTouristGuideGround = _groupData,
  10345. CreditCardPayment = _creditCardPayment
  10346. };
  10347. return Ok(JsonView(true, "查询成功!", data));
  10348. }
  10349. catch (Exception ex)
  10350. {
  10351. return Ok(JsonView(false, "程序错误!"));
  10352. }
  10353. }
  10354. /// <summary>
  10355. /// op费用删除
  10356. /// </summary>
  10357. /// <param name="dto"></param>
  10358. /// <returns></returns>
  10359. [HttpPost]
  10360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10361. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  10362. {
  10363. try
  10364. {
  10365. _sqlSugar.BeginTran();
  10366. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  10367. if (!res)
  10368. {
  10369. return Ok(JsonView(false, "删除失败"));
  10370. }
  10371. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  10372. {
  10373. IsDel = 1,
  10374. DeleteUserId = dto.DeleteUserId,
  10375. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10376. }).ExecuteCommandAsync();
  10377. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  10378. {
  10379. IsDel = 1,
  10380. DeleteUserId = dto.DeleteUserId,
  10381. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10382. }).ExecuteCommandAsync();
  10383. #region 删除超支相关数据
  10384. //删除导入的超支数据
  10385. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  10386. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  10387. {
  10388. IsDel = 1,
  10389. DeleteUserId = dto.DeleteUserId,
  10390. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10391. }).ExecuteCommand();
  10392. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  10393. {
  10394. IsDel = 1,
  10395. DeleteUserId = dto.DeleteUserId,
  10396. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10397. }).ExecuteCommand();
  10398. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  10399. {
  10400. IsDel = 1,
  10401. DeleteUserId = dto.DeleteUserId,
  10402. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10403. }).ExecuteCommand();
  10404. #endregion
  10405. _sqlSugar.CommitTran();
  10406. return Ok(JsonView(true, "删除成功!"));
  10407. }
  10408. catch (Exception ex)
  10409. {
  10410. _sqlSugar.RollbackTran();
  10411. return Ok(JsonView(false, "程序错误!" + ex.Message));
  10412. }
  10413. }
  10414. /// <summary>
  10415. /// op费用录入操作(Status:1.新增,2.修改)
  10416. /// </summary>
  10417. /// <param name="dto"></param>
  10418. /// <returns></returns>
  10419. [HttpPost]
  10420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10421. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  10422. {
  10423. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  10424. if (groupData.Code != 0)
  10425. {
  10426. return Ok(JsonView(false, groupData.Msg));
  10427. }
  10428. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10429. }
  10430. /// <summary>
  10431. /// 填写费用详细页面初始化绑定
  10432. /// </summary>
  10433. /// <param name="dto"></param>
  10434. /// <returns></returns>
  10435. [HttpPost]
  10436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10437. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  10438. {
  10439. try
  10440. {
  10441. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  10442. if (groupData.Code != 0)
  10443. {
  10444. return Ok(JsonView(false, groupData.Msg));
  10445. }
  10446. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10447. }
  10448. catch (Exception ex)
  10449. {
  10450. return Ok(JsonView(false, ex.Message));
  10451. }
  10452. }
  10453. /// <summary>
  10454. /// 根据op费用Id查询详细数据
  10455. /// </summary>
  10456. /// <param name="dto"></param>
  10457. /// <returns></returns>
  10458. [HttpPost]
  10459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10460. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  10461. {
  10462. try
  10463. {
  10464. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  10465. if (groupData.Code != 0)
  10466. {
  10467. return Ok(JsonView(false, groupData.Msg));
  10468. }
  10469. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10470. }
  10471. catch (Exception ex)
  10472. {
  10473. return Ok(JsonView(false, ex.Message));
  10474. }
  10475. }
  10476. /// <summary>
  10477. /// OP费用录入填写详情
  10478. /// </summary>
  10479. /// <param name="dto"></param>
  10480. /// <returns></returns>
  10481. [HttpPost]
  10482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10483. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  10484. {
  10485. try
  10486. {
  10487. #region 参数校验
  10488. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  10489. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  10490. if (di == null) return Ok(JsonView(false, "团组错误!"));
  10491. #endregion
  10492. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  10493. if (groupData.Code != 0)
  10494. {
  10495. return Ok(JsonView(false, groupData.Msg));
  10496. }
  10497. //自动审核
  10498. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  10499. #region 应用推送
  10500. try
  10501. {
  10502. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10503. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10504. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10505. //2024-10-21 新增LZ UID
  10506. var userIds = new List<int>() { 21 };
  10507. string title = $"系统通知";
  10508. var diId = dto.DiId;
  10509. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10510. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10511. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  10512. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10513. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10514. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10515. }
  10516. catch (Exception ex)
  10517. {
  10518. }
  10519. #endregion
  10520. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10521. }
  10522. catch (Exception ex)
  10523. {
  10524. return Ok(JsonView(false, ex.Message));
  10525. }
  10526. }
  10527. /// <summary>
  10528. /// 获取三公详细所有城市
  10529. /// </summary>
  10530. /// <returns></returns>
  10531. [HttpGet]
  10532. public IActionResult OpCarCityResult()
  10533. {
  10534. var jw = JsonView(false);
  10535. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  10536. {
  10537. x.Id,
  10538. x.Country,
  10539. x.City,
  10540. }).ToList();
  10541. if (data.Count > 0)
  10542. {
  10543. jw = JsonView(true, "获取成功!", data);
  10544. }
  10545. else
  10546. {
  10547. jw.Msg = "城市数据为空!";
  10548. jw.Data = new string[0];
  10549. }
  10550. return Ok(jw);
  10551. }
  10552. /// <summary>
  10553. /// 导出地接费用明细
  10554. /// </summary>
  10555. /// <param name="dto"></param>
  10556. /// <returns></returns>
  10557. [HttpPost]
  10558. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  10559. {
  10560. var jw = JsonView(false);
  10561. if (dto.Diid < 1)
  10562. {
  10563. jw.Msg = "请输入正确的diid!";
  10564. return Ok(jw);
  10565. }
  10566. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  10567. if (group == null)
  10568. {
  10569. jw.Msg = "未找到团组信息!";
  10570. return Ok(jw);
  10571. }
  10572. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  10573. if (localGuideArr.Count == 0)
  10574. {
  10575. jw.Msg = "该团组暂无地接信息!";
  10576. return Ok(jw);
  10577. }
  10578. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  10579. var overspendSoure = new Dictionary<int, int>
  10580. {
  10581. { 91, 982 }, //车
  10582. { 92 , 1059} ,//导游
  10583. { 994 , 1073}, //翻译
  10584. { 988 , 1074 }, //早餐
  10585. { 93 , 1075 }, //午餐
  10586. { 989 , 1076 }, //晚餐
  10587. };
  10588. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  10589. foreach (var groupArr in localGroup)
  10590. {
  10591. var keyValue = groupArr.Key;
  10592. if (int.TryParse(keyValue, out int cityid))
  10593. {
  10594. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  10595. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  10596. }
  10597. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  10598. foreach (var item in groupArr)
  10599. {
  10600. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  10601. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  10602. new Grp_CarTouristGuideGroundReservationsContentExtend
  10603. {
  10604. Count = a.Count,
  10605. CreateTime = a.CreateTime,
  10606. CreateUserId = a.CreateUserId,
  10607. CTGGRId = a.CTGGRId,
  10608. Currency = a.Currency,
  10609. DatePrice = a.DatePrice,
  10610. DeleteTime = a.DeleteTime,
  10611. DeleteUserId = a.DeleteUserId,
  10612. DiId = a.DiId,
  10613. Id = a.Id,
  10614. IsDel = a.IsDel,
  10615. Price = a.Price,
  10616. PriceContent = a.PriceContent,
  10617. Remark = a.Remark,
  10618. SId = a.SId,
  10619. SidName = b.Name,
  10620. Units = a.Units,
  10621. }
  10622. ).ToList();
  10623. if (content.Count > 0)
  10624. {
  10625. contentArr.Add(content);
  10626. }
  10627. }
  10628. //open excel
  10629. //set excel
  10630. //save excel
  10631. try
  10632. {
  10633. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  10634. IWorkbook workbook;
  10635. if (Path.GetExtension(filePath).ToLower() == ".xls")
  10636. {
  10637. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10638. }
  10639. else
  10640. {
  10641. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10642. }
  10643. ISheet sheet = workbook.GetSheetAt(0);
  10644. var rowStartIndex = 2;
  10645. var clounmCount = 10;
  10646. var initStyleRow = sheet.GetRow(2);
  10647. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  10648. //var overspendArrDetail =
  10649. var existsId = new List<CarCompare>();
  10650. var lastElem = arr.Last();
  10651. var thisSid = -1;
  10652. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  10653. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  10654. {
  10655. Name = "未知币种!",
  10656. Remark = "未知币种!",
  10657. };
  10658. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  10659. Action cloneRowFn = () =>
  10660. {
  10661. rowStartIndex++;
  10662. var cloneRow = sheet.CreateRow(rowStartIndex);
  10663. // 复制样式
  10664. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  10665. {
  10666. ICell sourceCell = initStyleRow.GetCell(i);
  10667. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  10668. // 确保单元格存在样式
  10669. if (sourceCell.CellStyle != null)
  10670. {
  10671. targetCell.CellStyle = sourceCell.CellStyle;
  10672. }
  10673. }
  10674. };
  10675. var mergeRow = () =>
  10676. {
  10677. for (int i = 2; i < sheet.LastRowNum; i++)
  10678. {
  10679. var row = sheet.GetRow(i);
  10680. var cellFirst = row.GetCell(0);
  10681. var thisIndex = i + 1;
  10682. while (thisIndex < sheet.LastRowNum)
  10683. {
  10684. var nextRow = sheet.GetRow(thisIndex);
  10685. var nextCellFirst = nextRow.GetCell(0);
  10686. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  10687. {
  10688. thisIndex++;
  10689. }
  10690. else
  10691. {
  10692. break;
  10693. }
  10694. }
  10695. thisIndex--;
  10696. if (thisIndex != i)
  10697. {
  10698. //合并row
  10699. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10700. i, // 起始行索引(0-based)
  10701. thisIndex, // 结束行索引(0-based)
  10702. 0, // 起始列索引(0-based)
  10703. 0 // 结束列索引(0-based)
  10704. );
  10705. sheet.AddMergedRegion(cellRangeAddress);
  10706. i = thisIndex;
  10707. }
  10708. }
  10709. };
  10710. var chaoshiNumber = 0;
  10711. var totalNumber = 0.00M;
  10712. string lastStr = "";
  10713. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  10714. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  10715. {
  10716. b.IsAuditGM,
  10717. x.Id,
  10718. x.Area,
  10719. b.PayPercentage,
  10720. b.PayMoney,
  10721. }).ToList();
  10722. string yesPayment = "", noPayment = "";
  10723. foreach (var item in queryCarArrByCityAndDiid)
  10724. {
  10725. if (item.IsAuditGM == 1)
  10726. {
  10727. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10728. }
  10729. else
  10730. {
  10731. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10732. }
  10733. }
  10734. lastStr = yesPayment + noPayment;
  10735. foreach (var item in arr)
  10736. {
  10737. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  10738. {
  10739. if (thisSid != item.SId)
  10740. {
  10741. if (thisSid == -1)
  10742. {
  10743. thisSid = item.SId;
  10744. }
  10745. else
  10746. {
  10747. //合并小计行
  10748. //创建合并区域的实例
  10749. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10750. rowStartIndex, // 起始行索引(0-based)
  10751. rowStartIndex, // 结束行索引(0-based)
  10752. 0, // 起始列索引(0-based)
  10753. 3 // 结束列索引(0-based)
  10754. );
  10755. sheet.AddMergedRegion(cellRangeAddress);
  10756. var CellStyle = workbook.CreateCellStyle();
  10757. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10758. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10759. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10760. for (int i = 0; i <= clounmCount; i++)
  10761. {
  10762. if (i > 6)
  10763. {
  10764. var CellStyle1 = workbook.CreateCellStyle();
  10765. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10766. IFont Font = workbook.CreateFont(); // 创建字体
  10767. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  10768. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10769. CellStyle1.SetFont(Font);
  10770. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  10771. }
  10772. else
  10773. {
  10774. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  10775. }
  10776. }
  10777. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  10778. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  10779. //超时合计
  10780. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  10781. //超时数
  10782. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  10783. //超时合计费用
  10784. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  10785. thisSid = item.SId;
  10786. cloneRowFn();
  10787. chaoshiNumber = 0;
  10788. totalNumber = 0;
  10789. }
  10790. }
  10791. IRow row = sheet.GetRow(rowStartIndex);
  10792. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10793. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  10794. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  10795. if (isOpenOverspendSoure)
  10796. {
  10797. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10798. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  10799. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  10800. }
  10801. for (int i = 0; i <= clounmCount; i++)
  10802. {
  10803. var cell = row.GetCell(i);
  10804. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  10805. if (cell == null)
  10806. {
  10807. cell = row.CreateCell(i);
  10808. }
  10809. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  10810. fontRed.CloneStyleFrom(cell.CellStyle);
  10811. IFont Font = workbook.CreateFont(); // 创建字体
  10812. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  10813. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10814. fontRed.SetFont(Font);
  10815. byte[] rgb = new byte[3] { 255, 242, 204 };
  10816. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  10817. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  10818. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  10819. if (workbook is XSSFWorkbook)
  10820. {
  10821. BackgroundColor255_242_204.FillForegroundColor = 0;
  10822. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  10823. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  10824. }
  10825. else
  10826. {
  10827. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  10828. }
  10829. if (i == 1 || i > 6)
  10830. {
  10831. if (i > 6)
  10832. {
  10833. fontRed.FillForegroundColor = 0;
  10834. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  10835. fontRed.FillPattern = FillPattern.SolidForeground;
  10836. }
  10837. cell.CellStyle = fontRed;
  10838. }
  10839. if (i > 2 && i < 7)
  10840. {
  10841. cell.CellStyle = BackgroundColor255_242_204;
  10842. }
  10843. cell.SetCellValue(setCellValue); //写入单元格
  10844. }
  10845. if (overspendSoure.ContainsKey(thisSid))
  10846. {
  10847. var overspendId = overspendSoure[thisSid];
  10848. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10849. }
  10850. cloneRowFn();
  10851. existsId.Add(new CarCompare
  10852. {
  10853. DataPrice = item.DatePrice.ObjToDate(),
  10854. Sid = item.SId
  10855. });
  10856. }
  10857. if (item.Equals(lastElem))
  10858. {
  10859. //合并小计行
  10860. //创建合并区域的实例
  10861. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10862. rowStartIndex, // 起始行索引(0-based)
  10863. rowStartIndex, // 结束行索引(0-based)
  10864. 0, // 起始列索引(0-based)
  10865. 3 // 结束列索引(0-based)
  10866. );
  10867. sheet.AddMergedRegion(cellRangeAddress);
  10868. var CellStyle = workbook.CreateCellStyle();
  10869. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10870. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10871. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10872. for (int i = 0; i <= clounmCount; i++)
  10873. {
  10874. if (i > 6)
  10875. {
  10876. var CellStyle1 = workbook.CreateCellStyle();
  10877. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10878. IFont Font = workbook.CreateFont(); // 创建字体
  10879. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  10880. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10881. CellStyle1.SetFont(Font);
  10882. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  10883. }
  10884. else
  10885. {
  10886. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  10887. }
  10888. }
  10889. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  10890. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  10891. //超时合计
  10892. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  10893. //超时数
  10894. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  10895. //超时合计费用
  10896. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  10897. cloneRowFn();
  10898. // 创建合并区域的实例
  10899. cellRangeAddress = new CellRangeAddress(
  10900. rowStartIndex, // 起始行索引(0-based)
  10901. rowStartIndex, // 结束行索引(0-based)
  10902. 0, // 起始列索引(0-based)
  10903. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  10904. );
  10905. // 添加合并区域
  10906. sheet.AddMergedRegion(cellRangeAddress);
  10907. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  10908. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  10909. }
  10910. }
  10911. mergeRow();
  10912. // 保存修改后的Excel文件到新文件
  10913. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  10914. // new FileStream(newFilePath, FileMode.CreateNew)
  10915. using (var stream = new MemoryStream())
  10916. {
  10917. workbook.Write(stream, true);
  10918. stream.Flush();
  10919. stream.Seek(0, SeekOrigin.Begin);
  10920. MemoryStream memoryStream = new MemoryStream();
  10921. stream.CopyTo(memoryStream);
  10922. memoryStream.Seek(0, SeekOrigin.Begin);
  10923. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  10924. }
  10925. workbook.Close();
  10926. workbook.Dispose();
  10927. }
  10928. catch (Exception ex)
  10929. {
  10930. jw.Msg = "出现异常!" + ex.Message;
  10931. return Ok(jw);
  10932. }
  10933. }
  10934. if (Zips.Count > 0)
  10935. {
  10936. IOOperatorHelper io = new IOOperatorHelper();
  10937. var byts = io.ConvertZipStream(Zips);
  10938. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  10939. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  10940. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  10941. }
  10942. else
  10943. {
  10944. jw.Msg = "暂无生成文件!";
  10945. }
  10946. return Ok(jw);
  10947. }
  10948. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  10949. {
  10950. string outStr = string.Empty;
  10951. switch (i)
  10952. {
  10953. case 0:
  10954. outStr = arr[0].SidName;
  10955. break;
  10956. case 1:
  10957. outStr = arr[0].DataPriceStr;
  10958. break;
  10959. case 2:
  10960. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  10961. break;
  10962. case 4:
  10963. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  10964. break;
  10965. case 7:
  10966. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  10967. {
  10968. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  10969. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  10970. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  10971. }
  10972. break;
  10973. case 8:
  10974. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  10975. {
  10976. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  10977. }
  10978. break;
  10979. case 9:
  10980. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  10981. {
  10982. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  10983. }
  10984. break;
  10985. case 10:
  10986. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  10987. {
  10988. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  10989. }
  10990. break;
  10991. }
  10992. return outStr;
  10993. }
  10994. #region OP行程单
  10995. /// <summary>
  10996. /// OP行程单初始化
  10997. /// </summary>
  10998. /// <param name="dto"></param>
  10999. /// <returns></returns>
  11000. [HttpPost]
  11001. public IActionResult InitOpTravel(InitOpTravelDto dto)
  11002. {
  11003. var jw = JsonView(false);
  11004. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  11005. var group = groupList.First();
  11006. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11007. if (group == null)
  11008. {
  11009. jw.Msg = "暂无团组!";
  11010. return Ok(jw);
  11011. }
  11012. group = groupList.Find(x => x.Id == diid);
  11013. if (group == null)
  11014. {
  11015. jw.Msg = "请输入正确的团组ID!";
  11016. return Ok(jw);
  11017. }
  11018. string city = string.Empty;
  11019. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  11020. if (blackCode.Count > 0)
  11021. {
  11022. var black = blackCode.First();
  11023. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  11024. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  11025. if (blackSp.Length > 0)
  11026. {
  11027. try
  11028. {
  11029. var cityArrCode = new List<string>(20);
  11030. foreach (var item in blackSp)
  11031. {
  11032. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  11033. var IndexSelect = itemSp[2];
  11034. var cityArrCodeLength = cityArrCode.Count - 1;
  11035. var startCity = IndexSelect.Substring(0, 3);
  11036. if (cityArrCodeLength > 0)
  11037. {
  11038. var arrEndCity = cityArrCode[cityArrCodeLength];
  11039. if (arrEndCity != startCity)
  11040. {
  11041. cityArrCode.Add(startCity.ToUpper());
  11042. }
  11043. }
  11044. else
  11045. {
  11046. cityArrCode.Add(startCity.ToUpper());
  11047. }
  11048. var endCity = IndexSelect.Substring(3, 3);
  11049. cityArrCode.Add(endCity.ToUpper());
  11050. }
  11051. var cityThree = string.Empty;
  11052. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  11053. cityThree = cityThree.TrimEnd(',');
  11054. if (string.IsNullOrWhiteSpace(cityThree))
  11055. {
  11056. throw new
  11057. Exception("error");
  11058. }
  11059. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  11060. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  11061. foreach (var item in cityArrCode)
  11062. {
  11063. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  11064. if (find != null)
  11065. {
  11066. city += find.City + "/";
  11067. }
  11068. else
  11069. {
  11070. city += item + "三字码未收入/";
  11071. }
  11072. }
  11073. city = city.TrimEnd('/');
  11074. }
  11075. catch (Exception e)
  11076. {
  11077. city = "黑屏代码格式不正确!";
  11078. }
  11079. }
  11080. }
  11081. else
  11082. {
  11083. city = "未录入黑屏代码";
  11084. }
  11085. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  11086. {
  11087. Date = x.Date,
  11088. Days = x.Days,
  11089. Diffgroup = x.Diffgroup,
  11090. Diid = x.Diid,
  11091. Traffic_First = x.Traffic_First,
  11092. Traffic_Second = x.Traffic_Second,
  11093. Trip = x.Trip,
  11094. WeekDay = x.WeekDay,
  11095. Id = x.Id
  11096. }).ToList();
  11097. jw.Data = new
  11098. {
  11099. groupList = groupList.Select(x => new
  11100. {
  11101. x.Id,
  11102. x.TeamName,
  11103. x.TourCode
  11104. }).ToList(),
  11105. groupInfo = new
  11106. {
  11107. group.VisitDays,
  11108. group.TourCode,
  11109. group.VisitPNumber,
  11110. group.TeamName,
  11111. city
  11112. },
  11113. OpTravelList
  11114. };
  11115. jw.Code = 200;
  11116. jw.Msg = "操作成功!";
  11117. return Ok(jw);
  11118. }
  11119. /// <summary>
  11120. /// 删除团组行程单
  11121. /// </summary>
  11122. /// <returns></returns>
  11123. [HttpPost]
  11124. public IActionResult DelTravel(DelOpTravelDto dto)
  11125. {
  11126. var jw = JsonView(false);
  11127. if (dto.UserId <= 0 || dto.Diid <= 0)
  11128. {
  11129. jw.Msg = "请输入正确的参数!";
  11130. return Ok(jw);
  11131. }
  11132. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  11133. .SetColumns(x => new Grp_TravelList
  11134. {
  11135. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11136. DeleteUserId = dto.UserId,
  11137. IsDel = 1,
  11138. }).ExecuteCommand();
  11139. jw = JsonView(true);
  11140. return Ok(jw);
  11141. }
  11142. /// <summary>
  11143. /// 行程单保存
  11144. /// </summary>
  11145. /// <returns></returns>
  11146. [HttpPost]
  11147. public IActionResult TravelSave(TravelSaveDto dto)
  11148. {
  11149. var jw = JsonView(false);
  11150. if (dto.Arr.Count > 0)
  11151. {
  11152. try
  11153. {
  11154. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  11155. .Where(x => dto.Arr.Select(x=>x.Id).Contains(x.Id))
  11156. .ToList();
  11157. _sqlSugar.BeginTran();
  11158. foreach (var item in dto.Arr)
  11159. {
  11160. if (item.Id == 0)
  11161. {
  11162. throw new Exception("请传入正确的Id");
  11163. }
  11164. //比较上一次的差异
  11165. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  11166. if (findTravel != null)
  11167. {
  11168. item.Trip = item.Trip.Replace("[++]", string.Empty);
  11169. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  11170. item.Trip = CheckStr(findTravel.Trip,item.Trip);
  11171. }
  11172. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  11173. .SetColumns(x => new Grp_TravelList
  11174. {
  11175. Trip = item.Trip
  11176. }).ExecuteCommand();
  11177. }
  11178. _sqlSugar.CommitTran();
  11179. jw = JsonView(true);
  11180. }
  11181. catch (Exception ex)
  11182. {
  11183. _sqlSugar.RollbackTran();
  11184. jw.Msg = "程序异常!" + ex.Message;
  11185. }
  11186. }
  11187. else
  11188. {
  11189. jw.Msg = "请传入正确的参数!";
  11190. }
  11191. return Ok(jw);
  11192. }
  11193. private string CheckStr(string original, string changed)
  11194. {
  11195. // 创建diff_match_patch对象
  11196. var dmp = new diff_match_patch();
  11197. // 计算差异
  11198. List<Diff> diffs = dmp.diff_main(original, changed);
  11199. // 清理和合并差异
  11200. dmp.diff_cleanupSemantic(diffs);
  11201. // 使用StringBuilder构建最终的字符串
  11202. StringBuilder finalString = new StringBuilder();
  11203. // 输出差异结果,并构建变动后的字符串
  11204. foreach (Diff diff in diffs)
  11205. {
  11206. switch (diff.operation)
  11207. {
  11208. case Operation.EQUAL:
  11209. // 相等的部分,直接添加到最终字符串
  11210. finalString.Append(diff.text);
  11211. break;
  11212. case Operation.INSERT:
  11213. // 插入的部分,添加标记并添加到最终字符串
  11214. finalString.Append("[++]" + diff.text + "[++]");
  11215. break;
  11216. case Operation.DELETE:
  11217. // 删除的部分,不添加到最终字符串
  11218. //finalString.Append("[++]" + diff.text + "[++]");
  11219. break;
  11220. }
  11221. }
  11222. // 输出变动后的字符串
  11223. return finalString.ToString();
  11224. }
  11225. private class tagContent
  11226. {
  11227. public DateTime Date { get; set; }
  11228. public string StartTag { get; set; }
  11229. public string EndTag { get; set; }
  11230. public string Content { get; set; }
  11231. public static int tagLength { get { return 3; } }
  11232. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  11233. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  11234. public bool IsFinally { get; set; }
  11235. }
  11236. private List<string> ExtractContentBetweenTags(string input, string tag)
  11237. {
  11238. List<string> results = new List<string>();
  11239. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  11240. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  11241. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  11242. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  11243. string[] strValueArr = new string[1];
  11244. foreach (Match match in matches)
  11245. {
  11246. var strValue = match.Groups[1].Value;
  11247. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  11248. }
  11249. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  11250. return results;
  11251. }
  11252. /// <summary>
  11253. /// 导出行程单
  11254. /// </summary>
  11255. /// <param name="dto"></param>
  11256. /// <returns></returns>
  11257. [HttpPost]
  11258. public IActionResult ExportTravel(ExportTravelDto dto)
  11259. {
  11260. var jw = JsonView(false);
  11261. jw.Data = "";
  11262. int diid = 0;
  11263. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  11264. if (Find == null)
  11265. {
  11266. jw.Msg = "请选择正确的团组!";
  11267. return Ok(jw);
  11268. }
  11269. else
  11270. {
  11271. diid = Find.Id;
  11272. }
  11273. //数据源
  11274. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  11275. DataTable dtBlack = null;
  11276. try
  11277. {
  11278. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  11279. }
  11280. catch (Exception)
  11281. {
  11282. jw.Msg = "机票黑屏代码有误!";
  11283. return Ok(jw);
  11284. }
  11285. string CityStr = string.Empty;
  11286. if (dtBlack.Rows.Count == 0)
  11287. {
  11288. jw.Msg = "机票黑屏代码有误!";
  11289. return Ok(jw);
  11290. }
  11291. else
  11292. {
  11293. foreach (DataRow row in dtBlack.Rows)
  11294. {
  11295. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11296. {
  11297. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  11298. return Ok(jw);
  11299. }
  11300. }
  11301. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  11302. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  11303. }
  11304. // 指定的文字
  11305. var targetTextDic = new Dictionary<string, List<string>>();
  11306. //创建数据源Table
  11307. DataTable dtSource = new DataTable();
  11308. dtSource.Columns.Add("Days", typeof(string));
  11309. dtSource.Columns.Add("Date", typeof(string));
  11310. dtSource.Columns.Add("Week", typeof(string));
  11311. dtSource.Columns.Add("Traffic", typeof(string));
  11312. dtSource.Columns.Add("Trip", typeof(string));
  11313. //获取数据,放到datatable
  11314. foreach (var item in _travelList)
  11315. {
  11316. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  11317. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  11318. .Replace(tagContent.TagFormat.Item2, string.Empty)
  11319. .Replace("[++]", string.Empty);
  11320. DataRow dr = dtSource.NewRow();
  11321. dr["Days"] = item.Days;
  11322. dr["Date"] = item.Date;
  11323. dr["Week"] = item.WeekDay;
  11324. dr["Traffic"] = item.Traffic_First
  11325. + "\r\n"
  11326. + item.Traffic_Second;
  11327. dr["Trip"] = item.Trip;
  11328. dtSource.Rows.Add(dr);
  11329. }
  11330. Dictionary<string, string> dic = new Dictionary<string, string>();
  11331. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  11332. dic.Add("City", CityStr);
  11333. dic.Add("Days", Find.VisitDays.ToString());
  11334. dic.Add("DeleCode", Find.TourCode);
  11335. dic.Add("Pnum", Find.VisitPNumber.ToString());
  11336. //模板路径
  11337. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  11338. //载入模板
  11339. Document doc = null;
  11340. DocumentBuilder builder = null;
  11341. try
  11342. {
  11343. //载入模板
  11344. doc = new Document(tempPath);
  11345. builder = new DocumentBuilder(doc);
  11346. }
  11347. catch (Exception)
  11348. {
  11349. jw.Msg = "模板位置不存在!";
  11350. return Ok(jw);
  11351. }
  11352. foreach (var key in dic.Keys)
  11353. {
  11354. Bookmark bookmark = doc.Range.Bookmarks[key];
  11355. if (bookmark != null)
  11356. {
  11357. builder.MoveToBookmark(key);
  11358. builder.Write(dic[key]);
  11359. }
  11360. }
  11361. //获取word里所有表格
  11362. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11363. //获取所填表格的序数
  11364. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11365. try
  11366. {
  11367. //循环赋值
  11368. for (int i = 0; i < dtSource.Rows.Count; i++)
  11369. {
  11370. builder.MoveToCell(0, i + 1, 0, 0);
  11371. builder.Write(dtSource.Rows[i]["Days"].ToString());
  11372. builder.MoveToCell(0, i + 1, 1, 0);
  11373. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  11374. builder.MoveToCell(0, i + 1, 2, 0);
  11375. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  11376. var trip = dtSource.Rows[i]["Trip"].ToString();
  11377. builder.MoveToCell(0, i + 1, 3, 0);
  11378. builder.Write(trip);
  11379. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  11380. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11381. // 获取特定索引的段落
  11382. Paragraph paragraph = (Paragraph)paragraphs[0];
  11383. Run run = paragraph.Runs[0];
  11384. Aspose.Words.Font font = run.Font;
  11385. font.Name = "黑体";
  11386. //设置双休红色
  11387. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  11388. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11389. paragraph = (Paragraph)paragraphs[1];
  11390. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  11391. {
  11392. run = paragraph.Runs[0];
  11393. font = run.Font;
  11394. font.Color = Color.Red;
  11395. }
  11396. }
  11397. }
  11398. catch (Exception ex)
  11399. {
  11400. }
  11401. //删除多余行
  11402. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  11403. {
  11404. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  11405. }
  11406. var targetTextList = new List<string>();
  11407. // 遍历文档中的表格
  11408. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11409. {
  11410. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11411. {
  11412. var cellIndex = 0;
  11413. foreach (Cell cell in row.Cells)
  11414. {
  11415. if (cellIndex == 1 && row.Cells.Count == 4)
  11416. {
  11417. foreach (var target in targetTextDic.Keys)
  11418. {
  11419. if (cell.GetText().Contains(target))
  11420. {
  11421. targetTextList = targetTextDic[target];
  11422. break;
  11423. }
  11424. }
  11425. }
  11426. // 遍历单元格中的所有段落
  11427. foreach (Paragraph paragraph in cell.Paragraphs)
  11428. {
  11429. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  11430. List<Run> runs = new List<Run>();
  11431. foreach (Run run in paragraph.Runs)
  11432. {
  11433. runs.Add(run);
  11434. }
  11435. foreach (Run run in runs)
  11436. {
  11437. foreach (var targetText in targetTextList)
  11438. {
  11439. // 检查文字是否包含指定文字
  11440. if (run.Text.Contains(targetText))
  11441. {
  11442. // 将包含的部分设置为红色
  11443. HighlightText(run, targetText, Color.Red);
  11444. }
  11445. }
  11446. }
  11447. }
  11448. cellIndex++;
  11449. }
  11450. }
  11451. }
  11452. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  11453. if (!Directory.Exists(savePath))
  11454. {
  11455. try
  11456. {
  11457. Directory.CreateDirectory(savePath);
  11458. }
  11459. catch
  11460. {
  11461. }
  11462. }
  11463. string path = savePath + Find.TeamName + "出访日程";
  11464. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  11465. try
  11466. {
  11467. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  11468. string postfix = ".docx";
  11469. if (dto.IsPDF == 1)
  11470. {
  11471. saveFormat = Aspose.Words.SaveFormat.Pdf;
  11472. postfix = ".pdf";
  11473. }
  11474. doc.Save(path + postfix, saveFormat);
  11475. jw = JsonView(true, "导出成功", ftpPath + postfix);
  11476. }
  11477. catch (Exception)
  11478. {
  11479. jw = JsonView(false);
  11480. }
  11481. return Ok(jw);
  11482. }
  11483. /// <summary>
  11484. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  11485. /// </summary>
  11486. /// <param name="num"></param>
  11487. /// <returns></returns>
  11488. string GetNum(string num)
  11489. {
  11490. string str = "";
  11491. switch (num)
  11492. {
  11493. case "1":
  11494. str = "一";
  11495. break;
  11496. case "2":
  11497. str = "二";
  11498. break;
  11499. case "3":
  11500. str = "三";
  11501. break;
  11502. case "4":
  11503. str = "四";
  11504. break;
  11505. case "5":
  11506. str = "五";
  11507. break;
  11508. case "6":
  11509. str = "六";
  11510. break;
  11511. case "7":
  11512. str = "七";
  11513. break;
  11514. case "8":
  11515. str = "八";
  11516. break;
  11517. case "9":
  11518. str = "九";
  11519. break;
  11520. case "10":
  11521. str = "十";
  11522. break;
  11523. case "11":
  11524. str = "十一";
  11525. break;
  11526. case "12":
  11527. str = "十二";
  11528. break;
  11529. case "一":
  11530. str = "1";
  11531. break;
  11532. case "二":
  11533. str = "2";
  11534. break;
  11535. case "三":
  11536. str = "3";
  11537. break;
  11538. case "四":
  11539. str = "4";
  11540. break;
  11541. case "五":
  11542. str = "5";
  11543. break;
  11544. case "六":
  11545. str = "6";
  11546. break;
  11547. case "七":
  11548. str = "7";
  11549. break;
  11550. case "八":
  11551. str = "8";
  11552. break;
  11553. case "九":
  11554. str = "9";
  11555. break;
  11556. case "十":
  11557. str = "10";
  11558. break;
  11559. case "十一":
  11560. str = "11";
  11561. break;
  11562. case "十二":
  11563. str = "12";
  11564. break;
  11565. }
  11566. return str;
  11567. }
  11568. // 高亮包含指定文字的部分
  11569. void HighlightText(Run run, string targetText, Color color)
  11570. {
  11571. string text = run.Text;
  11572. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  11573. if (startIndex >= 0)
  11574. {
  11575. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  11576. // 前部分
  11577. if (startIndex > 0)
  11578. {
  11579. Run beforeRun = (Run)run.Clone(true);
  11580. beforeRun.Text = text.Substring(0, startIndex);
  11581. parentParagraph.InsertBefore(beforeRun, run);
  11582. }
  11583. // 匹配部分
  11584. Run matchRun = (Run)run.Clone(true);
  11585. matchRun.Text = text.Substring(startIndex, targetText.Length);
  11586. matchRun.Font.Color = color;
  11587. parentParagraph.InsertBefore(matchRun, run);
  11588. // 后部分
  11589. if (startIndex + targetText.Length < text.Length)
  11590. {
  11591. Run afterRun = (Run)run.Clone(true);
  11592. afterRun.Text = text.Substring(startIndex + targetText.Length);
  11593. parentParagraph.InsertBefore(afterRun, run);
  11594. }
  11595. // 删除原始Run
  11596. run.Remove();
  11597. }
  11598. }
  11599. #endregion
  11600. #endregion
  11601. #region 团组成本
  11602. /// <summary>
  11603. /// 团组成本数据初始化
  11604. /// </summary>
  11605. /// <param name="dto"></param>
  11606. /// <returns></returns>
  11607. [HttpPost]
  11608. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  11609. {
  11610. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  11611. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  11612. WHEN COUNT(*) >= 0 THEN 'True'
  11613. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  11614. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  11615. ").ToList(); //团组列表
  11616. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  11617. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  11618. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  11619. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  11620. if (groupinfoValue != null)
  11621. {
  11622. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  11623. var spArr = new string[1] { countryArr };
  11624. if (countryArr.Contains("|"))
  11625. {
  11626. spArr = countryArr.Split("|");
  11627. }
  11628. else if (countryArr.Contains("、"))
  11629. {
  11630. spArr = countryArr.Split("、");
  11631. }
  11632. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  11633. {
  11634. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  11635. if (dbQueryCountry != null)
  11636. {
  11637. visaCountryInfoArr.Add(dbQueryCountry);
  11638. }
  11639. }
  11640. }
  11641. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  11642. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  11643. var create = _GroupCostRepository.
  11644. CreateGroupCostByBlackCode(dto.Diid);
  11645. if (groupCost.Count == 0 && create.Code == 0)
  11646. {
  11647. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  11648. }
  11649. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  11650. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  11651. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  11652. groupCostMap = groupCostMap.Select(x =>
  11653. {
  11654. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  11655. {
  11656. x.Date = dataForamt.ToString("yyyy-MM-dd");
  11657. }
  11658. return x;
  11659. }).ToList();
  11660. //GroupCostParameter.Add(new
  11661. // Grp_GroupCostParameter());
  11662. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  11663. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  11664. return Ok(JsonView(new
  11665. {
  11666. groupList,
  11667. groupInfo,
  11668. groupChecks,
  11669. groupCost = groupCostMap,
  11670. hotelNumber,
  11671. GroupCostParameter = GroupCostParameterMap,
  11672. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  11673. {
  11674. x.VisaCountry,
  11675. x.VisaPrice,
  11676. x.Id,
  11677. }).ToList(),
  11678. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  11679. blackCodeIsTrue = create.Code == 0 ? true : false,
  11680. hotelIsTrue = hotelIsTrue,
  11681. }));
  11682. }
  11683. /// <summary>
  11684. /// 团组成本信息保存
  11685. /// </summary>
  11686. /// <param name="dto"></param>
  11687. /// <returns></returns>
  11688. [HttpPost]
  11689. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  11690. {
  11691. if (dto.Diid <= 0 || dto.Userid <= 0)
  11692. {
  11693. return Ok(JsonView(false));
  11694. }
  11695. JsonView jw = null;
  11696. bool isTrue = false;
  11697. #region 复制团组成本
  11698. //if (dto.Diid == 2581)
  11699. //{
  11700. // dto.Diid = 2599;
  11701. // dto.CheckBoxs.ForEach(x =>
  11702. // {
  11703. // x.Diid = 2599;
  11704. // });
  11705. // dto.GroupCosts.ForEach(x =>
  11706. // {
  11707. // x.Diid = 2599;
  11708. // });
  11709. // dto.CostTypeHotelNumbers.ForEach(x =>
  11710. // {
  11711. // x.Diid = 2599;
  11712. // });
  11713. // dto.GroupCostParameters.ForEach(x =>
  11714. // {
  11715. // x.DiId = 2599;
  11716. // });
  11717. //}
  11718. #endregion
  11719. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  11720. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  11721. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  11722. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  11723. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  11724. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  11725. try
  11726. {
  11727. _sqlSugar.BeginTran();
  11728. isTrue = await _GroupCostRepository.
  11729. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  11730. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  11731. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  11732. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  11733. _sqlSugar.CommitTran();
  11734. jw = JsonView(true, "保存成功!", isTrue);
  11735. }
  11736. catch (Exception)
  11737. {
  11738. _sqlSugar.RollbackTran();
  11739. jw = JsonView(false);
  11740. }
  11741. return Ok(jw);
  11742. }
  11743. /// <summary>
  11744. /// 司兼导数据
  11745. /// </summary>
  11746. /// <param name="dto"></param>
  11747. /// <returns></returns>
  11748. [HttpPost]
  11749. public IActionResult GetCarGuides(CarGuidesDto dto)
  11750. {
  11751. JsonView jw = null;
  11752. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  11753. jw = JsonView(true, "获取成功!", Data);
  11754. return Ok(jw);
  11755. }
  11756. /// <summary>
  11757. /// 导游数据
  11758. /// </summary>
  11759. /// <param name="dto"></param>
  11760. /// <returns></returns>
  11761. [HttpPost]
  11762. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  11763. {
  11764. JsonView jw = null;
  11765. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  11766. // 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
  11767. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  11768. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  11769. jw = JsonView(true, "获取成功!", Data);
  11770. return Ok(jw);
  11771. }
  11772. /// <summary>
  11773. /// 成本车数据
  11774. /// </summary>
  11775. /// <param name="dto"></param>
  11776. /// <returns></returns>
  11777. [HttpPost]
  11778. public IActionResult GetCarInfo(CarGuidesDto dto)
  11779. {
  11780. JsonView jw = null;
  11781. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  11782. jw = JsonView(true, "获取成功!", Data);
  11783. return Ok(jw);
  11784. }
  11785. /// <summary>
  11786. /// 景点数据
  11787. /// </summary>
  11788. /// <param name="dto"></param>
  11789. /// <returns></returns>
  11790. [HttpPost]
  11791. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  11792. {
  11793. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  11794. return Ok(JsonView(true, "获取成功!", Data));
  11795. }
  11796. /// <summary>
  11797. /// 成本通知
  11798. /// </summary>
  11799. /// <param name="dto"></param>
  11800. /// <returns></returns>
  11801. [HttpPost]
  11802. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  11803. {
  11804. if (dto.Diid < 0)
  11805. {
  11806. return Ok(JsonView(false));
  11807. }
  11808. JsonView jw = null;
  11809. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  11810. if (GroupCostParameter != null)
  11811. {
  11812. int IsShare = 0;
  11813. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  11814. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  11815. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  11816. string msg = string.Empty;
  11817. if (isTrue)
  11818. {
  11819. if (IsShare == 0)
  11820. {
  11821. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  11822. }
  11823. else
  11824. {
  11825. #region 企微通知对应岗位用户
  11826. try
  11827. {
  11828. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  11829. }
  11830. catch (Exception ex)
  11831. {
  11832. }
  11833. #endregion
  11834. msg = "通知成功,其他模块操作人员可见此成本信息!";
  11835. }
  11836. jw = JsonView(isTrue, msg, new { IsShare });
  11837. }
  11838. else
  11839. {
  11840. msg = "修改失败!";
  11841. jw = JsonView(isTrue, msg);
  11842. }
  11843. }
  11844. else
  11845. {
  11846. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  11847. }
  11848. return Ok(jw);
  11849. }
  11850. /// <summary>
  11851. /// 导出报价单
  11852. /// </summary>
  11853. /// <param name="dto"></param>
  11854. /// <returns></returns>
  11855. [HttpPost]
  11856. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  11857. {
  11858. if (dto.Diid == 0)
  11859. {
  11860. return Ok(JsonView(false, "请传递团组id"));
  11861. }
  11862. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  11863. if (deleInfo.Code != 0)
  11864. {
  11865. return Ok(JsonView(false, "团组信息查询失败!"));
  11866. }
  11867. var di = deleInfo.Data as DelegationInfoWebView;
  11868. if (di != null)
  11869. {
  11870. di.TeamName = di.TeamName.Replace("|", "、");
  11871. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  11872. //文件名
  11873. string strFileName = di.TeamName + "-收款账单.doc";
  11874. //获取模板
  11875. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  11876. //载入模板
  11877. Document doc = new Document(tmppath);
  11878. decimal TotalPrice = 0.00M;
  11879. string itemStr = string.Empty;
  11880. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  11881. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  11882. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  11883. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  11884. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  11885. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  11886. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  11887. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  11888. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  11889. foreach (var cost in groupCostType)
  11890. {
  11891. var List = cost.ToList();
  11892. if (cost.Key == "A")
  11893. {
  11894. foreach (var ListItem in List)
  11895. {
  11896. if (ListItem.number > 0)
  11897. {
  11898. if (ListItem.code.Contains("TBR"))
  11899. {
  11900. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11901. }
  11902. else
  11903. {
  11904. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11905. }
  11906. TotalPrice += (ListItem.number * ListItem.price);
  11907. }
  11908. }
  11909. }
  11910. else
  11911. {
  11912. itemStr = itemStr.Insert(0, "A段\r\n");
  11913. itemStr += "B段\r\n";
  11914. foreach (var ListItem in List)
  11915. {
  11916. if (ListItem.number > 0)
  11917. {
  11918. if (ListItem.code.Contains("TBR"))
  11919. {
  11920. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11921. }
  11922. else
  11923. {
  11924. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11925. }
  11926. TotalPrice += (ListItem.number * ListItem.price);
  11927. }
  11928. }
  11929. }
  11930. }
  11931. #region 替换Word模板书签内容
  11932. Dictionary<string, string> marks = new Dictionary<string, string>();
  11933. marks.Add("To", di.ClientUnit);//付款方
  11934. marks.Add("ToTel", di.TellPhone);//付款方电话
  11935. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  11936. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  11937. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  11938. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  11939. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  11940. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  11941. marks.Add("PayItemContent", itemStr);//详细信息
  11942. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  11943. #endregion
  11944. ////注
  11945. //if (doc.Range.Bookmarks["Attention"] != null)
  11946. //{
  11947. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  11948. // mark.Text = frList[0].Attention;
  11949. //}
  11950. foreach (var item in marks.Keys)
  11951. {
  11952. if (doc.Range.Bookmarks[item] != null)
  11953. {
  11954. Bookmark mark = doc.Range.Bookmarks[item];
  11955. mark.Text = marks[item];
  11956. }
  11957. }
  11958. byte[] bytes = null;
  11959. using (MemoryStream stream = new MemoryStream())
  11960. {
  11961. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  11962. bytes = stream.ToArray();
  11963. }
  11964. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  11965. return Ok(JsonView(true, "", new
  11966. {
  11967. Data = bytes,
  11968. strFileName,
  11969. }));
  11970. }
  11971. else
  11972. {
  11973. return Ok(JsonView(false, "团组信息不存在!"));
  11974. }
  11975. }
  11976. /// <summary>
  11977. /// 导出团组成本
  11978. /// </summary>
  11979. /// <param name="dto"></param>
  11980. /// <returns></returns>
  11981. [HttpPost]
  11982. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  11983. {
  11984. var jw = JsonView(false);
  11985. if (dto.Diid == 0)
  11986. {
  11987. return Ok(JsonView(false, "请传递团组id"));
  11988. }
  11989. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  11990. if (deleInfo.Code != 0)
  11991. {
  11992. return Ok(JsonView(false, "团组信息查询失败!"));
  11993. }
  11994. var di = deleInfo.Data as DelegationInfoWebView;
  11995. if (di == null)
  11996. {
  11997. return Ok(JsonView(false, "团组信息查询失败!"));
  11998. }
  11999. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  12000. WorkbookDesigner designer = new WorkbookDesigner();
  12001. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  12002. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  12003. for (int i = 0; i < List_GC.Count; i++)
  12004. {
  12005. GroupCost_Excel gc = new GroupCost_Excel();
  12006. gc.Id = List_GC[i].Id;
  12007. gc.Diid = List_GC[i].Diid.ToString();
  12008. gc.DAY = List_GC[i].DAY;
  12009. string week = "";
  12010. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  12011. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  12012. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  12013. gc.ITIN = List_GC[i].ITIN;
  12014. gc.CarType = List_GC[i].CarType;
  12015. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  12016. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  12017. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  12018. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  12019. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  12020. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  12021. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  12022. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  12023. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  12024. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  12025. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  12026. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  12027. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12028. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12029. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  12030. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  12031. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  12032. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  12033. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  12034. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  12035. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  12036. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  12037. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  12038. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  12039. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  12040. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  12041. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  12042. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  12043. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  12044. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  12045. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  12046. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  12047. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  12048. List_GC1.Add(gc);
  12049. }
  12050. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  12051. dt.TableName = "TB";
  12052. //报表标题等不用dt的值
  12053. designer.SetDataSource("TeamName", dto.title.TeamName);
  12054. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  12055. designer.SetDataSource("Tax", dto.title.Tax);
  12056. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  12057. designer.SetDataSource("Currency", dto.title.Currency);
  12058. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  12059. designer.SetDataSource("Rate", dto.title.Rate);
  12060. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  12061. var Aparams = hotels.Find(x => x.Type == "Default");
  12062. if (Aparams == null)
  12063. {
  12064. return Ok(jw);
  12065. }
  12066. //酒店数量
  12067. var txtSGRNumber = Aparams.SGR.ToString();
  12068. var txtTBRNumber = Aparams.TBR.ToString();
  12069. var txtJSESNumber = Aparams.JSES.ToString();
  12070. var txtSUITENumbe = Aparams.SUITE.ToString();
  12071. if (dto.costType == "B")
  12072. {
  12073. Aparams = hotels.Find(x => x.Type == "A");
  12074. var Bparams = hotels.Find(x => x.Type == "B");
  12075. if (Aparams == null || Bparams == null)
  12076. {
  12077. return Ok(jw);
  12078. }
  12079. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  12080. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  12081. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  12082. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  12083. }
  12084. designer.SetDataSource("SGRNumber", txtSGRNumber);
  12085. designer.SetDataSource("TBRNumber", txtTBRNumber);
  12086. designer.SetDataSource("JSESNumber", txtJSESNumber);
  12087. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  12088. var ws = designer.Workbook.Worksheets[0];
  12089. int Row = List_GC.Count;
  12090. int startIndex = 11;
  12091. int HideRows = 0;
  12092. List<int> hideRowsList = new List<int>();
  12093. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  12094. #region A段left数据
  12095. var left = dto.leftInfo.Find(x => x.Type == "A");
  12096. if (left == null)
  12097. {
  12098. return Ok(jw);
  12099. }
  12100. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  12101. if (leftBindData != null)
  12102. {
  12103. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  12104. designer.SetDataSource("VisaRS", leftBindData.rs);
  12105. designer.SetDataSource("VisaXS", leftBindData.xs);
  12106. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12107. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12108. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12109. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12110. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12111. }
  12112. else
  12113. {
  12114. hideRowsList.Add(Row + startIndex + HideRows);
  12115. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12116. }
  12117. HideRows += 2;
  12118. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  12119. if (leftBindData != null)
  12120. {
  12121. designer.SetDataSource("BXDRCB", leftBindData.cb);
  12122. designer.SetDataSource("BXRS", leftBindData.rs);
  12123. designer.SetDataSource("BXXS", leftBindData.xs);
  12124. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12125. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12126. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12127. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12128. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12129. }
  12130. else
  12131. {
  12132. hideRowsList.Add(Row + startIndex + HideRows);
  12133. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12134. }
  12135. HideRows += 2;
  12136. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12137. if (leftBindData != null)
  12138. {
  12139. designer.SetDataSource("HSDRCB", leftBindData.cb);
  12140. designer.SetDataSource("HSRS", leftBindData.rs);
  12141. designer.SetDataSource("HSXS", leftBindData.xs);
  12142. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12143. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12144. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12145. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12146. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12147. }
  12148. else
  12149. {
  12150. hideRowsList.Add(Row + startIndex + HideRows);
  12151. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12152. }
  12153. HideRows += 2;
  12154. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12155. if (leftBindData != null)
  12156. {
  12157. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  12158. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  12159. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  12160. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12161. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12162. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12163. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12164. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12165. }
  12166. else
  12167. {
  12168. hideRowsList.Add(Row + startIndex + HideRows);
  12169. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12170. }
  12171. HideRows += 2;
  12172. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12173. if (leftBindData != null)
  12174. {
  12175. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  12176. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  12177. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  12178. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12179. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12180. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12181. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12182. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12183. }
  12184. else
  12185. {
  12186. hideRowsList.Add(Row + startIndex + HideRows);
  12187. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12188. }
  12189. HideRows += 2;
  12190. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12191. if (leftBindData != null)
  12192. {
  12193. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  12194. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  12195. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  12196. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12197. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12198. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12199. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12200. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12201. }
  12202. else
  12203. {
  12204. hideRowsList.Add(Row + startIndex + HideRows);
  12205. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12206. }
  12207. HideRows += 2;
  12208. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12209. if (leftBindData != null)
  12210. {
  12211. ////TBR
  12212. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  12213. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  12214. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  12215. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12216. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12217. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12218. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12219. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12220. }
  12221. else
  12222. {
  12223. hideRowsList.Add(Row + startIndex + HideRows);
  12224. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12225. }
  12226. HideRows += 2;
  12227. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12228. if (leftBindData != null)
  12229. {
  12230. ////SGR
  12231. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  12232. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  12233. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  12234. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12235. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12236. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12237. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12238. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12239. }
  12240. else
  12241. {
  12242. hideRowsList.Add(Row + startIndex + HideRows);
  12243. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12244. }
  12245. HideRows += 2;
  12246. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12247. if (leftBindData != null)
  12248. {
  12249. ////JS/ES
  12250. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  12251. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  12252. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  12253. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12254. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12255. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12256. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12257. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12258. }
  12259. else
  12260. {
  12261. hideRowsList.Add(Row + startIndex + HideRows);
  12262. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12263. }
  12264. HideRows += 2;
  12265. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12266. if (leftBindData != null)
  12267. {
  12268. ////SUITE
  12269. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  12270. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  12271. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  12272. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12273. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12274. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12275. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12276. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12277. }
  12278. else
  12279. {
  12280. hideRowsList.Add(Row + startIndex + HideRows);
  12281. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12282. }
  12283. HideRows += 2;
  12284. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12285. if (leftBindData != null)
  12286. {
  12287. designer.SetDataSource("DJDRCB", leftBindData.cb);
  12288. designer.SetDataSource("DJRS", leftBindData.rs);
  12289. designer.SetDataSource("DJXS", leftBindData.xs);
  12290. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12291. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12292. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12293. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12294. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12295. }
  12296. else
  12297. {
  12298. hideRowsList.Add(Row + startIndex + HideRows);
  12299. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12300. }
  12301. HideRows += 2;
  12302. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12303. if (leftBindData != null)
  12304. {
  12305. designer.SetDataSource("HCPCB", leftBindData.cb);
  12306. designer.SetDataSource("HCPRS", leftBindData.rs);
  12307. designer.SetDataSource("HCPXS", leftBindData.xs);
  12308. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12309. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12310. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12311. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12312. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12313. }
  12314. else
  12315. {
  12316. hideRowsList.Add(Row + startIndex + HideRows);
  12317. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12318. }
  12319. HideRows += 2;
  12320. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12321. if (leftBindData != null)
  12322. {
  12323. designer.SetDataSource("CPCB", leftBindData.cb);
  12324. designer.SetDataSource("CPRS", leftBindData.rs);
  12325. designer.SetDataSource("CPXS", leftBindData.xs);
  12326. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12327. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12328. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12329. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12330. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12331. }
  12332. else
  12333. {
  12334. hideRowsList.Add(Row + startIndex + HideRows);
  12335. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12336. }
  12337. HideRows += 2;
  12338. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12339. if (leftBindData != null)
  12340. {
  12341. designer.SetDataSource("GWDRCD", leftBindData.cb);
  12342. designer.SetDataSource("GWRS", leftBindData.rs);
  12343. designer.SetDataSource("GWXS", leftBindData.xs);
  12344. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12345. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12346. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12347. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12348. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12349. }
  12350. else
  12351. {
  12352. hideRowsList.Add(Row + startIndex + HideRows);
  12353. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12354. }
  12355. HideRows += 2;
  12356. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12357. if (leftBindData != null)
  12358. {
  12359. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  12360. designer.SetDataSource("LYJRS", leftBindData.rs);
  12361. designer.SetDataSource("LYJXS", leftBindData.xs);
  12362. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12363. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12364. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12365. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12366. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12367. }
  12368. else
  12369. {
  12370. hideRowsList.Add(Row + startIndex + HideRows);
  12371. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12372. }
  12373. #endregion
  12374. #region A段Right信息
  12375. var right = dto.rightInfo.Find(x => x.Type == "A");
  12376. if (right == null)
  12377. {
  12378. return Ok(jw);
  12379. }
  12380. HideRows += 4;
  12381. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12382. if (rightBindData != null)
  12383. {
  12384. //经济舱 + 双人间 TBR
  12385. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  12386. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  12387. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12388. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  12389. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12390. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12391. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12392. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12393. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12394. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12395. }
  12396. else
  12397. {
  12398. hideRowsList.Add(Row + startIndex + HideRows);
  12399. }
  12400. HideRows += 2;
  12401. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12402. if (rightBindData != null)
  12403. {
  12404. //经济舱 + 单人间 SGR
  12405. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  12406. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  12407. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12408. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  12409. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12410. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12411. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12412. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12413. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12414. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12415. }
  12416. else
  12417. {
  12418. hideRowsList.Add(Row + startIndex + HideRows);
  12419. }
  12420. HideRows += 2;
  12421. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12422. if (rightBindData != null)
  12423. {
  12424. //公务舱 + 单人间 SGR
  12425. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  12426. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  12427. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12428. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  12429. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12430. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12431. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12432. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12433. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12434. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12435. }
  12436. else
  12437. {
  12438. hideRowsList.Add(Row + startIndex + HideRows);
  12439. }
  12440. HideRows += 2;
  12441. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12442. if (rightBindData != null)
  12443. {
  12444. //公务舱 + 小套房 JSES
  12445. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  12446. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  12447. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12448. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  12449. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12450. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12451. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12452. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12453. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12454. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12455. }
  12456. else
  12457. {
  12458. hideRowsList.Add(Row + startIndex + HideRows);
  12459. }
  12460. HideRows += 2;
  12461. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12462. if (rightBindData != null)
  12463. {
  12464. //公务舱 + 小套房 JSES
  12465. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  12466. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  12467. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12468. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  12469. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12470. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12471. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12472. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12473. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12474. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12475. }
  12476. else
  12477. {
  12478. hideRowsList.Add(Row + startIndex + HideRows);
  12479. }
  12480. HideRows += 2;
  12481. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12482. if (rightBindData != null)
  12483. {
  12484. //经济舱 + 大套房
  12485. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  12486. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  12487. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12488. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  12489. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12490. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12491. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12492. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12493. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12494. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12495. }
  12496. else
  12497. {
  12498. hideRowsList.Add(Row + startIndex + HideRows);
  12499. }
  12500. HideRows += 2;
  12501. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12502. if (rightBindData != null)
  12503. {
  12504. //头等舱 + 小套房 JSES
  12505. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  12506. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  12507. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12508. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  12509. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12510. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12511. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12512. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12513. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12514. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12515. }
  12516. else
  12517. {
  12518. hideRowsList.Add(Row + startIndex + HideRows);
  12519. }
  12520. HideRows += 2;
  12521. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12522. if (rightBindData != null)
  12523. {
  12524. //头等舱 + 大套房
  12525. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  12526. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  12527. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12528. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  12529. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12530. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12531. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12532. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12533. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12534. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12535. }
  12536. else
  12537. {
  12538. hideRowsList.Add(Row + startIndex + HideRows);
  12539. }
  12540. #endregion
  12541. #region B段标题清空
  12542. designer.SetDataSource("CostBDRCB", "");
  12543. designer.SetDataSource("CostBRS", "");
  12544. designer.SetDataSource("CostBXS", "");
  12545. designer.SetDataSource("CostBZCB", "");
  12546. designer.SetDataSource("CostBDRBJ", "");
  12547. designer.SetDataSource("CostBZBJ", "");
  12548. designer.SetDataSource("CostBDRLR", "");
  12549. designer.SetDataSource("CostBZLR", "");
  12550. designer.SetDataSource("CostBDRCBOM", "");
  12551. designer.SetDataSource("CostBRSOM", "");
  12552. designer.SetDataSource("CostBZCBOM", "");
  12553. designer.SetDataSource("CostBDRBJOM", "");
  12554. designer.SetDataSource("CostBZBJOM", "");
  12555. designer.SetDataSource("CostBDRLROM", "");
  12556. designer.SetDataSource("CostBZLROM", "");
  12557. #endregion
  12558. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  12559. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  12560. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  12561. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  12562. designer.SetDataSource("DJName", "地接(CNY)");
  12563. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  12564. designer.SetDataSource("CPName", "地接-船票(CNY)");
  12565. designer.SetDataSource("GWName", "公务(CNY)");
  12566. designer.SetDataSource("YQHName", "邀请函(CNY)");
  12567. designer.SetDataSource("LYJName", "零用金(CNY)");
  12568. designer.SetDataSource("HSName", "核酸检测(CNY)");
  12569. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  12570. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  12571. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  12572. designer.SetDataSource("BXName", "保险(CNY)");
  12573. designer.SetDataSource("VisaName", "签证(CNY)");
  12574. #region B段基本数据
  12575. if (dto.costType == "B")
  12576. {
  12577. left = dto.leftInfo.Find(x => x.Type == "B");
  12578. if (left == null)
  12579. {
  12580. return Ok(jw);
  12581. }
  12582. #region B段left数据
  12583. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12584. if (leftBindData != null)
  12585. {
  12586. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  12587. designer.SetDataSource("BHSRS", leftBindData.rs);
  12588. designer.SetDataSource("BHSXS", leftBindData.xs);
  12589. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12590. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12591. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12592. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12593. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12594. }
  12595. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12596. if (leftBindData != null)
  12597. {
  12598. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  12599. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  12600. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  12601. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12602. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12603. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12604. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12605. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12606. }
  12607. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12608. if (leftBindData != null)
  12609. {
  12610. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  12611. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  12612. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  12613. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12614. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12615. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12616. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12617. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12618. }
  12619. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12620. if (leftBindData != null)
  12621. {
  12622. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  12623. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  12624. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  12625. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12626. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12627. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12628. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12629. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12630. }
  12631. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12632. if (leftBindData != null)
  12633. {
  12634. designer.SetDataSource("BHCPCB", leftBindData.cb);
  12635. designer.SetDataSource("BHCPRS", leftBindData.rs);
  12636. designer.SetDataSource("BHCPXS", leftBindData.xs);
  12637. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12638. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12639. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12640. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12641. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12642. }
  12643. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12644. if (leftBindData != null)
  12645. {
  12646. designer.SetDataSource("BCPCB", leftBindData.cb);
  12647. designer.SetDataSource("BCPRS", leftBindData.rs);
  12648. designer.SetDataSource("BCPXS", leftBindData.xs);
  12649. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12650. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12651. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12652. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12653. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12654. }
  12655. //TBR
  12656. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12657. if (leftBindData != null)
  12658. {
  12659. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  12660. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  12661. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  12662. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12663. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12664. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12665. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12666. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12667. }
  12668. //SGR
  12669. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12670. if (leftBindData != null)
  12671. {
  12672. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  12673. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  12674. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  12675. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12676. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12677. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12678. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12679. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12680. }
  12681. //JS/ES
  12682. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12683. if (leftBindData != null)
  12684. {
  12685. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  12686. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  12687. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  12688. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12689. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12690. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12691. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12692. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12693. }
  12694. //SUITE
  12695. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12696. if (leftBindData != null)
  12697. {
  12698. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  12699. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  12700. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  12701. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12702. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12703. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12704. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12705. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12706. }
  12707. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12708. if (leftBindData != null)
  12709. {
  12710. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  12711. designer.SetDataSource("BDJRS", leftBindData.rs);
  12712. designer.SetDataSource("BDJXS", leftBindData.xs);
  12713. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12714. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12715. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12716. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12717. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12718. }
  12719. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12720. if (leftBindData != null)
  12721. {
  12722. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  12723. designer.SetDataSource("BGWRS", leftBindData.rs);
  12724. designer.SetDataSource("BGWXS", leftBindData.xs);
  12725. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12726. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12727. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12728. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12729. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12730. }
  12731. #region 优化方案
  12732. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  12733. //excelBind.Add("零用金", new {
  12734. //cb="",
  12735. //rs="",
  12736. //xs ="",
  12737. //zcb = "",
  12738. //});
  12739. #endregion
  12740. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12741. if (leftBindData != null)
  12742. {
  12743. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  12744. designer.SetDataSource("BLYJRS", leftBindData.rs);
  12745. designer.SetDataSource("BLYJXS", leftBindData.xs);
  12746. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12747. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12748. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12749. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12750. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12751. }
  12752. #endregion
  12753. #region B段Right信息
  12754. right = dto.rightInfo.Find(x => x.Type == "B");
  12755. if (right == null)
  12756. {
  12757. return Ok(jw);
  12758. }
  12759. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12760. if (rightBindData != null)
  12761. {
  12762. //经济舱 + 双人间 TBR
  12763. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  12764. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  12765. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12766. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  12767. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12768. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12769. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12770. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12771. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12772. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12773. }
  12774. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12775. if (rightBindData != null)
  12776. {
  12777. //经济舱 + 单人间 SGR
  12778. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  12779. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  12780. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12781. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  12782. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12783. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12784. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12785. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12786. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12787. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12788. }
  12789. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12790. if (rightBindData != null)
  12791. {
  12792. //公务舱 + 单人间 SGR
  12793. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  12794. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  12795. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12796. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  12797. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12798. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12799. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12800. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12801. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12802. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12803. }
  12804. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12805. if (rightBindData != null)
  12806. {
  12807. //公务舱 + 小套房 JSES
  12808. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  12809. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  12810. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12811. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  12812. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12813. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12814. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12815. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12816. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12817. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12818. }
  12819. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12820. if (rightBindData != null)
  12821. {
  12822. //公务舱 + 小套房 JSES
  12823. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  12824. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  12825. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12826. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  12827. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12828. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12829. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12830. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12831. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12832. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12833. }
  12834. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12835. if (rightBindData != null)
  12836. {
  12837. //经济舱 + 大套房
  12838. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  12839. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  12840. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12841. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  12842. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12843. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12844. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12845. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12846. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12847. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12848. }
  12849. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12850. if (rightBindData != null)
  12851. {
  12852. //头等舱 + 小套房 JSES
  12853. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  12854. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  12855. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12856. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  12857. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12858. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12859. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12860. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12861. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12862. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12863. }
  12864. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12865. if (rightBindData != null)
  12866. {
  12867. //头等舱 + 大套房
  12868. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  12869. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  12870. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12871. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  12872. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12873. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12874. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12875. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12876. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12877. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12878. }
  12879. #endregion
  12880. #region 标题
  12881. designer.SetDataSource("CostBDRCB", "单人成本");
  12882. designer.SetDataSource("CostBRS", "人数");
  12883. designer.SetDataSource("CostBXS", "系数");
  12884. designer.SetDataSource("CostBZCB", "总成本");
  12885. designer.SetDataSource("CostBDRBJ", "单人报价");
  12886. designer.SetDataSource("CostBZBJ", "总报价");
  12887. designer.SetDataSource("CostBDRLR", "单人利润");
  12888. designer.SetDataSource("CostBZLR", "总利润");
  12889. designer.SetDataSource("CostBDRCBOM", "单人成本");
  12890. designer.SetDataSource("CostBRSOM", "人数");
  12891. designer.SetDataSource("CostBZCBOM", "总成本");
  12892. designer.SetDataSource("CostBDRBJOM", "单人报价");
  12893. designer.SetDataSource("CostBZBJOM", "总报价");
  12894. designer.SetDataSource("CostBDRLROM", "单人利润");
  12895. designer.SetDataSource("CostBZLROM", "总利润");
  12896. #endregion
  12897. }
  12898. #endregion
  12899. designer.SetDataSource("TzZCB2", TzZCB2);
  12900. designer.SetDataSource("TzZBJ2", TzZBJ2);
  12901. designer.SetDataSource("TzZLR2", TzZLR2);
  12902. string[] dataSourceKeys = new string[]
  12903. {
  12904. "VF",
  12905. "TGS",
  12906. "TGOF",
  12907. "TGM",
  12908. "TGA",
  12909. "TGTF",
  12910. "TGEF",
  12911. "CFM",
  12912. "CFOF",
  12913. "B",
  12914. "L",
  12915. "D",
  12916. "TBR",
  12917. "SGR",
  12918. "JSES",
  12919. "Suite",
  12920. "TV",
  12921. "1L",
  12922. "IF",
  12923. "EF",
  12924. "BRF",
  12925. "TE",
  12926. "TGT",
  12927. "DRVT",
  12928. "PC",
  12929. "TLF",
  12930. "ECT"
  12931. };
  12932. foreach (var item in dataSourceKeys)
  12933. {
  12934. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  12935. if (find != null)
  12936. {
  12937. designer.SetDataSource(item, find.text);
  12938. }
  12939. else
  12940. {
  12941. designer.SetDataSource(item, 0);
  12942. }
  12943. }
  12944. designer.SetDataSource(dt);
  12945. //根据数据源处理生成报表内容
  12946. designer.Process();
  12947. designer.Workbook.Worksheets[0].Name = "清单";
  12948. Worksheet sheet = designer.Workbook.Worksheets[0];
  12949. foreach (var Rowindex in hideRowsList)
  12950. {
  12951. ws.Cells.HideRows(Rowindex, 2);
  12952. }
  12953. byte[] bytes = null;
  12954. string strFileName = di.TeamName + "-团组-成本.xls";
  12955. using (MemoryStream stream = new MemoryStream())
  12956. {
  12957. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  12958. bytes = stream.ToArray();
  12959. }
  12960. return Ok(JsonView(true, "", new
  12961. {
  12962. Data = bytes,
  12963. strFileName,
  12964. }));
  12965. }
  12966. /// <summary>
  12967. /// 导出客户报表
  12968. /// </summary>
  12969. /// <returns></returns>
  12970. [HttpPost]
  12971. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  12972. {
  12973. var jw = JsonView(false);
  12974. if (dto.Diid == 0)
  12975. {
  12976. return Ok(JsonView(false, "请传递团组id"));
  12977. }
  12978. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12979. if (deleInfo.Code != 0)
  12980. {
  12981. return Ok(JsonView(false, "团组信息查询失败!"));
  12982. }
  12983. var di = deleInfo.Data as DelegationInfoWebView;
  12984. if (di == null)
  12985. {
  12986. return Ok(JsonView(false, "团组信息查询失败!"));
  12987. }
  12988. //文件名
  12989. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  12990. //获取模板
  12991. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  12992. //载入模板
  12993. Document doc = new Document(tmppath);
  12994. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  12995. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  12996. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  12997. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  12998. var AParameter = ParameterList.Find(x => x.CostType == "A");
  12999. var BParameter = ParameterList.Find(x => x.CostType == "B");
  13000. if (AParameter == null)
  13001. {
  13002. return Ok(JsonView(false, "系数不存在!"));
  13003. }
  13004. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  13005. , TzAirDesc, TzZCost;
  13006. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  13007. = TzAirDesc = TzZCost = string.Empty;
  13008. TzNumber = AParameter.CostTypenumber.ToString();
  13009. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  13010. CarGuides1 = dto.CarGuides1;
  13011. Meal = dto.Meal;
  13012. SubsidizedMeals = dto.SubsidizedMeals;
  13013. NightRepair = dto.NightRepair;
  13014. AttractionsTickets = dto.AttractionsTickets;
  13015. MiscellaneousFees = dto.MiscellaneousFees;
  13016. ATip = dto.ATip;
  13017. TzHotelDesc = "";
  13018. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  13019. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  13020. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  13021. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  13022. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  13023. TzAirDesc = "";
  13024. TzZCost = dto.TzZCost;
  13025. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  13026. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  13027. var index = 1;
  13028. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  13029. foreach (var item in TzHotelDescArr)
  13030. {
  13031. if (AinfoArr != null)
  13032. {
  13033. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13034. if (Ainfo != null)
  13035. {
  13036. if (int.Parse(Ainfo.rs) <= 0)
  13037. {
  13038. continue;
  13039. }
  13040. var hotelText = string.Empty;
  13041. switch (item)
  13042. {
  13043. case "SGR":
  13044. hotelText = "单人间";
  13045. break;
  13046. case "JSES":
  13047. hotelText = "小套房";
  13048. break;
  13049. case "SUITE":
  13050. hotelText = "套房";
  13051. break;
  13052. case "TBR":
  13053. hotelText = "双人间";
  13054. break;
  13055. }
  13056. if (item != "TBR")
  13057. {
  13058. 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";
  13059. }
  13060. else
  13061. {
  13062. 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";
  13063. }
  13064. index++;
  13065. }
  13066. }
  13067. }
  13068. index = 1;
  13069. foreach (var item in TzAirDescArr)
  13070. {
  13071. if (AinfoArr != null)
  13072. {
  13073. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13074. if (Ainfo != null)
  13075. {
  13076. if (int.Parse(Ainfo.rs) <= 0)
  13077. {
  13078. continue;
  13079. }
  13080. 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";
  13081. index++;
  13082. }
  13083. }
  13084. }
  13085. if (dto.costType == "B")
  13086. {
  13087. if (BParameter == null)
  13088. {
  13089. return Ok(JsonView(false, "B段系数不存在!"));
  13090. }
  13091. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  13092. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  13093. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  13094. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  13095. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  13096. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  13097. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  13098. foreach (var item in TzHotelDescArr)
  13099. {
  13100. if (AinfoArr != null)
  13101. {
  13102. TzHotelDesc += "B段信息 \r\n";
  13103. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13104. if (Ainfo != null)
  13105. {
  13106. if (int.Parse(Ainfo.rs) <= 0)
  13107. {
  13108. continue;
  13109. }
  13110. var hotelText = string.Empty;
  13111. switch (item)
  13112. {
  13113. case "SGR":
  13114. hotelText = "单人间";
  13115. break;
  13116. case "JSES":
  13117. hotelText = "小套房";
  13118. break;
  13119. case "SUITE":
  13120. hotelText = "套房";
  13121. break;
  13122. case "TBR":
  13123. hotelText = "双人间";
  13124. break;
  13125. }
  13126. if (item != "TBR")
  13127. {
  13128. 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";
  13129. }
  13130. else
  13131. {
  13132. 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";
  13133. }
  13134. index++;
  13135. }
  13136. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  13137. }
  13138. }
  13139. index = 1;
  13140. foreach (var item in TzAirDescArr)
  13141. {
  13142. if (AinfoArr != null)
  13143. {
  13144. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13145. if (Ainfo != null)
  13146. {
  13147. if (int.Parse(Ainfo.rs) <= 0)
  13148. {
  13149. continue;
  13150. }
  13151. 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";
  13152. index++;
  13153. }
  13154. }
  13155. }
  13156. }
  13157. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  13158. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  13159. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  13160. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  13161. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  13162. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  13163. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  13164. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  13165. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  13166. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  13167. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  13168. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  13169. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  13170. DickeyValue.Add("Visa", Visa); // 签证单人报价
  13171. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  13172. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  13173. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  13174. DickeyValue.Add("TzZCost", TzZCost);
  13175. foreach (var key in DickeyValue.Keys)
  13176. {
  13177. if (doc.Range.Bookmarks[key] != null)
  13178. {
  13179. Bookmark mark = doc.Range.Bookmarks[key];
  13180. mark.Text = DickeyValue[key];
  13181. }
  13182. }
  13183. byte[] bytes = null;
  13184. string strFileName = di.TeamName + "-客户报价.doc";
  13185. using (MemoryStream stream = new MemoryStream())
  13186. {
  13187. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13188. bytes = stream.ToArray();
  13189. }
  13190. return Ok(JsonView(true, "", new
  13191. {
  13192. Data = bytes,
  13193. strFileName,
  13194. }));
  13195. }
  13196. /// <summary>
  13197. /// 团组成本 各模块(酒店,地接,机票)成本提示
  13198. /// </summary>
  13199. /// <param name="dto"></param>
  13200. /// <returns></returns>
  13201. [HttpPost]
  13202. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13203. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  13204. {
  13205. try
  13206. {
  13207. #region 参数验证
  13208. if (dto.DiId < 0)
  13209. {
  13210. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  13211. }
  13212. List<int> cTableIds = new List<int>() {
  13213. 76 ,//酒店预订
  13214. 77 ,//行程
  13215. 79 ,//车/导游地接
  13216. 80 ,//签证
  13217. 81 ,//邀请/公务活
  13218. 82 ,//团组客户保险
  13219. 85 ,//机票预订
  13220. 98 ,//其他款项
  13221. 285 ,//收款退还
  13222. 751 ,//酒店早餐
  13223. 1015 // 超支费用
  13224. };
  13225. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  13226. {
  13227. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  13228. }
  13229. #endregion
  13230. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  13231. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  13232. if (_GroupCostParameters.Count <= 0)
  13233. {
  13234. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  13235. }
  13236. if (_GroupCostParameters[0].IsShare == 0)
  13237. {
  13238. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  13239. }
  13240. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13241. //处理date为空问题
  13242. if (_GroupCosts.Count > 0)
  13243. {
  13244. for (int i = 0; i < _GroupCosts.Count; i++)
  13245. {
  13246. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  13247. {
  13248. if (i > 0)
  13249. {
  13250. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  13251. }
  13252. }
  13253. }
  13254. }
  13255. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  13256. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  13257. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  13258. string currCode = "";
  13259. #region currCode 验证
  13260. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  13261. if (isInt)
  13262. {
  13263. var currData = currDatas.Find(it => it.Id == intCurrency);
  13264. if (currData != null)
  13265. {
  13266. currCode = currData.Name;
  13267. }
  13268. }
  13269. else
  13270. {
  13271. currCode = _GroupCostParameters[0].Currency.Trim();
  13272. }
  13273. #endregion
  13274. //op,酒店单段模式存储
  13275. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  13276. {
  13277. CurrencyCode = currCode,
  13278. Rate = _GroupCostParameters[0].Rate,
  13279. CostType = _GroupCostParameters[0].CostType,
  13280. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  13281. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  13282. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  13283. };
  13284. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  13285. if (_GroupCostParameters.Count == 2)
  13286. {
  13287. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  13288. }
  13289. foreach (var item in _GroupCostParameters)
  13290. {
  13291. decimal _rate = 1;
  13292. decimal _rate1 = item.Rate;
  13293. decimal _scale = 1;
  13294. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  13295. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  13296. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  13297. //if (userInfo != null)
  13298. //{
  13299. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  13300. // {
  13301. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  13302. // {
  13303. // _scale = 1.00M;
  13304. // }
  13305. // }
  13306. //}
  13307. #endregion
  13308. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  13309. {
  13310. CurrencyCode = currCode,
  13311. Rate = _rate1,
  13312. CostType = item.CostType,
  13313. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  13314. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  13315. CostTypeNumber = item.CostTypenumber
  13316. };
  13317. if (_GroupCostParameters.Count > 1)
  13318. {
  13319. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  13320. }
  13321. else
  13322. {
  13323. modulePromptInfo.CostTypeNumber = item.LYJRS;
  13324. }
  13325. if (dto.CTable == 79)//
  13326. {
  13327. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  13328. modulePromptInfo.TotalCost = item.DJCB;
  13329. }
  13330. List<string> costTypes = new List<string>() { "A", "B" };
  13331. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  13332. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  13333. if (_GroupCostsDuplicates.Count() == 1)
  13334. {
  13335. _GroupCostsTypeData = _GroupCosts;
  13336. }
  13337. else
  13338. {
  13339. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  13340. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  13341. }
  13342. /*
  13343. * 76 酒店预订
  13344. * 77 行程
  13345. * 79 车/导游地接
  13346. * 80 签证
  13347. * 81 邀请/公务活动
  13348. * 82 团组客户保险
  13349. * 85 机票预订
  13350. * 98 其他款项
  13351. * 285 收款退还
  13352. * 751 酒店早餐
  13353. * 1015 超支费用
  13354. */
  13355. switch (dto.CTable)
  13356. {
  13357. case 76: // 酒店预订
  13358. _ModuleSubPromptInfo.AddRange(
  13359. _GroupCostsTypeData.Select(it => new
  13360. {
  13361. it.DAY,
  13362. it.Date,
  13363. it.ACCON,
  13364. it.ITIN,
  13365. it.SGR,
  13366. it.TBR,
  13367. it.JS_ES,
  13368. it.Suite
  13369. })
  13370. );
  13371. break;
  13372. case 79: // 车/导游地接
  13373. _ModuleSubPromptInfo.AddRange(
  13374. _GroupCostsTypeData.Select(it => new
  13375. {
  13376. Date = it.Date, //日期
  13377. CarFee = it.CarCost * _rate * _scale, //车费用
  13378. CarType = it.CarType, //车型
  13379. DriverFee = it.CFS * _rate * _scale, //司机工资
  13380. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  13381. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  13382. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  13383. GuideFee = it.TGS * _rate * _scale, //导游费用
  13384. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  13385. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  13386. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  13387. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  13388. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  13389. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  13390. Breakfast = it.B * _rate * _scale, //早餐费
  13391. Lunch = it.L * _rate * _scale, //午餐费
  13392. Dinner = it.D * _rate * _scale, //晚餐费
  13393. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  13394. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  13395. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  13396. TicketFee = it.EF * _rate * _scale, //门票费
  13397. TicketRemark = it.EFR, //门票费描述
  13398. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  13399. TravelSupplies = it.TE * _rate * _scale, //出行物资
  13400. SpentCash = it.PC * _rate * _scale, //零用金
  13401. LeadersFee = it.TLF * _rate * _scale, //领队费
  13402. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  13403. })
  13404. );
  13405. break;
  13406. case 85: // 机票
  13407. List<dynamic> datas = new List<dynamic>();
  13408. datas.Add(
  13409. new
  13410. {
  13411. AirType = "经济舱",
  13412. AirNum = item.JJCRS,
  13413. AirDRCB = item.JJCCB,
  13414. AirZCB = (item.JJCRS * item.JJCCB)
  13415. }
  13416. );
  13417. datas.Add(
  13418. new
  13419. {
  13420. AirType = "公务舱",
  13421. AirNum = item.GWCRS,
  13422. AirDRCB = item.GWCCB,
  13423. AirZCB = (item.GWCRS * item.GWCCB)
  13424. }
  13425. );
  13426. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13427. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  13428. modulePromptInfo.Data = new
  13429. {
  13430. airFeeData = datas,
  13431. airInitData = initDatas
  13432. };
  13433. _ModulePromptInfos.Add(modulePromptInfo);
  13434. break;
  13435. default:
  13436. break;
  13437. }
  13438. }
  13439. if (dto.CTable != 85)
  13440. {
  13441. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  13442. _ModulePromptInfos.Add(_ModulePromptInfo);
  13443. }
  13444. _view.ModulePromptInfos = _ModulePromptInfos;
  13445. return Ok(JsonView(true, "操作成功!", _view));
  13446. }
  13447. catch (Exception ex)
  13448. {
  13449. return Ok(JsonView(false, ex.Message));
  13450. }
  13451. }
  13452. /// <summary>
  13453. /// 根据黑屏代码重新生成行程
  13454. /// </summary>
  13455. /// <param name="dto"></param>
  13456. /// <returns></returns>
  13457. [HttpPost]
  13458. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  13459. {
  13460. var jw = JsonView(false);
  13461. var Create = _GroupCostRepository.
  13462. CreateGroupCostByBlackCode(dto.Diid);
  13463. jw.Msg = Create.Msg;
  13464. if (Create.Code == 0)
  13465. {
  13466. jw.Code = 200;
  13467. jw.Data = new
  13468. {
  13469. groupCost = Create.Data,
  13470. blackCodeIsTrue = true
  13471. };
  13472. }
  13473. else
  13474. {
  13475. jw.Code = 400;
  13476. jw.Data = new
  13477. {
  13478. groupCost = Create.Data,
  13479. blackCodeIsTrue = false,
  13480. };
  13481. }
  13482. return Ok(jw);
  13483. }
  13484. /// <summary>
  13485. /// 成本获取OP历史车费用
  13486. /// </summary>
  13487. /// <param name="dto"></param>
  13488. /// <returns></returns>
  13489. [HttpPost]
  13490. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  13491. {
  13492. var jw = JsonView(false);
  13493. try
  13494. {
  13495. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  13496. //获取现有所有车的数据
  13497. if (!dto.Param.IsNullOrWhiteSpace())
  13498. {
  13499. string sql = $@"
  13500. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  13501. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  13502. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  13503. 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
  13504. AND gctggr.ServiceEndTime is not NULL
  13505. ORDER by gctggrc.id DESC
  13506. ";
  13507. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  13508. var numeberResult = await Task.Run(() =>
  13509. {
  13510. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  13511. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  13512. return numberArr;
  13513. });
  13514. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  13515. foreach (var item in numeberResult)
  13516. {
  13517. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  13518. {
  13519. Country = "数据异常!",
  13520. City = string.Empty,
  13521. };
  13522. item.Area = find.Country + " " + find.City;
  13523. }
  13524. dbResult.AddRange(numeberResult);
  13525. if (dto.Param.Contains("、"))
  13526. {
  13527. var sp = dto.Param.Split("、");
  13528. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13529. .Where(x =>
  13530. {
  13531. return System.Array.Exists(sp, e =>
  13532. {
  13533. bool where = false;
  13534. if (x.Area != null)
  13535. {
  13536. where = x.Area.Contains(e);
  13537. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13538. {
  13539. return false;
  13540. }
  13541. }
  13542. if (x.PriceName != null && !where)
  13543. {
  13544. where = x.PriceName.Contains(e);
  13545. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13546. {
  13547. return false;
  13548. }
  13549. }
  13550. return where;
  13551. });
  13552. }).ToList();
  13553. }
  13554. else
  13555. {
  13556. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13557. .Where(x =>
  13558. {
  13559. bool where = false;
  13560. if (x.Area != null)
  13561. {
  13562. where = x.Area.Contains(dto.Param);
  13563. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13564. {
  13565. return false;
  13566. }
  13567. }
  13568. if (x.PriceName != null && !where)
  13569. {
  13570. where = x.PriceName.Contains(dto.Param);
  13571. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13572. {
  13573. return false;
  13574. }
  13575. }
  13576. return where;
  13577. }
  13578. )
  13579. .ToList();
  13580. }
  13581. }
  13582. var view = dbResult.Select(x =>
  13583. {
  13584. decimal dp = 0.00M;
  13585. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  13586. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  13587. if (string.IsNullOrWhiteSpace(x.DatePrice))
  13588. {
  13589. if (startB && endB)
  13590. {
  13591. var timesp = endD.Subtract(startD);
  13592. if ((timesp.Days + 1) != 0)
  13593. {
  13594. dp = x.Price / (timesp.Days + 1);
  13595. }
  13596. }
  13597. }
  13598. else
  13599. {
  13600. dp = x.Price;
  13601. }
  13602. return new
  13603. {
  13604. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  13605. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  13606. x.Area,
  13607. x.id,
  13608. price = x.Price.ToString("F2"),
  13609. x.PriceName,
  13610. x.PriceContent,
  13611. x.TeamName,
  13612. x.DatePrice,
  13613. dayPrice = dp.ToString("F2"),
  13614. };
  13615. }).OrderByDescending(x => x.id).ToList();
  13616. jw = JsonView(true, "获取成功!", view);
  13617. }
  13618. catch (Exception e)
  13619. {
  13620. jw = JsonView(false, e.Message);
  13621. }
  13622. return Ok(jw);
  13623. }
  13624. #endregion
  13625. #region 酒店预订 新 雷怡 2023-12-28 17:45
  13626. /// <summary>
  13627. /// 酒店预订
  13628. /// 酒店费用列表 根据团组Id查询
  13629. /// </summary>
  13630. /// <param name="_dto"></param>
  13631. /// <returns></returns>
  13632. [HttpPost]
  13633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13634. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  13635. {
  13636. #region 参数验证
  13637. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13638. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13639. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13640. #region 团组操作权限验证 76 酒店预定模块
  13641. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13642. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13643. #endregion
  13644. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13645. #region 页面操作权限验证
  13646. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13647. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13648. #endregion
  13649. #endregion
  13650. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  13651. }
  13652. /// <summary>
  13653. /// 酒店预订
  13654. /// 基础数据
  13655. /// </summary>
  13656. /// <param name="_dto"></param>
  13657. /// <returns></returns>
  13658. [HttpPost]
  13659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13660. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  13661. {
  13662. #region 参数验证
  13663. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13664. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13665. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13666. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13667. #region 页面操作权限验证
  13668. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13669. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13670. #endregion
  13671. #region 团组操作权限验证 76 酒店预定模块
  13672. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13673. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13674. #endregion
  13675. #endregion
  13676. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  13677. }
  13678. /// <summary>
  13679. /// 酒店预订
  13680. /// 创建 入住卷号码
  13681. /// </summary>
  13682. /// <param name="_dto"></param>
  13683. /// <returns></returns>
  13684. [HttpPost]
  13685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13686. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  13687. {
  13688. #region 参数验证
  13689. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13690. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13691. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13692. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13693. #region 页面操作权限验证
  13694. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13695. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13696. #endregion
  13697. #region 团组操作权限验证 76 酒店预定模块
  13698. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13699. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13700. #endregion
  13701. #endregion
  13702. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  13703. if (data.Code != 0)
  13704. {
  13705. return Ok(JsonView(false, data.Msg));
  13706. }
  13707. return Ok(JsonView(true, data.Msg, data.Data));
  13708. }
  13709. /// <summary>
  13710. /// 酒店预订
  13711. /// 详情
  13712. /// </summary>
  13713. /// <param name="_dto"></param>
  13714. /// <returns></returns>
  13715. [HttpPost]
  13716. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13717. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  13718. {
  13719. #region 参数验证
  13720. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  13721. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13722. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  13723. #region 团组操作权限验证 76 酒店预定模块
  13724. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13725. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13726. #endregion
  13727. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13728. #region 页面操作权限验证
  13729. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13730. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13731. #endregion
  13732. #endregion
  13733. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  13734. }
  13735. /// <summary>
  13736. /// 酒店预订
  13737. /// Add Or Edit
  13738. /// </summary>
  13739. /// <param name="_dto"></param>
  13740. /// <returns></returns>
  13741. [HttpPost]
  13742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13743. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  13744. {
  13745. #region 参数验证
  13746. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13747. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13748. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13749. #region 团组操作权限验证 76 酒店预定模块
  13750. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13751. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13752. #endregion
  13753. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13754. #region 页面操作权限验证
  13755. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13756. if (_dto.Id == 0) // Add
  13757. {
  13758. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13759. }
  13760. else if (_dto.Id > 1) // Edit
  13761. {
  13762. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  13763. }
  13764. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  13765. #endregion
  13766. #endregion
  13767. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  13768. if (_view.Code != 200)
  13769. {
  13770. return Ok(_view);
  13771. }
  13772. #region 成本无酒店价格数据进入超支
  13773. _sqlSugar.BeginTran();
  13774. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  13775. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  13776. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  13777. for (int i = 0; i < groupCost.Count; i++)
  13778. {
  13779. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  13780. {
  13781. groupCost[i].Date = groupCost[i - 1].Date;
  13782. }
  13783. }
  13784. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  13785. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  13786. List<Fin_GroupExtraCostDto_OP>();
  13787. if (start_Bool && end_Bool)
  13788. {
  13789. while (start_Time < end_Time)
  13790. {
  13791. foreach (var item in groupCost_Grp)
  13792. {
  13793. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  13794. {
  13795. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  13796. {
  13797. extraCostList.Add(new
  13798. Fin_GroupExtraCostDto_OP
  13799. {
  13800. Area = _dto.AreaId,
  13801. coefficient = 1.5M,
  13802. createUser = _dto.UserId,
  13803. currency = _dto.CardPriceCurrency,
  13804. diId = _dto.DiId,
  13805. ManagerConfirm = 0,
  13806. SupervisorConfirm = 0,
  13807. SYsupervisorConfirm = 0,
  13808. editType = 1,
  13809. PortType = 1,
  13810. price = _dto.CardPrice,
  13811. PriceCount = 1,
  13812. priceType = 1027,
  13813. priceDetailType = 1044,
  13814. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  13815. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  13816. });
  13817. }
  13818. }
  13819. }
  13820. start_Time = start_Time.AddDays(1);
  13821. }
  13822. }
  13823. if (extraCostList.Any())
  13824. {
  13825. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  13826. }
  13827. _sqlSugar.CommitTran();
  13828. #endregion
  13829. #region 应用推送
  13830. try
  13831. {
  13832. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  13833. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  13834. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  13835. var diId = _dto.DiId;
  13836. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13837. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13838. #region 操作记录
  13839. var opInfo = new Crm_TableOperationRecord() {
  13840. TableName = "Grp_HotelReservations",
  13841. PortType = _dto.PortType,
  13842. DataId = hotelId,
  13843. CreateUserId = _dto.UserId
  13844. };
  13845. var opStatus = OperationEnum.NoOperation;
  13846. if (_dto.Id<1) //添加操作
  13847. {
  13848. opInfo.OperationItem = OperationEnum.Add;
  13849. }
  13850. else if (_dto.Id > 0)
  13851. {
  13852. opInfo.OperationItem = OperationEnum.Edit;
  13853. }
  13854. string opRemark = string.Empty;
  13855. if (ccpInfo != null)
  13856. {
  13857. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  13858. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  13859. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  13860. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  13861. }
  13862. opInfo.Remark = opRemark;
  13863. await _tableorRep.AddAsync(opInfo);
  13864. #endregion
  13865. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  13866. //2024-10-21 新增LZ UID
  13867. var userIds = new List<int>() { 21 };
  13868. string title = $"费用审核";
  13869. string content = "";
  13870. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13871. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13872. try
  13873. {
  13874. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  13875. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  13876. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  13877. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  13878. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  13879. }
  13880. catch (Exception ex )
  13881. {
  13882. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  13883. }
  13884. }
  13885. catch (Exception ex)
  13886. {
  13887. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  13888. }
  13889. try
  13890. {
  13891. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  13892. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  13893. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  13894. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13895. //自动审核
  13896. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  13897. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  13898. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  13899. //2024-10-21 新增LZ UID
  13900. var userIds = new List<int>() { 21 };
  13901. string title = $"系统通知";
  13902. var diId = _dto.DiId;
  13903. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13904. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13905. string content = "";
  13906. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13907. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13908. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13909. }
  13910. catch (Exception ex)
  13911. {
  13912. }
  13913. #endregion
  13914. return Ok(_view);
  13915. }
  13916. /// <summary>
  13917. /// 酒店自动审核测试
  13918. /// Add Or Edit
  13919. /// </summary>
  13920. /// <param name="_dto"></param>
  13921. /// <returns></returns>
  13922. [HttpPost]
  13923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13924. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  13925. {
  13926. #region 应用推送
  13927. try
  13928. {
  13929. //自动审核
  13930. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  13931. }
  13932. catch (Exception ex)
  13933. {
  13934. return Ok(JsonView(false, "操作失败"));
  13935. }
  13936. #endregion
  13937. return Ok(JsonView(false, "操作成功"));
  13938. }
  13939. /// <summary>
  13940. /// 酒店预订
  13941. /// Del
  13942. /// </summary>
  13943. /// <param name="_dto"></param>
  13944. /// <returns></returns>
  13945. [HttpPost]
  13946. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13947. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  13948. {
  13949. #region 参数验证
  13950. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13951. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13952. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13953. #region 团组操作权限验证 76 酒店预定模块
  13954. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13955. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13956. #endregion
  13957. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13958. #region 页面操作权限验证
  13959. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13960. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  13961. #endregion
  13962. #endregion
  13963. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  13964. #region 操作记录
  13965. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  13966. {
  13967. TableName = "Grp_HotelReservations",
  13968. PortType = _dto.PortType,
  13969. OperationItem = OperationEnum.Del,
  13970. DataId = _dto.Id,
  13971. CreateUserId = _dto.UserId
  13972. });
  13973. #endregion
  13974. return Ok(data);
  13975. }
  13976. /// <summary>
  13977. /// 酒店预订
  13978. /// 生成VOUCHER
  13979. /// 2024.05.06 之前版本
  13980. /// </summary>
  13981. /// <param name="_dto"></param>
  13982. /// <returns></returns>
  13983. [HttpPost]
  13984. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13985. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  13986. {
  13987. try
  13988. {
  13989. #region 参数验证
  13990. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13991. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13992. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13993. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  13994. #region 团组操作权限验证 76 酒店预定模块
  13995. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13996. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13997. #endregion
  13998. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13999. #region 页面操作权限验证
  14000. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14001. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14002. #endregion
  14003. #endregion
  14004. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  14005. //判断数据是否完整
  14006. if (hr != null)
  14007. {
  14008. if (!string.IsNullOrEmpty(hr.DetermineNo))
  14009. {
  14010. string strFileName = "HotelStatement/";
  14011. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14012. if (dele != null)
  14013. strFileName += dele.TourCode;
  14014. //载入模板
  14015. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  14016. Document doc = new Document(sss);
  14017. DocumentBuilder builder = new DocumentBuilder(doc);
  14018. #region 替换Word模板书签内容
  14019. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  14020. //入住卷预定号码
  14021. if (doc.Range.Bookmarks["VNO"] != null)
  14022. {
  14023. Bookmark mark = doc.Range.Bookmarks["VNO"];
  14024. mark.Text = hr.CheckNumber;
  14025. }
  14026. //酒店时间
  14027. if (doc.Range.Bookmarks["Date"] != null)
  14028. {
  14029. Bookmark mark = doc.Range.Bookmarks["Date"];
  14030. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14031. }
  14032. //团号
  14033. if (doc.Range.Bookmarks["TNo"] != null)
  14034. {
  14035. Bookmark mark = doc.Range.Bookmarks["TNo"];
  14036. mark.Text = dele.TourCode;
  14037. }
  14038. //预定号码
  14039. if (doc.Range.Bookmarks["BookingId"] != null)
  14040. {
  14041. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  14042. mark.Text = hr.ReservationsNo;
  14043. }
  14044. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  14045. {
  14046. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  14047. mark.Text = hr.DetermineNo;
  14048. }
  14049. //酒店城市
  14050. if (doc.Range.Bookmarks["City"] != null)
  14051. {
  14052. Bookmark mark = doc.Range.Bookmarks["City"];
  14053. mark.Text = hr.City;
  14054. }
  14055. //酒店名称
  14056. if (doc.Range.Bookmarks["HName"] != null)
  14057. {
  14058. Bookmark mark = doc.Range.Bookmarks["HName"];
  14059. mark.Text = hr.HotelName;
  14060. }
  14061. //酒店地址
  14062. if (doc.Range.Bookmarks["Address"] != null)
  14063. {
  14064. Bookmark mark = doc.Range.Bookmarks["Address"];
  14065. mark.Text = hr.HotelAddress;
  14066. }
  14067. //酒店电话
  14068. if (doc.Range.Bookmarks["Tel"] != null)
  14069. {
  14070. Bookmark mark = doc.Range.Bookmarks["Tel"];
  14071. mark.Text = hr.HotelTel;
  14072. }
  14073. //酒店传真
  14074. if (doc.Range.Bookmarks["Fax"] != null)
  14075. {
  14076. Bookmark mark = doc.Range.Bookmarks["Fax"];
  14077. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  14078. {
  14079. mark.Text = hr.HotelFax;
  14080. }
  14081. }
  14082. //入住时间
  14083. if (doc.Range.Bookmarks["CIn"] != null)
  14084. {
  14085. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14086. Bookmark mark = doc.Range.Bookmarks["CIn"];
  14087. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  14088. }
  14089. //退房时间
  14090. if (doc.Range.Bookmarks["COut"] != null)
  14091. {
  14092. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14093. Bookmark mark = doc.Range.Bookmarks["COut"];
  14094. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14095. }
  14096. //客户名称
  14097. if (doc.Range.Bookmarks["GName"] != null)
  14098. {
  14099. string guestName = "";
  14100. string[] clients = new string[] { };
  14101. if (hr.GuestName.Contains(","))
  14102. {
  14103. clients = hr.GuestName.Split(",");
  14104. }
  14105. else
  14106. {
  14107. clients = new string[] { hr.GuestName };
  14108. }
  14109. List<int> clientIds_int = new List<int>();
  14110. if (clients.Length > 0)
  14111. {
  14112. foreach (var item in clients)
  14113. {
  14114. if (item.IsNumeric())
  14115. {
  14116. clientIds_int.Add(int.Parse(item));
  14117. }
  14118. }
  14119. }
  14120. if (clientIds_int.Count > 0)
  14121. {
  14122. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  14123. foreach (var client in _clientDatas)
  14124. {
  14125. //男
  14126. if (client.Sex == 0) guestName += $"Mr.";
  14127. //女
  14128. else if (client.Sex == 1) guestName += $"Ms.";
  14129. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  14130. {
  14131. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  14132. }
  14133. //guestName += $"{client.Pinyin},";
  14134. }
  14135. if (guestName.Length > 0)
  14136. {
  14137. guestName = guestName.Substring(0, guestName.Length - 1);
  14138. }
  14139. }
  14140. else
  14141. {
  14142. guestName = hr.GuestName;
  14143. }
  14144. Bookmark mark = doc.Range.Bookmarks["GName"];
  14145. mark.Text = guestName;
  14146. }
  14147. //房间介绍
  14148. if (doc.Range.Bookmarks["ROOM"] != null)
  14149. {
  14150. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  14151. mark.Text = hr.RoomExplanation;
  14152. }
  14153. //报价描述
  14154. if (doc.Range.Bookmarks["NOTE"] != null)
  14155. {
  14156. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  14157. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  14158. if (ss != null)
  14159. mark.Text = ss.Name;
  14160. }
  14161. //入住时间
  14162. if (doc.Range.Bookmarks["CheckIn"] != null)
  14163. {
  14164. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14165. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  14166. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14167. }
  14168. //退房时间
  14169. if (doc.Range.Bookmarks["CheckOut"] != null)
  14170. {
  14171. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14172. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  14173. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14174. }
  14175. //日期
  14176. if (doc.Range.Bookmarks["DT"] != null)
  14177. {
  14178. Bookmark mark = doc.Range.Bookmarks["DT"];
  14179. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14180. }
  14181. //名称
  14182. if (doc.Range.Bookmarks["VName"] != null)
  14183. {
  14184. Bookmark mark = doc.Range.Bookmarks["VName"];
  14185. mark.Text = hr.HotelName;
  14186. }
  14187. //号码
  14188. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  14189. {
  14190. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  14191. mark.Text = hr.CheckNumber;
  14192. }
  14193. #endregion
  14194. strFileName += "VOUCHER.doc";
  14195. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14196. doc.Save(fileDir);
  14197. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14198. return Ok(JsonView(true, "操作成功!", Url));
  14199. }
  14200. else
  14201. {
  14202. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  14203. }
  14204. }
  14205. else
  14206. {
  14207. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  14208. }
  14209. }
  14210. catch (Exception ex)
  14211. {
  14212. return Ok(JsonView(false, ex.Message));
  14213. }
  14214. }
  14215. /// <summary>
  14216. /// 酒店预订
  14217. /// 生成VOUCHER
  14218. /// 2024.05.06 之后版本
  14219. /// </summary>
  14220. /// <param name="_dto"></param>
  14221. /// <returns></returns>
  14222. [HttpPost]
  14223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14224. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  14225. {
  14226. #region 参数验证
  14227. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14228. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14229. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14230. #region 团组操作权限验证 76 酒店预定模块
  14231. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14232. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14233. #endregion
  14234. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14235. #region 页面操作权限验证
  14236. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14237. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14238. #endregion
  14239. #endregion
  14240. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  14241. //判断数据是否完整
  14242. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14243. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14244. string strFileName = "HotelStatement/";
  14245. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14246. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  14247. #region 数据处理
  14248. List<int> guestIds = new List<int>();
  14249. int index = 0;
  14250. foreach (var item in hrDtas)
  14251. {
  14252. if (item.GuestName.Contains(","))
  14253. {
  14254. string[] guestIdArr = item.GuestName.Split(',');
  14255. foreach (var guestIdStr in guestIdArr)
  14256. {
  14257. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  14258. if (guestBool)
  14259. {
  14260. guestIds.Add(guestId);
  14261. }
  14262. }
  14263. }
  14264. else guestNames += item.GuestName;
  14265. var voucherInfo = new HotelVoucherInfoView()
  14266. {
  14267. HotelName = item.HotelName,
  14268. CheckInDate = item.CheckInDate,
  14269. CheckOutDate = item.CheckOutDate,
  14270. ConfirmationNumber = item.DetermineNo.Trim(),
  14271. RoomType = item.RoomExplanation
  14272. };
  14273. vouchers.Add(voucherInfo);
  14274. }
  14275. if (guestIds.Count > 0)
  14276. {
  14277. guestIds = guestIds.Distinct().ToList();
  14278. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  14279. if (guestDatas.Count > 0)
  14280. {
  14281. guestNames = "";
  14282. foreach (var guest in guestDatas)
  14283. {
  14284. string guestName = "";
  14285. if (guest.Sex == 0) guestName += @"MR.";
  14286. else if (guest.Sex == 1) guestName += @"MS.";
  14287. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14288. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14289. guestNames += @$"{guestName.Trim()}、";
  14290. }
  14291. if (guestNames.Length > 0)
  14292. {
  14293. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14294. }
  14295. }
  14296. }
  14297. #endregion
  14298. //载入模板
  14299. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  14300. Document doc = new Document(sss);
  14301. DocumentBuilder builder = new DocumentBuilder(doc);
  14302. if (doc.Range.Bookmarks["GuestName"] != null)
  14303. {
  14304. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  14305. mark.Text = guestNames;
  14306. }
  14307. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14308. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  14309. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  14310. for (int i = 1; i <= vouchers.Count; i++)
  14311. {
  14312. HotelVoucherInfoView hviv = vouchers[i - 1];
  14313. builder.MoveToCell(0, i, 0, 0);
  14314. builder.Write(hviv.HotelName);
  14315. builder.MoveToCell(0, i, 1, 0);
  14316. builder.Write(hviv.CheckInDate);
  14317. builder.MoveToCell(0, i, 2, 0);
  14318. builder.Write(hviv.CheckOutDate);
  14319. builder.MoveToCell(0, i, 3, 0);
  14320. builder.Write(hviv.RoomType);
  14321. builder.MoveToCell(0, i, 4, 0);
  14322. builder.Write(hviv.ConfirmationNumber);
  14323. }
  14324. //删除多余行
  14325. int currRowIndex = vouchers.Count + 1;
  14326. int delRows = 21 - currRowIndex;
  14327. if (delRows > 0)
  14328. {
  14329. for (int i = 0; i < delRows; i++)
  14330. {
  14331. table.Rows.RemoveAt(currRowIndex);
  14332. //cultivateRowIndex++;
  14333. }
  14334. }
  14335. strFileName += "VOUCHER.docx";
  14336. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14337. doc.Save(fileDir);
  14338. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14339. return Ok(JsonView(true, "操作成功!", Url));
  14340. }
  14341. /// <summary>
  14342. /// 酒店预订
  14343. /// 生成VOUCHER 批量生成
  14344. /// New
  14345. /// </summary>
  14346. /// <param name="_dto"></param>
  14347. /// <returns></returns>
  14348. [HttpPost]
  14349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14350. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  14351. {
  14352. #region 参数验证
  14353. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14354. if (_dto.PageId < 1) _dto.PageId = 28;
  14355. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14356. #region 团组操作权限验证 76 酒店预定模块
  14357. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14358. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14359. #endregion
  14360. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14361. #region 页面操作权限验证
  14362. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14363. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14364. #endregion
  14365. #endregion
  14366. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  14367. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  14368. .OrderBy(x => x.CheckInDate)
  14369. .ToListAsync();
  14370. //判断数据是否完整
  14371. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14372. string strFileName = "HotelStatement/";
  14373. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14374. if (dele != null)
  14375. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  14376. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  14377. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  14378. .Where(it => it.IsDel == 0)
  14379. .ToListAsync();
  14380. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  14381. for (int i = 0; i < hrDtas.Count; i++)
  14382. {
  14383. string guestNames = string.Empty;
  14384. List<int> guestIds = new List<int>();
  14385. var item = hrDtas[i];
  14386. //处理客户姓名
  14387. if (item.GuestName.Contains(","))
  14388. {
  14389. string[] guestIdArr = item.GuestName.Split(',');
  14390. foreach (var guestIdStr in guestIdArr)
  14391. if (int.TryParse(guestIdStr, out int guestId))
  14392. guestIds.Add(guestId);
  14393. }
  14394. else
  14395. {
  14396. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  14397. if (guestIdBool)
  14398. {
  14399. guestIds.Add(guestId);
  14400. }
  14401. //NaN
  14402. if (item.GuestName.Contains("NaN"))
  14403. {
  14404. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  14405. }
  14406. }
  14407. if (guestIds.Count > 0)
  14408. {
  14409. guestIds = guestIds.Distinct().ToList();
  14410. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  14411. if (guestDatas1.Count > 0)
  14412. {
  14413. guestNames = "";
  14414. foreach (var guest in guestDatas1)
  14415. {
  14416. string guestName = "";
  14417. if (guest.Sex == 0) guestName += @"MR.";
  14418. else if (guest.Sex == 1) guestName += @"MS.";
  14419. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14420. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14421. guestNames += @$"{guestName.Trim()}、";
  14422. }
  14423. if (guestNames.Length > 0)
  14424. {
  14425. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14426. }
  14427. }
  14428. }
  14429. //if (!string.IsNullOrEmpty(guestNames))
  14430. //{
  14431. hrDtas[i].GuestName = guestNames;
  14432. //}
  14433. }
  14434. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  14435. Document doc = new Document();
  14436. DocumentBuilder builder = new DocumentBuilder(doc);
  14437. try
  14438. {
  14439. builder.MoveToDocumentStart();
  14440. foreach (var item in hrDtas)
  14441. {
  14442. //标题
  14443. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14444. builder.ParagraphFormat.LineSpacing = 1;
  14445. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14446. builder.ParagraphFormat.Style.Font.Size = 9;
  14447. builder.ParagraphFormat.Style.Font.Bold = true;
  14448. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14449. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  14450. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14451. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14452. builder.ParagraphFormat.LineSpacing = 1;
  14453. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14454. builder.ParagraphFormat.Style.Font.Size = 9;
  14455. builder.ParagraphFormat.Style.Font.Bold = true;
  14456. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  14457. builder.StartTable();
  14458. // 设置边框颜色
  14459. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  14460. //设置边框样式
  14461. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  14462. //表格
  14463. #region 第一行
  14464. builder.InsertCell();
  14465. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14466. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14467. //builder.CellFormat.AllowAutoFit = false;
  14468. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14469. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14470. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14471. builder.CellFormat.WrapText = true; //自动换行
  14472. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14473. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  14474. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14475. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14476. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14477. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14478. builder.Write("TOUR NO:");
  14479. builder.InsertCell();
  14480. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14481. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14482. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14483. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14484. builder.ParagraphFormat.Style.Font.Bold = false;
  14485. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14486. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14487. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14488. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14489. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14490. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14491. builder.Write($"{dele?.TourCode ?? "-"}");
  14492. builder.InsertCell();
  14493. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14494. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14495. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14496. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14497. builder.ParagraphFormat.Style.Font.Bold = false;
  14498. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14499. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14500. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14501. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14502. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14503. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14504. builder.Write($"CITY:");
  14505. builder.InsertCell();
  14506. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14507. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14508. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14509. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14510. builder.ParagraphFormat.Style.Font.Bold = false;
  14511. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14512. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14513. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14514. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14515. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14516. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14517. builder.Write($"{item.City}");
  14518. builder.EndRow();
  14519. #endregion
  14520. #region 第二行
  14521. builder.InsertCell();
  14522. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14523. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14524. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14525. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14526. builder.ParagraphFormat.Style.Font.Bold = false;
  14527. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14528. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14529. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14530. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14531. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14532. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14533. builder.Write("CONFIRMATION NO:");
  14534. builder.InsertCell();
  14535. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14536. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14537. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14538. builder.ParagraphFormat.Style.Font.Bold = false;
  14539. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14540. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14541. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14542. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14543. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14544. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14545. builder.CellFormat.VerticalMerge = CellMerge.None;
  14546. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14547. builder.Write($"{item.DetermineNo}");
  14548. builder.InsertCell();
  14549. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14550. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14551. builder.InsertCell();
  14552. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14553. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14554. builder.EndRow();
  14555. #endregion
  14556. #region 第三行
  14557. builder.InsertCell();
  14558. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14559. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14560. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14561. builder.ParagraphFormat.Style.Font.Bold = false;
  14562. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14563. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14564. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14565. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14566. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14567. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14568. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14569. builder.Write($"HOTEL NAME:");
  14570. builder.InsertCell();
  14571. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14572. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14573. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14574. builder.ParagraphFormat.Style.Font.Bold = false;
  14575. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14576. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14577. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14578. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14579. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14580. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14581. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14582. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14583. builder.Write($"{item.HotelName}");
  14584. builder.InsertCell();
  14585. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14586. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14587. builder.InsertCell();
  14588. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14589. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14590. builder.EndRow();
  14591. #endregion
  14592. #region 第四行
  14593. builder.InsertCell();
  14594. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14595. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14596. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14597. builder.ParagraphFormat.Style.Font.Bold = false;
  14598. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14599. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14600. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14601. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14602. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14603. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14604. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14605. builder.Write($"HOTEL ADDRESS:");
  14606. builder.InsertCell();
  14607. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14608. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14609. builder.ParagraphFormat.Style.Font.Size = 8;
  14610. builder.ParagraphFormat.Style.Font.Bold = false;
  14611. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14612. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14613. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14614. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14615. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14616. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14617. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14618. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14619. builder.Write($"{item.HotelAddress}");
  14620. builder.InsertCell();
  14621. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14622. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14623. builder.InsertCell();
  14624. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14625. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14626. builder.EndRow();
  14627. #endregion
  14628. #region 第五行
  14629. builder.InsertCell();
  14630. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14631. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14632. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14633. builder.ParagraphFormat.Style.Font.Bold = false;
  14634. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14635. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14636. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14637. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14638. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14639. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14640. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14641. builder.Write("TEL:");
  14642. builder.InsertCell();
  14643. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14644. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14645. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14646. builder.ParagraphFormat.Style.Font.Bold = false;
  14647. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14648. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14649. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14650. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14651. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14652. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14653. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14654. builder.Write($"{item.HotelTel}");
  14655. builder.InsertCell();
  14656. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14657. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14658. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14659. builder.ParagraphFormat.Style.Font.Bold = false;
  14660. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14661. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14662. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14663. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14664. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14665. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14666. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14667. builder.Write($"FAX:");
  14668. builder.InsertCell();
  14669. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14670. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14671. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14672. builder.ParagraphFormat.Style.Font.Bold = false;
  14673. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14674. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14675. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14676. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14677. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14678. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14679. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14680. builder.Write($"{item.HotelFax}");
  14681. builder.EndRow();
  14682. #endregion
  14683. #region 第六行
  14684. builder.InsertCell();
  14685. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14686. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14687. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14688. builder.ParagraphFormat.Style.Font.Bold = false;
  14689. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14690. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14691. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14692. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14693. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14694. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14695. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14696. builder.Write("CHECK IN:");
  14697. builder.InsertCell();
  14698. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14699. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14700. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14701. builder.ParagraphFormat.Style.Font.Bold = false;
  14702. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14703. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14704. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14705. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14706. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14707. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14708. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14709. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  14710. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14711. builder.Write($"{checkInStr}");
  14712. builder.InsertCell();
  14713. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14714. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14715. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14716. builder.ParagraphFormat.Style.Font.Bold = false;
  14717. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14718. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14719. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14720. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14721. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14722. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14723. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14724. builder.Write($"CHECK OUT:");
  14725. builder.InsertCell();
  14726. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14727. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14728. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14729. builder.ParagraphFormat.Style.Font.Bold = false;
  14730. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14731. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14732. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14733. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14734. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14735. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14736. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14737. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  14738. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  14739. builder.Write($"{checkOutStr}");
  14740. builder.EndRow();
  14741. #endregion
  14742. #region 第七行
  14743. builder.InsertCell();
  14744. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14745. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14746. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14747. builder.ParagraphFormat.Style.Font.Bold = false;
  14748. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14749. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14750. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14751. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14752. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14753. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14754. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14755. builder.Write($"GUEST NAME:");
  14756. builder.InsertCell();
  14757. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14758. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14759. builder.ParagraphFormat.Style.Font.Size = 8;
  14760. builder.ParagraphFormat.Style.Font.Bold = false;
  14761. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14762. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14763. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14764. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14765. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14766. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14767. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14768. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14769. builder.Write($"{item.GuestName}");
  14770. builder.InsertCell();
  14771. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14772. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14773. builder.InsertCell();
  14774. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14775. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14776. builder.EndRow();
  14777. #endregion
  14778. #region 第八行
  14779. builder.InsertCell();
  14780. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14781. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14782. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14783. builder.ParagraphFormat.Style.Font.Bold = false;
  14784. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14785. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14786. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14787. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14788. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14789. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14790. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14791. builder.Write($"ROOM TYPE:");
  14792. builder.InsertCell();
  14793. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14794. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14795. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14796. builder.ParagraphFormat.Style.Font.Bold = false;
  14797. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14798. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14799. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14800. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14801. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14802. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14803. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14804. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14805. builder.Write($"{item.RoomExplanation}");
  14806. builder.InsertCell();
  14807. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14808. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14809. builder.InsertCell();
  14810. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14811. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14812. builder.EndRow();
  14813. #endregion
  14814. #region 第九行
  14815. builder.InsertCell();
  14816. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14817. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14818. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14819. builder.ParagraphFormat.Style.Font.Bold = false;
  14820. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14821. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14822. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14823. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14824. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14825. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14826. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14827. builder.Write($"NOTE:");
  14828. builder.InsertCell();
  14829. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14830. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14831. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14832. builder.ParagraphFormat.Style.Font.Bold = false;
  14833. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14834. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14835. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14836. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14837. 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.");
  14838. builder.InsertCell();
  14839. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14840. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14841. builder.InsertCell();
  14842. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14843. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14844. builder.EndRow();
  14845. #endregion
  14846. builder.EndTable();
  14847. //换行
  14848. builder.Writeln("");
  14849. builder.Writeln("");
  14850. }
  14851. #region 获取文档中的所有表格 设置文字自适应
  14852. // 获取文档中的所有表格。
  14853. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14854. {
  14855. // 遍历表格中的所有行。
  14856. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14857. {
  14858. foreach (Cell cell in row.Cells)
  14859. {
  14860. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  14861. cellFormat.Width = 0;
  14862. }
  14863. }
  14864. }
  14865. #endregion
  14866. #region 设置页眉
  14867. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  14868. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  14869. if (System.IO.File.Exists(voucherHeaderPath))
  14870. {
  14871. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  14872. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  14873. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  14874. Shape shape = builder.InsertImage(imageBytes);
  14875. // 调整图片位置
  14876. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  14877. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  14878. shape.Top = 50; // 将图片距离页眉上边缘的距离
  14879. shape.Left = 0; // 将图片距离页面左边缘的距离
  14880. shape.Width = 81; // 设置图片宽度
  14881. shape.Height = 36; // 设置图片高度
  14882. }
  14883. //靠右
  14884. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  14885. //// 设置页脚上下边距
  14886. //builder.PageSetup.HeaderDistance = 42;
  14887. // 添加页眉线
  14888. Aspose.Words.Border borderHeader = null;
  14889. try
  14890. {
  14891. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  14892. }
  14893. catch (Exception e)
  14894. {
  14895. // TODO Auto-generated catch block
  14896. //e.printStackTrace();
  14897. }
  14898. borderHeader.Shadow = true;
  14899. borderHeader.DistanceFromText = 2;
  14900. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  14901. #endregion
  14902. }
  14903. catch (Exception ex)
  14904. {
  14905. }
  14906. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14907. doc.Save(fileDir);
  14908. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14909. return Ok(JsonView(true, "操作成功!", Url));
  14910. }
  14911. /// <summary>
  14912. /// 酒店预订
  14913. /// 生成 预定成本 Excel
  14914. /// </summary>
  14915. /// <param name="_dto"></param>
  14916. /// <returns></returns>
  14917. [HttpPost]
  14918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14919. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  14920. {
  14921. #region 参数验证
  14922. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  14923. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  14924. if (!vadalitorRes.IsValid)
  14925. {
  14926. var errors = new StringBuilder();
  14927. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  14928. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  14929. }
  14930. #region 团组操作权限验证 76 酒店预定模块
  14931. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14932. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14933. #endregion
  14934. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14935. #region 页面操作权限验证
  14936. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14937. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14938. #endregion
  14939. #endregion
  14940. decimal _rate = 1.00M;
  14941. string _currency = string.Empty;
  14942. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  14943. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  14944. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  14945. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  14946. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  14947. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  14948. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  14949. if (_GroupCostParameter == null)
  14950. {
  14951. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  14952. bool isIntType = int.TryParse(_currency, out int currId);
  14953. if (isIntType)
  14954. {
  14955. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  14956. }
  14957. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  14958. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  14959. if (currInfo == null)
  14960. {
  14961. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  14962. }
  14963. else _rate = currInfo.Rate;
  14964. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  14965. {
  14966. _rate = _GroupCostParameter.Rate;
  14967. }
  14968. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14969. string strFileName = "HotelStatement/";
  14970. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14971. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  14972. var rateDatas = new List<dynamic>();
  14973. #region 数据处理
  14974. foreach (var item in hrDtas)
  14975. {
  14976. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  14977. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  14978. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  14979. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  14980. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  14981. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  14982. {
  14983. continue;
  14984. }
  14985. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  14986. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  14987. string singleRoomFeeStr = string.Empty,
  14988. doubleRoomFeeStr = string.Empty,
  14989. suiteRoomFeeStr = string.Empty,
  14990. otherRoomFeeStr = string.Empty,
  14991. payMoneyStr = string.Empty,
  14992. cardPriceStr = string.Empty;
  14993. if (roomCurr.Equals("CNY"))
  14994. {
  14995. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  14996. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  14997. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  14998. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  14999. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15000. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  15001. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  15002. }
  15003. else
  15004. {
  15005. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15006. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15007. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15008. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15009. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15010. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15011. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15012. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15013. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15014. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15015. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  15016. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  15017. if (ccpPaymentCurrency.Equals("CNY"))
  15018. {
  15019. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  15020. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15021. }
  15022. else
  15023. {
  15024. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  15025. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  15026. }
  15027. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  15028. if (hotelcardPriceCurrency.Equals("CNY"))
  15029. {
  15030. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15031. }
  15032. else
  15033. {
  15034. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  15035. }
  15036. }
  15037. string breakfastPriceStr = string.Empty,
  15038. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15039. governmentRentStr = string.Empty,
  15040. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15041. cityTaxStr = string.Empty,
  15042. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15043. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  15044. if (!string.IsNullOrEmpty(breakfastCurrency1))
  15045. {
  15046. if (breakfastCurrency1.Equals("CNY"))
  15047. {
  15048. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15049. }
  15050. else
  15051. {
  15052. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  15053. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  15054. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  15055. }
  15056. }
  15057. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15058. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  15059. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  15060. {
  15061. if (governmentRentCurrency.Equals("CNY"))
  15062. {
  15063. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15064. }
  15065. else
  15066. {
  15067. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  15068. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  15069. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  15070. }
  15071. }
  15072. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15073. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  15074. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  15075. {
  15076. if (cityTaxStrCurrency1.Equals("CNY"))
  15077. {
  15078. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15079. }
  15080. else
  15081. {
  15082. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  15083. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  15084. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  15085. }
  15086. }
  15087. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15088. int payDId = roomInfo?.PayDId ?? 0;
  15089. pcfds.Add(new HotelReservations_PCFD_View()
  15090. {
  15091. City = item.City,
  15092. HotelName = item.HotelName,
  15093. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15094. // SingleRoomCount = item.SingleRoomCount,
  15095. SingleRoomPrice = singleRoomFeeStr,
  15096. // DoubleRoomCount = item.DoubleRoomCount,
  15097. DoubleRoomPrice = doubleRoomFeeStr,
  15098. //SuiteRoomCount = item.SuiteRoomCount,
  15099. SuiteRoomPrice = suiteRoomFeeStr,
  15100. OtherRoomPrice = otherRoomFeeStr,
  15101. //OtherRoomCount = item.OtherRoomCount,
  15102. BreakfastPrice = breakfastPriceStr,
  15103. GovernmentRent = governmentRentStr,
  15104. CityTax = cityTaxStr,
  15105. RoomExplanation = item.RoomExplanation,
  15106. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15107. PayTime = roomInfo?.ConsumptionDate,
  15108. BankNo = roomInfo?.BankNo,
  15109. PayMoney = payMoneyStr,
  15110. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15111. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15112. CardPrice = cardPriceStr,
  15113. Remark = ccpInfo.Remark
  15114. });
  15115. }
  15116. #endregion
  15117. //载入模板
  15118. WorkbookDesigner designer = new WorkbookDesigner();
  15119. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15120. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15121. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15122. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15123. var rateDatas1 = rateDatas.Distinct();
  15124. var rateStr = string.Empty;
  15125. foreach (var item in rateDatas1)
  15126. {
  15127. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  15128. }
  15129. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  15130. designer.SetDataSource("Opertor", userInfo.CnName);
  15131. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15132. dt.TableName = "ViewMyHotelReservations";
  15133. designer.SetDataSource(dt);
  15134. designer.Process();
  15135. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15136. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15137. designer.Workbook.Save(serverPath);
  15138. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15139. #region 删除指定行
  15140. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15141. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15142. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15143. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15144. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15145. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15146. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15147. cssIndex = dt.Columns["CityTax"].Ordinal,
  15148. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15149. remarkIndex = dt.Columns["Remark"].Ordinal;
  15150. //删除指定列
  15151. foreach (DataRow item in dt.Rows)
  15152. {
  15153. string singleStr = item["SingleRoomPrice"].ToString();
  15154. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15155. if (containsDigitButNotZero1) singleDel = false;
  15156. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15157. string doubleStr = item["DoubleRoomPrice"].ToString();
  15158. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15159. if (containsDigitButNotZero2) doubleDel = false;
  15160. string suiteStr = item["SuiteRoomPrice"].ToString();
  15161. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15162. if (containsDigitButNotZero3) suiteDel = false;
  15163. string otherStr = item["OtherRoomPrice"].ToString();
  15164. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15165. if (containsDigitButNotZero4) otherDel = false;
  15166. string zcStr = item["BreakfastPrice"].ToString();
  15167. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15168. if (containsDigitButNotZero5) zcDel = false;
  15169. string dsStr = item["GovernmentRent"].ToString();
  15170. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15171. if (containsDigitButNotZero6) dsDel = false;
  15172. string cssStr = item["CityTax"].ToString();
  15173. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15174. if (containsDigitButNotZero7) cssDel = false;
  15175. string cpStr = item["ConsumptionPatterns"].ToString();
  15176. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15177. string remarkStr = item["Remark"].ToString();
  15178. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15179. }
  15180. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15181. DeleteColumn(serverPath, cpIndex, cpDel);
  15182. DeleteColumn(serverPath, dsIndex, dsDel);
  15183. DeleteColumn(serverPath, cssIndex, cssDel);
  15184. DeleteColumn(serverPath, zcIndex, zcDel);
  15185. DeleteColumn(serverPath, otherIndex, otherDel);
  15186. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15187. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15188. DeleteColumn(serverPath, singleIndex, singleDel);
  15189. #endregion
  15190. //只保留第一个表格
  15191. DeleteSheet(serverPath);
  15192. return Ok(JsonView(true, "操作成功", url = rst));
  15193. }
  15194. else
  15195. {
  15196. _currency = _GroupCostParameter.Currency;
  15197. bool isIntType = int.TryParse(_currency, out int currId);
  15198. if (isIntType)
  15199. {
  15200. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15201. }
  15202. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15203. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15204. if (currInfo == null)
  15205. {
  15206. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15207. }
  15208. if (!_currency.ToUpper().Equals("CNY"))
  15209. {
  15210. _rate = _GroupCostParameter.Rate;
  15211. }
  15212. _rate = currInfo.Rate;
  15213. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15214. //string strFileName = "HotelStatement/";
  15215. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15216. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15217. #region 数据处理
  15218. foreach (var item in hrDtas)
  15219. {
  15220. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15221. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15222. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15223. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15224. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15225. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15226. string singleRoomFeeStr = string.Empty,
  15227. doubleRoomFeeStr = string.Empty,
  15228. suiteRoomFeeStr = string.Empty,
  15229. otherRoomFeeStr = string.Empty,
  15230. payMoneyStr = string.Empty,
  15231. cardPriceStr = string.Empty;
  15232. if (roomCurr.Equals(_currency))
  15233. {
  15234. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  15235. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  15236. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  15237. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  15238. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  15239. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  15240. }
  15241. else
  15242. {
  15243. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15244. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15245. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15246. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15247. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15248. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15249. }
  15250. string breakfastPriceStr = string.Empty,
  15251. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15252. governmentRentStr = string.Empty,
  15253. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15254. cityTaxStrStr = string.Empty,
  15255. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15256. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  15257. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  15258. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  15259. int payDId = roomInfo?.PayDId ?? 0;
  15260. pcfds.Add(new HotelReservations_PCFD_View()
  15261. {
  15262. City = item.City,
  15263. HotelName = item.HotelName,
  15264. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15265. // SingleRoomCount = item.SingleRoomCount,
  15266. SingleRoomPrice = singleRoomFeeStr,
  15267. // DoubleRoomCount = item.DoubleRoomCount,
  15268. DoubleRoomPrice = doubleRoomFeeStr,
  15269. //SuiteRoomCount = item.SuiteRoomCount,
  15270. SuiteRoomPrice = suiteRoomFeeStr,
  15271. OtherRoomPrice = otherRoomFeeStr,
  15272. //OtherRoomCount = item.OtherRoomCount,
  15273. BreakfastPrice = breakfastPriceStr,
  15274. GovernmentRent = governmentRentStr,
  15275. CityTax = cityTaxStrStr,
  15276. RoomExplanation = item.RoomExplanation,
  15277. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15278. PayTime = roomInfo?.ConsumptionDate,
  15279. BankNo = roomInfo?.BankNo,
  15280. PayMoney = payMoneyStr,
  15281. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15282. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15283. CardPrice = cardPriceStr,
  15284. Remark = ccpInfo.Remark
  15285. });
  15286. }
  15287. #endregion
  15288. //载入模板
  15289. WorkbookDesigner designer = new WorkbookDesigner();
  15290. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15291. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15292. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15293. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15294. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  15295. designer.SetDataSource("Opertor", userInfo.CnName);
  15296. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15297. dt.TableName = "ViewMyHotelReservations";
  15298. designer.SetDataSource(dt);
  15299. designer.Process();
  15300. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15301. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15302. designer.Workbook.Save(serverPath);
  15303. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15304. #region 删除指定行
  15305. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15306. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15307. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15308. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15309. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15310. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15311. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15312. cssIndex = dt.Columns["CityTax"].Ordinal,
  15313. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15314. remarkIndex = dt.Columns["Remark"].Ordinal;
  15315. //删除指定列
  15316. foreach (DataRow item in dt.Rows)
  15317. {
  15318. string singleStr = item["SingleRoomPrice"].ToString();
  15319. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15320. if (containsDigitButNotZero1) singleDel = false;
  15321. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15322. string doubleStr = item["DoubleRoomPrice"].ToString();
  15323. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15324. if (containsDigitButNotZero2) doubleDel = false;
  15325. string suiteStr = item["SuiteRoomPrice"].ToString();
  15326. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15327. if (containsDigitButNotZero3) suiteDel = false;
  15328. string otherStr = item["OtherRoomPrice"].ToString();
  15329. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15330. if (containsDigitButNotZero4) otherDel = false;
  15331. string zcStr = item["BreakfastPrice"].ToString();
  15332. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15333. if (containsDigitButNotZero5) zcDel = false;
  15334. string dsStr = item["GovernmentRent"].ToString();
  15335. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15336. if (containsDigitButNotZero6) dsDel = false;
  15337. string cssStr = item["CityTax"].ToString();
  15338. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15339. if (containsDigitButNotZero7) cssDel = false;
  15340. string cpStr = item["ConsumptionPatterns"].ToString();
  15341. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15342. string remarkStr = item["Remark"].ToString();
  15343. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15344. }
  15345. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15346. DeleteColumn(serverPath, cpIndex, cpDel);
  15347. DeleteColumn(serverPath, dsIndex, dsDel);
  15348. DeleteColumn(serverPath, cssIndex, cssDel);
  15349. DeleteColumn(serverPath, zcIndex, zcDel);
  15350. DeleteColumn(serverPath, otherIndex, otherDel);
  15351. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15352. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15353. DeleteColumn(serverPath, singleIndex, singleDel);
  15354. #endregion
  15355. //只保留第一个表格
  15356. DeleteSheet(serverPath);
  15357. return Ok(JsonView(true, "操作成功", url = rst));
  15358. }
  15359. return Ok(JsonView(false));
  15360. }
  15361. /// <summary>
  15362. /// 删除指定列
  15363. /// </summary>
  15364. /// <param name="file"></param>
  15365. /// <param name="columnIndex"></param>
  15366. /// <param name="isDel"></param>
  15367. private void DeleteColumn(string file, int columnIndex, bool isDel)
  15368. {
  15369. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15370. //wb.Save(file);
  15371. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  15372. if (sheet1 != null)
  15373. {
  15374. if (isDel)
  15375. {
  15376. Cells cells = sheet1.Cells;
  15377. cells.DeleteColumn(columnIndex);
  15378. }
  15379. }
  15380. wb.Save(file);
  15381. }
  15382. /// <summary>
  15383. /// 删除sheet
  15384. /// </summary>
  15385. /// <param name="file"></param>
  15386. /// <param name="sheetName"></param>
  15387. private void DeleteSheet(string file, string sheetName = "")
  15388. {
  15389. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15390. //wb.Save(file);
  15391. List<string> sheets = new List<string>();
  15392. foreach (var item in wb.Worksheets)
  15393. {
  15394. sheets.Add(item.Name);
  15395. }
  15396. if (sheets.Count > 0)
  15397. {
  15398. sheets.RemoveAt(0);//不删除第一个sheet
  15399. foreach (var item in sheets)
  15400. {
  15401. wb.Worksheets.RemoveAt(item);
  15402. }
  15403. }
  15404. wb.Save(file);
  15405. }
  15406. /// <summary>
  15407. /// 酒店预订
  15408. /// 确认单
  15409. /// </summary>
  15410. /// <param name="_dto"></param>
  15411. /// <returns></returns>
  15412. [HttpPost]
  15413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15414. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  15415. {
  15416. try
  15417. {
  15418. #region 参数验证
  15419. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15420. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15421. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15422. #region 团组操作权限验证 76 酒店预定模块
  15423. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15424. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15425. #endregion
  15426. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15427. #region 页面操作权限验证
  15428. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15429. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15430. #endregion
  15431. #endregion
  15432. //团组信息
  15433. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  15434. //酒店数据
  15435. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  15436. if (listhoteldata.Count < 0)
  15437. {
  15438. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  15439. }
  15440. //利datatable存储
  15441. DataTable dt = new DataTable();
  15442. dt.Columns.Add("CheckInDate", typeof(string));
  15443. dt.Columns.Add("City", typeof(string));
  15444. dt.Columns.Add("Hotel", typeof(string));
  15445. dt.Columns.Add("Room", typeof(string));
  15446. for (int i = 0; i < listhoteldata.Count; i++)
  15447. {
  15448. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  15449. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  15450. while (dayStart < dayEnd)
  15451. {
  15452. string temp = "";
  15453. DataRow row = dt.NewRow();
  15454. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  15455. row["City"] = listhoteldata[i].City;
  15456. row["Hotel"] = listhoteldata[i].HotelName;
  15457. if (listhoteldata[i].SingleRoomCount > 0)
  15458. {
  15459. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  15460. }
  15461. if (listhoteldata[i].DoubleRoomCount > 0)
  15462. {
  15463. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  15464. }
  15465. if (listhoteldata[i].SuiteRoomCount > 0)
  15466. {
  15467. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  15468. }
  15469. if (listhoteldata[i].OtherRoomCount > 0)
  15470. {
  15471. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  15472. }
  15473. row["Room"] = temp;
  15474. dt.Rows.Add(row);
  15475. dayStart = dayStart.AddDays(1);
  15476. }
  15477. }
  15478. Dictionary<string, string> dic = new Dictionary<string, string>();
  15479. dic.Add("Dele", di.TeamName);
  15480. dic.Add("City", di.VisitCountry);
  15481. //模板路径
  15482. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  15483. //载入模板
  15484. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  15485. DocumentBuilder builder = new DocumentBuilder(doc);
  15486. foreach (var key in dic.Keys)
  15487. {
  15488. builder.MoveToBookmark(key);
  15489. builder.Write(dic[key]);
  15490. }
  15491. //获取word里所有表格
  15492. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15493. //获取所填表格的序数
  15494. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  15495. var rowStart = tableOne.Rows[0]; //获取第1行
  15496. //循环赋值
  15497. for (int i = 0; i < dt.Rows.Count; i++)
  15498. {
  15499. builder.MoveToCell(0, i + 1, 0, 0);
  15500. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  15501. builder.MoveToCell(0, i + 1, 1, 0);
  15502. builder.Write(dt.Rows[i]["City"].ToString());
  15503. builder.MoveToCell(0, i + 1, 2, 0);
  15504. builder.Write(dt.Rows[i]["Hotel"].ToString());
  15505. builder.MoveToCell(0, i + 1, 3, 0);
  15506. builder.Write(dt.Rows[i]["Room"].ToString());
  15507. }
  15508. //删除多余行
  15509. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  15510. {
  15511. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  15512. }
  15513. string strFileName = di.TeamName + "酒店确认单.doc";
  15514. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  15515. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  15516. return Ok(JsonView(true, "成功", url));
  15517. }
  15518. catch (Exception ex)
  15519. {
  15520. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  15521. }
  15522. }
  15523. #endregion
  15524. #region 团组状态
  15525. /// <summary>
  15526. /// 团组状态列表 Page
  15527. /// </summary>
  15528. /// <param name="dto">团组列表请求dto</param>
  15529. /// <returns></returns>
  15530. [HttpPost]
  15531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15532. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  15533. {
  15534. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15535. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  15536. {
  15537. string sqlWhere = string.Empty;
  15538. if (dto.IsSure == 0) //未完成
  15539. {
  15540. sqlWhere += string.Format(@" And IsSure = 0");
  15541. }
  15542. else if (dto.IsSure == 1) //已完成
  15543. {
  15544. sqlWhere += string.Format(@" And IsSure = 1");
  15545. }
  15546. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  15547. {
  15548. string tj = dto.SearchCriteria;
  15549. 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}%')",
  15550. tj, tj, tj, tj, tj);
  15551. }
  15552. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  15553. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  15554. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  15555. From (
  15556. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  15557. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  15558. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  15559. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  15560. From Grp_DelegationInfo gdi
  15561. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  15562. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  15563. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  15564. Where gdi.IsDel = 0 {0}
  15565. ) temp ", sqlWhere);
  15566. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  15567. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  15568. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  15569. }
  15570. else
  15571. {
  15572. return Ok(JsonView(false, "查询失败"));
  15573. }
  15574. }
  15575. /// <summary>
  15576. /// 团组状态
  15577. /// 设置操作完成
  15578. /// </summary>
  15579. /// <param name="dto">团组列表请求dto</param>
  15580. /// <returns></returns>
  15581. [HttpPost]
  15582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15583. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  15584. {
  15585. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15586. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  15587. {
  15588. Id = dto.Id,
  15589. IsSure = 1
  15590. };
  15591. var result = await _sqlSugar.Updateable(_DelegationInfo)
  15592. .UpdateColumns(it => new { it.IsSure })
  15593. .WhereColumns(it => new { it.Id })
  15594. .ExecuteCommandAsync();
  15595. if (result > 0)
  15596. {
  15597. return Ok(JsonView(true, "操作完成!"));
  15598. }
  15599. return Ok(JsonView(false, "操作失败!"));
  15600. }
  15601. #endregion
  15602. #region 保险费用录入
  15603. /// <summary>
  15604. /// 根据团组Id查询保险费用列表
  15605. /// </summary>
  15606. /// <param name="dto"></param>
  15607. /// <returns></returns>
  15608. [HttpPost]
  15609. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15610. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  15611. {
  15612. Result groupData = await _customersRep.CustomersByDiId(dto);
  15613. if (groupData.Code != 0)
  15614. {
  15615. return Ok(JsonView(false, groupData.Msg));
  15616. }
  15617. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15618. }
  15619. /// <summary>
  15620. /// 根据保险费用Id查询保险费用详细
  15621. /// </summary>
  15622. /// <param name="dto"></param>
  15623. /// <returns></returns>
  15624. [HttpPost]
  15625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15626. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  15627. {
  15628. try
  15629. {
  15630. Result groupData = await _customersRep.CustomersById(dto);
  15631. if (groupData.Code != 0)
  15632. {
  15633. return Ok(JsonView(false, groupData.Msg));
  15634. }
  15635. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15636. }
  15637. catch (Exception ex)
  15638. {
  15639. return Ok(JsonView(false, ex.Message));
  15640. }
  15641. }
  15642. /// <summary>
  15643. /// 保险费用录入页面初始化绑定
  15644. /// </summary>
  15645. /// <param name="dto"></param>
  15646. /// <returns></returns>
  15647. [HttpPost]
  15648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15649. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  15650. {
  15651. try
  15652. {
  15653. Result groupData = await _customersRep.CustomersInitialize(dto);
  15654. if (groupData.Code != 0)
  15655. {
  15656. return Ok(JsonView(false, groupData.Msg));
  15657. }
  15658. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15659. }
  15660. catch (Exception ex)
  15661. {
  15662. return Ok(JsonView(false, ex.Message));
  15663. }
  15664. }
  15665. /// <summary>
  15666. /// 保险费用操作(Status:1.新增,2.修改)
  15667. /// </summary>
  15668. /// <param name="dto"></param>
  15669. /// <returns></returns>
  15670. [HttpPost]
  15671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15672. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  15673. {
  15674. Result groupData = await _customersRep.OpCustomers(dto);
  15675. if (groupData.Code != 0)
  15676. {
  15677. return Ok(JsonView(false, groupData.Msg));
  15678. }
  15679. #region 应用推送
  15680. try
  15681. {
  15682. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  15683. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  15684. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  15685. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  15686. //自动审核
  15687. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  15688. //2024-10-21 新增LZ UID
  15689. var userIds = new List<int>() { 21 };
  15690. string title = $"系统通知";
  15691. var diId = dto.DiId;
  15692. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15693. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15694. string content = "";
  15695. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15696. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15697. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  15698. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  15699. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  15700. }
  15701. catch (Exception ex)
  15702. {
  15703. }
  15704. #endregion
  15705. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15706. }
  15707. /// <summary>
  15708. /// 保险文件上传
  15709. /// </summary>
  15710. /// <param name="file"></param>
  15711. /// <returns></returns>
  15712. [HttpPost]
  15713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15714. public async Task<IActionResult> UploadCus(IFormFile file)
  15715. {
  15716. try
  15717. {
  15718. if (file != null)
  15719. {
  15720. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15721. //文件名称
  15722. string projectFileName = file.FileName;
  15723. //上传的文件的路径
  15724. string filePath = "";
  15725. if (!Directory.Exists(fileDir))
  15726. {
  15727. Directory.CreateDirectory(fileDir);
  15728. }
  15729. //上传的文件的路径
  15730. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  15731. using (FileStream fs = System.IO.File.Create(filePath))
  15732. {
  15733. file.CopyTo(fs);
  15734. fs.Flush();
  15735. }
  15736. return Ok(JsonView(true, "上传成功!", projectFileName));
  15737. }
  15738. else
  15739. {
  15740. return Ok(JsonView(false, "上传失败!"));
  15741. }
  15742. }
  15743. catch (Exception ex)
  15744. {
  15745. return Ok(JsonView(false, "程序错误!"));
  15746. throw;
  15747. }
  15748. }
  15749. /// <summary>
  15750. /// 保险删除指定文件
  15751. /// </summary>
  15752. /// <param name="dto"></param>
  15753. /// <returns></returns>
  15754. [HttpPost]
  15755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15756. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  15757. {
  15758. try
  15759. {
  15760. string filePath = "";
  15761. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15762. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  15763. //int id = 0;
  15764. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  15765. // 删除该文件
  15766. try
  15767. {
  15768. System.IO.File.Delete(filePath);
  15769. 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()
  15770. {
  15771. Attachment = "",
  15772. }).ExecuteCommandAsync();
  15773. if (result != 0)
  15774. {
  15775. return Ok(JsonView(true, "成功!"));
  15776. }
  15777. else
  15778. {
  15779. return Ok(JsonView(false, "失败!"));
  15780. }
  15781. }
  15782. catch (Exception)
  15783. {
  15784. 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()
  15785. {
  15786. Attachment = "",
  15787. }).ExecuteCommandAsync();
  15788. if (result != 0)
  15789. {
  15790. return Ok(JsonView(true, "成功!"));
  15791. }
  15792. else
  15793. {
  15794. return Ok(JsonView(false, "失败!"));
  15795. }
  15796. }
  15797. }
  15798. catch (Exception ex)
  15799. {
  15800. return Ok(JsonView(false, "程序错误!"));
  15801. throw;
  15802. }
  15803. }
  15804. /// <summary>
  15805. /// 保险费用操作(删除)
  15806. /// </summary>
  15807. /// <param name="dto"></param>
  15808. /// <returns></returns>
  15809. [HttpPost]
  15810. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15811. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  15812. {
  15813. try
  15814. {
  15815. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  15816. if (!res)
  15817. {
  15818. return Ok(JsonView(false, "删除失败"));
  15819. }
  15820. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  15821. {
  15822. IsDel = 1,
  15823. DeleteUserId = dto.DeleteUserId,
  15824. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  15825. }).ExecuteCommandAsync();
  15826. return Ok(JsonView(true, "删除成功!"));
  15827. }
  15828. catch (Exception ex)
  15829. {
  15830. return Ok(JsonView(false, "程序错误!"));
  15831. throw;
  15832. }
  15833. }
  15834. #endregion
  15835. #region 接团客户名单 PageId 104
  15836. /// <summary>
  15837. /// 接团客户名单
  15838. /// 迁移数据(慎用!)
  15839. /// </summary>
  15840. /// <param name="dto"></param>
  15841. /// <returns></returns>
  15842. [HttpPost]
  15843. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15844. public async Task<IActionResult> PostTourClientListChange()
  15845. {
  15846. try
  15847. {
  15848. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  15849. //var groupClinetData1
  15850. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  15851. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  15852. int updateCount = 0;
  15853. if (oldOAClientList.Count > 0)
  15854. {
  15855. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  15856. _sqlSugar.BeginTran();
  15857. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  15858. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  15859. foreach (var item in oldOAClientList)
  15860. {
  15861. int comId = 0;
  15862. string format = "yyyy-MM-dd HH:mm:ss";
  15863. string data11 = "1990-01-01 00:00";
  15864. var data1 = IsValidDate(item.OPdate, format);
  15865. if (data1) data11 = item.OPdate;
  15866. //客户公司验证
  15867. if (!string.IsNullOrEmpty(item.Company))
  15868. {
  15869. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  15870. if (clientComInfo == null) // add
  15871. {
  15872. var addInfo = new Crm_CustomerCompany()
  15873. {
  15874. CompanyAbbreviation = "",
  15875. CompanyFullName = item.Company,
  15876. Address = "",
  15877. PostCodes = "",
  15878. LastedOpUserId = item.OPer,
  15879. LastedOpDt = Convert.ToDateTime(data11),
  15880. CreateUserId = item.OPer,
  15881. CreateTime = Convert.ToDateTime(data11),
  15882. IsDel = 0
  15883. };
  15884. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  15885. if (comId1 > 0) comId = comId1;
  15886. }
  15887. else comId = clientComInfo.Id;
  15888. }
  15889. //客户人员验证
  15890. int clientId = 0;
  15891. string name = item.LastName + item.Name;
  15892. if (!string.IsNullOrEmpty(name))
  15893. {
  15894. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  15895. if (clientInfo == null)
  15896. {
  15897. DateTime? dateTime = null;
  15898. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  15899. if (isDt) dateTime = birthDayDt;
  15900. var addInfo1 = new Crm_DeleClient()
  15901. {
  15902. CrmCompanyId = comId,
  15903. DiId = -1,
  15904. LastName = item.LastName,
  15905. FirstName = item.Name,
  15906. OldName = "",
  15907. Pinyin = item.Pinyin,
  15908. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  15909. Marriage = 0,
  15910. Phone = item.Phone,
  15911. Job = item.Job,
  15912. BirthDay = dateTime
  15913. };
  15914. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  15915. if (clientId1 > 0) clientId = clientId1;
  15916. }
  15917. else clientId = clientInfo.Id;
  15918. }
  15919. if (clientId < 1)
  15920. {
  15921. continue;
  15922. }
  15923. int airType = 0;
  15924. if (item.AirType == "超经舱") airType = 459;
  15925. else if (item.AirType == "公务舱") airType = 458;
  15926. else if (item.AirType == "经济舱") airType = 460;
  15927. else if (item.AirType == "其他") airType = 565;
  15928. else if (item.AirType == "头等舱") airType = 457;
  15929. var _TourClientListEntity = new Grp_TourClientList()
  15930. {
  15931. DiId = item.Diid,
  15932. ClientId = clientId,
  15933. CreateUserId = item.OPer,
  15934. CreateTime = Convert.ToDateTime(data11),
  15935. Remark = item.Remark,
  15936. IsDel = item.Isdel,
  15937. ShippingSpaceTypeId = airType,
  15938. ShippingSpaceSpecialNeeds = item.AirRemark,
  15939. HotelSpecialNeeds = item.RoomType
  15940. };
  15941. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  15942. if (_TourClientList > 0)
  15943. {
  15944. updateCount++;
  15945. }
  15946. }
  15947. _sqlSugar.CommitTran();
  15948. }
  15949. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  15950. }
  15951. catch (Exception ex)
  15952. {
  15953. _sqlSugar.RollbackTran();
  15954. return Ok(JsonView(false, ex.Message));
  15955. }
  15956. return Ok(JsonView(true));
  15957. }
  15958. private bool IsValidDate(string dateString, string format)
  15959. {
  15960. DateTime dateValue;
  15961. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  15962. return valid;
  15963. }
  15964. /// <summary>
  15965. /// 接团客户名单
  15966. /// 根据团组Id查询List
  15967. /// </summary>
  15968. /// <param name="dto"></param>
  15969. /// <returns></returns>
  15970. [HttpPost]
  15971. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15972. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  15973. {
  15974. #region 参数验证
  15975. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  15976. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  15977. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  15978. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15979. #region 页面操作权限验证
  15980. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15981. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15982. #endregion
  15983. #endregion
  15984. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  15985. if (viewData.Code != 0)
  15986. {
  15987. return Ok(JsonView(false, viewData.Msg));
  15988. }
  15989. return Ok(JsonView(viewData.Data));
  15990. }
  15991. /// <summary>
  15992. /// 接团客户名单
  15993. /// 基础数据 Init
  15994. /// </summary>
  15995. /// <param name="_dto"></param>
  15996. /// <returns></returns>
  15997. [HttpPost]
  15998. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15999. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  16000. {
  16001. #region 参数验证
  16002. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16003. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16004. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16005. #region 页面操作权限验证
  16006. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16007. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16008. #endregion
  16009. #endregion
  16010. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  16011. }
  16012. /// <summary>
  16013. /// 接团客户名单
  16014. /// 根据 Id查询 Details
  16015. /// </summary>
  16016. /// <param name="_dto"></param>
  16017. /// <returns></returns>
  16018. [HttpPost]
  16019. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16020. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  16021. {
  16022. #region 参数验证
  16023. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16024. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16025. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16026. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16027. #region 页面操作权限验证
  16028. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16029. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16030. #endregion
  16031. #endregion
  16032. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  16033. if (viewData.Code != 0)
  16034. {
  16035. return Ok(JsonView(false, viewData.Msg));
  16036. }
  16037. return Ok(JsonView(viewData.Data));
  16038. }
  16039. /// <summary>
  16040. /// 接团客户名单
  16041. /// Add Or Edit
  16042. /// </summary>
  16043. /// <param name="_dto"></param>
  16044. /// <returns></returns>
  16045. [HttpPost]
  16046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16047. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  16048. {
  16049. #region 参数验证
  16050. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16051. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16052. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16053. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16054. #region 页面操作权限验证
  16055. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16056. if (_dto.Id == 0) //添加
  16057. {
  16058. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16059. }
  16060. else if (_dto.Id >= 0) //修改
  16061. {
  16062. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16063. }
  16064. #endregion
  16065. #endregion
  16066. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  16067. if (viewData.Code != 0)
  16068. {
  16069. return Ok(JsonView(false, viewData.Msg));
  16070. }
  16071. return Ok(JsonView(true));
  16072. }
  16073. /// <summary>
  16074. /// 接团客户名单
  16075. /// json字符串 AddMultiple(添加多个)
  16076. /// </summary>
  16077. /// <param name="_dto"></param>
  16078. /// <returns></returns>
  16079. [HttpPost]
  16080. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16081. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  16082. {
  16083. #region 参数验证
  16084. string jsonLabel = _dto.JsonLabel;
  16085. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16086. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16087. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16088. #region 页面操作权限验证
  16089. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16090. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16091. #endregion
  16092. #endregion
  16093. var request = new TourClientListAddMultipleDto();
  16094. request.DiId = _dto.DiId;
  16095. request.UserId = _dto.UserId;
  16096. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  16097. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  16098. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  16099. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  16100. var infos = new List<TourClientListInfo>();
  16101. foreach (var data in datas)
  16102. {
  16103. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  16104. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  16105. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  16106. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  16107. {
  16108. continue;
  16109. }
  16110. infos.Add(new TourClientListInfo() {
  16111. IsAccompany = 1,
  16112. LastName = lastName,
  16113. FirstName = firstName,
  16114. Pinyin = lastNameEn + @"/" + firstNameEn,
  16115. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女")? 1:2,
  16116. CompanyFullName = data.CompanyFullName,
  16117. Job = data.Job
  16118. });
  16119. }
  16120. if (infos.Any())
  16121. {
  16122. var viewData = await _tourClientListRep._AddMultiple(request);
  16123. if (viewData.Code != 0)
  16124. {
  16125. return Ok(JsonView(false, viewData.Msg));
  16126. }
  16127. return Ok(JsonView(true));
  16128. }
  16129. return Ok(JsonView(false));
  16130. }
  16131. /// <summary>
  16132. /// 接团客户名单
  16133. /// AddMultiple(添加多个)
  16134. /// </summary>
  16135. /// <param name="_dto"></param>
  16136. /// <returns></returns>
  16137. [HttpPost]
  16138. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16139. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  16140. {
  16141. #region 参数验证
  16142. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16143. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16144. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16145. #region 页面操作权限验证
  16146. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16147. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16148. #endregion
  16149. #endregion
  16150. var viewData = await _tourClientListRep._AddMultiple(_dto);
  16151. if (viewData.Code != 0)
  16152. {
  16153. return Ok(JsonView(false, viewData.Msg));
  16154. }
  16155. return Ok(JsonView(true));
  16156. }
  16157. /// <summary>
  16158. /// 接团客户名单
  16159. /// Del
  16160. /// </summary>
  16161. /// <param name="_dto"></param>
  16162. /// <returns></returns>
  16163. [HttpPost]
  16164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16165. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  16166. {
  16167. #region 参数验证
  16168. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16169. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16170. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16171. #region 页面操作权限验证
  16172. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16173. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16174. #endregion
  16175. #endregion
  16176. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  16177. if (viewData.Code != 0)
  16178. {
  16179. return Ok(JsonView(false, viewData.Msg));
  16180. }
  16181. return Ok(JsonView(true));
  16182. }
  16183. /// <summary>
  16184. /// 接团客户名单
  16185. /// 文件下载 客户名单
  16186. /// </summary>
  16187. /// <param name="_dto"></param>
  16188. /// <returns></returns>
  16189. [HttpPost]
  16190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16191. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  16192. {
  16193. #region 参数验证
  16194. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16195. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16196. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  16197. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16198. #region 页面操作权限验证
  16199. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16200. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16201. #endregion
  16202. #endregion
  16203. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  16204. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  16205. From Grp_TourClientList tcl
  16206. Left Join
  16207. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  16208. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  16209. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  16210. From Crm_DeleClient dc
  16211. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  16212. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  16213. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  16214. Where dc.IsDel = 0) temp
  16215. On temp.DcId =tcl.ClientId
  16216. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  16217. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  16218. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  16219. //载入模板
  16220. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  16221. if (_dto.Language == 1)
  16222. {
  16223. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  16224. }
  16225. //载入模板
  16226. var doc = new Document(tempPath);
  16227. DocumentBuilder builder = new DocumentBuilder(doc);
  16228. //获取word里所有表格
  16229. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16230. //获取所填表格的序数
  16231. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16232. var rowStart = tableOne.Rows[0]; //获取第1行
  16233. if (_dto.Language == 0)
  16234. {
  16235. //循环赋值
  16236. for (int i = 0; i < DcList.Count; i++)
  16237. {
  16238. EncryptionProcessor.DecryptProperties(DcList[i]);
  16239. builder.MoveToCell(0, i + 1, 0, 0);
  16240. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  16241. builder.MoveToCell(0, i + 1, 1, 0);
  16242. int sex = DcList[i].Sex;
  16243. string sexStr = string.Empty;
  16244. if (sex == 0) sexStr = "男";
  16245. else if (sex == 1) sexStr = "女";
  16246. else sexStr = "未设置";
  16247. builder.Write(sexStr);
  16248. builder.MoveToCell(0, i + 1, 2, 0);
  16249. string birthDay = DcList[i].BirthDay;
  16250. string birthDayStr = string.Empty;
  16251. if (!string.IsNullOrEmpty(birthDay))
  16252. {
  16253. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  16254. }
  16255. builder.Write(birthDayStr);
  16256. builder.MoveToCell(0, i + 1, 3, 0);
  16257. string company = "";
  16258. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16259. {
  16260. company = DcList[i].CompanyFullName.ToString();
  16261. }
  16262. builder.Write(company);
  16263. builder.MoveToCell(0, i + 1, 4, 0);
  16264. builder.Write(DcList[i].Job);
  16265. }
  16266. }
  16267. else if (_dto.Language == 1)
  16268. {
  16269. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  16270. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  16271. List<string> transArrayStr = new List<string>();
  16272. string transStrRes1 = "";
  16273. for (int i = 0; i < DcList.Count; i++)
  16274. {
  16275. var dc = DcList[i];
  16276. EncryptionProcessor.DecryptProperties(dc);
  16277. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  16278. if (dc.Job.Equals("暂无")) dc.Job = "-";
  16279. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  16280. if (DcList.Count - 1 == i) transStrRes1 += str1;
  16281. else transStrRes1 += $"{str1}|";
  16282. }
  16283. //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";
  16284. string transStrRes = "";
  16285. if (transStrRes1.Length > 0)
  16286. {
  16287. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  16288. }
  16289. //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
  16290. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  16291. //List<string> transArray = new List<string> { };
  16292. List<TranslateInfo> transArray = new List<TranslateInfo>();
  16293. if (transStrRes.Contains("|"))
  16294. {
  16295. string[] transArray1 = transStrRes.Split('|');
  16296. if (transArray1.Length > 0)
  16297. {
  16298. foreach (var item in transArray1)
  16299. {
  16300. if (item.Contains("&"))
  16301. {
  16302. string[] transArray2 = item.Split('&');
  16303. int index = 0;
  16304. string companyName = "", job = "";
  16305. if (transArray2.Length > 0)
  16306. {
  16307. bool success = int.TryParse(transArray2[0].Trim(), out index);
  16308. if (1 < transArray2.Length) companyName = transArray2[1];
  16309. if (2 < transArray2.Length) job = transArray2[2];
  16310. }
  16311. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  16312. }
  16313. }
  16314. }
  16315. }
  16316. //循环赋值
  16317. for (int i = 0; i < DcList.Count; i++)
  16318. {
  16319. string PYName = "";
  16320. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  16321. {
  16322. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  16323. string PY_First = DcList[i].Pinyin.Split('/')[1];
  16324. PYName = PY_First + " " + PY_Last;
  16325. }
  16326. else
  16327. {
  16328. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  16329. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  16330. PYName = PY_First + " " + PY_Last;
  16331. }
  16332. builder.MoveToCell(0, i + 1, 0, 0);
  16333. builder.Write(PYName);
  16334. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  16335. builder.MoveToCell(0, i + 1, 1, 0);
  16336. builder.Write(sex);
  16337. DateTime birthDt;
  16338. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  16339. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  16340. builder.MoveToCell(0, i + 1, 2, 0);
  16341. builder.Write(birthday);
  16342. string company = string.Empty, job = string.Empty;
  16343. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  16344. if (dcTransInfo != null)
  16345. {
  16346. company = dcTransInfo.CompanyName;
  16347. job = dcTransInfo.Job;
  16348. }
  16349. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16350. {
  16351. //查询对照表
  16352. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  16353. if (tempCec != null)
  16354. {
  16355. company = tempCec.enName;
  16356. }
  16357. //翻译
  16358. else
  16359. {
  16360. }
  16361. }
  16362. builder.MoveToCell(0, i + 1, 3, 0);
  16363. builder.Write(company);
  16364. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  16365. {
  16366. //查询对照表
  16367. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  16368. if (tempPec != null)
  16369. {
  16370. job = tempPec.enName;
  16371. }
  16372. //翻译
  16373. else
  16374. {
  16375. }
  16376. }
  16377. builder.MoveToCell(0, i + 1, 4, 0);
  16378. builder.Write(job);
  16379. }
  16380. }
  16381. //删除多余行
  16382. while (tableOne.Rows.Count > DcList.Count + 1)
  16383. {
  16384. tableOne.Rows.RemoveAt(DcList.Count + 1);
  16385. }
  16386. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  16387. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  16388. doc.Save(fileDir);
  16389. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  16390. return Ok(JsonView(true, "操作成功!", Url));
  16391. }
  16392. private class TranslateInfo
  16393. {
  16394. public int Index { get; set; }
  16395. public string CompanyName { get; set; }
  16396. public string Job { get; set; }
  16397. }
  16398. #endregion
  16399. #region 团组倒推表
  16400. /// <summary>
  16401. /// 倒推表基础数据
  16402. /// Init
  16403. /// </summary>
  16404. /// <param name="dto"></param>
  16405. /// <returns></returns>
  16406. [HttpPost]
  16407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16408. public async Task<IActionResult> PostInvertedListInit()
  16409. {
  16410. var viewData = await _invertedListRep._Init();
  16411. if (viewData.Code != 0)
  16412. {
  16413. return Ok(JsonView(false, viewData.Msg));
  16414. }
  16415. return Ok(JsonView(viewData.Data));
  16416. }
  16417. /// <summary>
  16418. /// 倒推表
  16419. /// Info
  16420. /// </summary>
  16421. /// <param name="dto"></param>
  16422. /// <returns></returns>
  16423. [HttpPost]
  16424. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16425. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  16426. {
  16427. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  16428. if (viewData.Code != 0)
  16429. {
  16430. return Ok(JsonView(false, viewData.Msg));
  16431. }
  16432. return Ok(JsonView(viewData.Data));
  16433. }
  16434. /// <summary>
  16435. /// 倒推表
  16436. /// Create
  16437. /// </summary>
  16438. /// <param name="dto"></param>
  16439. /// <returns></returns>
  16440. [HttpPost]
  16441. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16442. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  16443. {
  16444. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  16445. if (viewData.Code != 0)
  16446. {
  16447. return Ok(JsonView(false, viewData.Msg));
  16448. }
  16449. return Ok(JsonView(viewData.Data));
  16450. }
  16451. /// <summary>
  16452. /// 倒推表
  16453. /// Update
  16454. /// </summary>
  16455. /// <param name="dto"></param>
  16456. /// <returns></returns>
  16457. [HttpPost]
  16458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16459. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  16460. {
  16461. var viewData = await _invertedListRep._Update(dto);
  16462. if (viewData.Code != 0)
  16463. {
  16464. return Ok(JsonView(false, viewData.Msg));
  16465. }
  16466. return Ok(JsonView(viewData.Data));
  16467. }
  16468. /// <summary>
  16469. /// 倒推表
  16470. /// File Download
  16471. /// </summary>
  16472. /// <param name="dto"></param>
  16473. /// <returns></returns>
  16474. [HttpPost]
  16475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16476. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  16477. {
  16478. var info2 = await _invertedListRep._Info(1, dto.DiId);
  16479. if (info2.Code != 0)
  16480. {
  16481. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  16482. }
  16483. var info1 = info2.Data as InvertedListInfoView;
  16484. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  16485. string teamName = "";
  16486. if (info != null) teamName = info.TeamName;
  16487. //载入模板
  16488. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  16489. DocumentBuilder builder = new DocumentBuilder(doc);
  16490. //利用键值对存放数据
  16491. Dictionary<string, string> dic = new Dictionary<string, string>();
  16492. dic.Add("TeamName", teamName);
  16493. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  16494. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  16495. dic.Add("BPRemark", info1.ApprovalDataRemark);
  16496. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  16497. dic.Add("SQRemark", info1.ApprovalRemark);
  16498. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  16499. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  16500. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  16501. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  16502. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  16503. dic.Add("QZRemark", info1.VisaInformationRemark);
  16504. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  16505. dic.Add("SQQZRemark", info1.SendVisaRemark);
  16506. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  16507. dic.Add("CQRemark", info1.IssueVisaRemark);
  16508. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  16509. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  16510. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  16511. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  16512. #region 填充word模板书签内容
  16513. foreach (var key in dic.Keys)
  16514. {
  16515. builder.MoveToBookmark(key);
  16516. builder.Write(dic[key]);
  16517. }
  16518. #endregion
  16519. var fileDir = AppSettingsHelper.Get("WordBasePath");
  16520. string fileName = $"{teamName}团出行准备流程表.doc";
  16521. string filePath = fileDir + $@"InvertedList/{fileName}";
  16522. doc.Save(filePath);
  16523. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  16524. return Ok(JsonView(true, "操作成功!", Url));
  16525. }
  16526. #endregion
  16527. #region 三公签证费用(签证费、代办费)
  16528. /// <summary>
  16529. /// 三公签证费用(签证费、代办费)
  16530. /// List
  16531. /// </summary>
  16532. /// <returns></returns>
  16533. [HttpPost]
  16534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16535. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  16536. {
  16537. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  16538. if (_view.Code != 0)
  16539. {
  16540. return Ok(JsonView(false, _view.Msg));
  16541. }
  16542. return Ok(JsonView(true, "操作成功!", _view.Data));
  16543. }
  16544. /// <summary>
  16545. /// 三公签证费用(签证费、代办费)
  16546. /// Add Or Update
  16547. /// </summary>
  16548. /// <returns></returns>
  16549. [HttpPost]
  16550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16551. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  16552. {
  16553. var _view = await _visaFeeInfoRep._Update(_dto);
  16554. if (_view.Code != 0)
  16555. {
  16556. return Ok(JsonView(false, _view.Msg));
  16557. }
  16558. return Ok(JsonView(true, _view.Msg));
  16559. }
  16560. #endregion
  16561. #region 酒店询价
  16562. /// <summary>
  16563. /// 酒店询价
  16564. /// Init
  16565. /// </summary>
  16566. /// <param name="dto"></param>
  16567. /// <returns></returns>
  16568. [HttpPost]
  16569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16570. public async Task<IActionResult> PostHotelInquiryInit()
  16571. {
  16572. var res = await _hotelInquiryRep._Init();
  16573. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16574. return Ok(JsonView(true, res.Msg, res.Data));
  16575. }
  16576. /// <summary>
  16577. /// 酒店询价
  16578. /// page Item
  16579. /// </summary>
  16580. /// <param name="_dto"></param>
  16581. /// <returns></returns>
  16582. [HttpPost]
  16583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16584. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  16585. {
  16586. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  16587. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16588. var view = res.Data as PageDataViewBase;
  16589. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  16590. }
  16591. /// <summary>
  16592. /// 酒店询价
  16593. /// info
  16594. /// </summary>
  16595. /// <param name="_dto"></param>
  16596. /// <returns></returns>
  16597. [HttpPost]
  16598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16599. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  16600. {
  16601. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  16602. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16603. return Ok(JsonView(true, res.Msg, res.Data));
  16604. }
  16605. /// <summary>
  16606. /// 酒店询价
  16607. /// Add Or Edit
  16608. /// </summary>
  16609. /// <param name="_dto"></param>
  16610. /// <returns></returns>
  16611. [HttpPost]
  16612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16613. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  16614. {
  16615. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  16616. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16617. return Ok(JsonView(true, res.Msg, res.Data));
  16618. }
  16619. /// <summary>
  16620. /// 酒店询价
  16621. /// Del
  16622. /// </summary>
  16623. /// <param name="_dto"></param>
  16624. /// <returns></returns>
  16625. [HttpPost]
  16626. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16627. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  16628. {
  16629. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  16630. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16631. return Ok(JsonView(true, res.Msg, res.Data));
  16632. }
  16633. #endregion
  16634. #region 下载匹配op行程单
  16635. /// <summary>
  16636. /// 匹配op行程单
  16637. /// Init
  16638. /// </summary>
  16639. /// <param name="dto">团组列表请求dto</param>
  16640. /// <returns></returns>
  16641. [HttpPost]
  16642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16643. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  16644. {
  16645. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  16646. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  16647. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  16648. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  16649. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  16650. .Where(it => it.IsDel == 0)
  16651. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  16652. .OrderByDescending(it => it.CreateUserId)
  16653. .ToList();
  16654. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  16655. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  16656. var diids = groupInfos.Select(it => it.Id).ToList();
  16657. List<string> countrys = new List<string>();
  16658. foreach (var item in country)
  16659. {
  16660. var data = _groupRepository.FormartTeamName(item);
  16661. var dataArray = _groupRepository.GroupSplitCountry(data);
  16662. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  16663. }
  16664. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  16665. List<string> areaArray = new List<string>(); //GetGroupCityLine
  16666. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  16667. foreach (var item in areaItem)
  16668. {
  16669. string areaStr = item.Value;
  16670. if (!string.IsNullOrEmpty(areaStr))
  16671. {
  16672. string[] str1 = areaStr.Split("-");
  16673. if (str1.Length > 0)
  16674. {
  16675. areaArray.AddRange(str1);
  16676. }
  16677. }
  16678. }
  16679. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  16680. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  16681. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  16682. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  16683. .ToList();
  16684. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  16685. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  16686. .Where(it => countriesIds.Contains(it.Id))
  16687. .Select(it => new { it.Id, Name = it.Name_CN })
  16688. .ToList();
  16689. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  16690. .Select(it => it.TeamName).ToList();
  16691. stopwatch.Stop();
  16692. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  16693. }
  16694. ///// <summary>
  16695. ///// 匹配op行程单
  16696. ///// Init 查询区域数据
  16697. ///// </summary>
  16698. ///// <param name="dto">团组列表请求dto</param>
  16699. ///// <returns></returns>
  16700. //[HttpPost]
  16701. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16702. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  16703. //{
  16704. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  16705. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  16706. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  16707. // if (string.IsNullOrEmpty(countriesDataStr))
  16708. // {
  16709. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  16710. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  16711. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  16712. // }
  16713. // else
  16714. // {
  16715. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  16716. // }
  16717. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  16718. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  16719. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  16720. // List<dynamic> childList = new List<dynamic>();
  16721. // int parentId = dto.CountriesId;
  16722. // if (provinceData.Count > 1)
  16723. // {
  16724. // foreach (var item1 in provinceData)
  16725. // {
  16726. // List<dynamic> childList1 = new List<dynamic>();
  16727. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  16728. // foreach (var item2 in citiesData1)
  16729. // {
  16730. // List<dynamic> childList2 = new List<dynamic>();
  16731. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  16732. // foreach (var item3 in countiesData1)
  16733. // {
  16734. // childList2.Add(new
  16735. // {
  16736. // id = item3.Id,
  16737. // parentId = item2.Id,
  16738. // level = "district",
  16739. // name = item3.Name_CN,
  16740. // });
  16741. // }
  16742. // childList1.Add(new
  16743. // {
  16744. // id = item2.Id,
  16745. // parentId = item1.Id,
  16746. // level = "city",
  16747. // name = item2.Name_CN,
  16748. // childList = childList2
  16749. // });
  16750. // }
  16751. // childList.Add(new
  16752. // {
  16753. // id = item1.Id,
  16754. // parentId = parentId,
  16755. // level = "province",
  16756. // name = item1.Name_CN,
  16757. // childList = childList1
  16758. // });
  16759. // }
  16760. // //城市
  16761. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  16762. // foreach (var item2 in citiesData2)
  16763. // {
  16764. // List<dynamic> childList22 = new List<dynamic>();
  16765. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  16766. // foreach (var item3 in countiesData1)
  16767. // {
  16768. // childList22.Add(new
  16769. // {
  16770. // id = item3.Id,
  16771. // parentId = item2.Id,
  16772. // level = "district",
  16773. // name = item3.Name_CN,
  16774. // });
  16775. // }
  16776. // childList.Add(new
  16777. // {
  16778. // id = item2.Id,
  16779. // parentId = parentId,
  16780. // level = "city",
  16781. // name = item2.Name_CN,
  16782. // childList = childList22
  16783. // });
  16784. // }
  16785. // }
  16786. // else
  16787. // {
  16788. // foreach (var item2 in citiesData)
  16789. // {
  16790. // string cname = item2.Name_CN;
  16791. // List<dynamic> childList1 = new List<dynamic>();
  16792. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  16793. // foreach (var item3 in countiesData1)
  16794. // {
  16795. // childList1.Add(new
  16796. // {
  16797. // Id = item3.Id,
  16798. // parentId = item2.Id,
  16799. // level = "district",
  16800. // name = item3.Name_CN
  16801. // });
  16802. // }
  16803. // childList.Add(new
  16804. // {
  16805. // id = item2.Id,
  16806. // parentId = parentId,
  16807. // level = "city",
  16808. // name = item2.Name_CN,
  16809. // childList = childList1
  16810. // });
  16811. // }
  16812. // }
  16813. // stopwatch.Stop();
  16814. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  16815. //}
  16816. /// <summary>
  16817. /// 匹配op行程单
  16818. /// 接团信息列表 Page
  16819. /// </summary>
  16820. /// <param name="dto">团组列表请求dto</param>
  16821. /// <returns></returns>
  16822. [HttpPost]
  16823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16824. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  16825. {
  16826. var swatch = new Stopwatch();
  16827. swatch.Start();
  16828. #region 参数验证
  16829. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16830. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  16831. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16832. #region 页面操作权限验证
  16833. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  16834. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  16835. #endregion
  16836. #endregion
  16837. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  16838. {
  16839. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  16840. string sqlWhere = "";
  16841. if (!string.IsNullOrEmpty(dto.Country))
  16842. {
  16843. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  16844. }
  16845. if (!string.IsNullOrEmpty(dto.Area))
  16846. {
  16847. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  16848. }
  16849. if (!string.IsNullOrEmpty(dto.TeamName))
  16850. {
  16851. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  16852. }
  16853. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  16854. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  16855. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  16856. swatch.Stop();
  16857. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  16858. }
  16859. else
  16860. {
  16861. return Ok(JsonView(false, "查询失败"));
  16862. }
  16863. }
  16864. /// <summary>
  16865. /// 匹配op行程单
  16866. /// 行程单下载
  16867. /// </summary>
  16868. /// <param name="dto">团组列表请求dto</param>
  16869. /// <returns></returns>
  16870. [HttpPost]
  16871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16872. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  16873. {
  16874. #region 参数验证
  16875. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16876. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  16877. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16878. #region 页面操作权限验证
  16879. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  16880. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  16881. #endregion
  16882. #endregion
  16883. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  16884. {
  16885. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  16886. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  16887. }
  16888. else
  16889. {
  16890. return Ok(JsonView(false, "下载失败!"));
  16891. }
  16892. }
  16893. #endregion
  16894. #region 国家信息 数据 注释
  16895. //[HttpPost]
  16896. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  16897. //{
  16898. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  16899. // foreach (var item in dto)
  16900. // {
  16901. // infos.Add(new Grp_GroupsTaskAssignment()
  16902. // {
  16903. // DIId = item,
  16904. // CTId = 82,
  16905. // UId = 248,
  16906. // IsEnable = 1,
  16907. // CreateUserId = 233,
  16908. // CreateTime = DateTime.Now,
  16909. // IsDel = 0
  16910. // });
  16911. // infos.Add(new Grp_GroupsTaskAssignment()
  16912. // {
  16913. // DIId = item,
  16914. // CTId = 82,
  16915. // UId = 286,
  16916. // IsEnable = 1,
  16917. // CreateUserId = 233,
  16918. // CreateTime = DateTime.Now,
  16919. // IsDel = 0
  16920. // });
  16921. // }
  16922. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  16923. // return Ok("操作成功");
  16924. //}
  16925. //public class paramJsonDto
  16926. //{
  16927. // public List<CountriesInfo> str { get; set; }
  16928. //}
  16929. //[HttpPost]
  16930. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  16931. //{
  16932. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  16933. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  16934. // List<Sys_Cities> cities = new List<Sys_Cities>();
  16935. // List<Sys_Cities> districts = new List<Sys_Cities>();
  16936. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  16937. // _sqlSugar.BeginTran();
  16938. // int countitiesIndex = 0;
  16939. // foreach (var item in dto.str)
  16940. // {
  16941. // dynamic data = item.c;
  16942. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  16943. // if (data != null)
  16944. // {
  16945. // countitiesIndex++;
  16946. // foreach (var item1 in data)
  16947. // {
  16948. // string cnname = item1.cn;
  16949. // string enname = item1.en;
  16950. // Sys_Cities provinceInfo = new Sys_Cities()
  16951. // {
  16952. // CountriesId = countriesId,
  16953. // Name_CN = cnname,
  16954. // Name_EN = enname,
  16955. // ParentId = 0,
  16956. // IsCapital = 1,
  16957. // CreateUserId = 208,
  16958. // CreateTime = DateTime.Now,
  16959. // IsDel = 0
  16960. // };
  16961. // if (item1.lv == "province") //省份
  16962. // {
  16963. // provinceInfo.Level = 1;
  16964. // int provinceId = 0;
  16965. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  16966. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  16967. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  16968. // var data1 = item1.c;
  16969. // foreach (var item2 in data1)
  16970. // {
  16971. // if (item2.lv == "city")
  16972. // {
  16973. // string citycnname = item2.cn;
  16974. // string cityenname = item2.en;
  16975. // Sys_Cities cityInfo = new Sys_Cities()
  16976. // {
  16977. // CountriesId = countriesId,
  16978. // ParentId = provinceId,
  16979. // Level = 2,
  16980. // Name_CN = citycnname,
  16981. // Name_EN = cityenname,
  16982. // IsCapital = 1,
  16983. // CreateUserId = 208,
  16984. // CreateTime = DateTime.Now,
  16985. // IsDel = 0
  16986. // };
  16987. // if (item2.c != null)
  16988. // {
  16989. // int cityId = 0;
  16990. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  16991. // if (citiesInfo != null) cityId = citiesInfo.Id;
  16992. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  16993. // foreach (var item3 in item2.c)
  16994. // {
  16995. // if (item3.lv == "district")
  16996. // {
  16997. // var districtInfo = new Sys_Cities()
  16998. // {
  16999. // CountriesId = countriesId,
  17000. // Name_CN = item3.cn,
  17001. // Name_EN = item3.en,
  17002. // Level = 3,
  17003. // ParentId = cityId,
  17004. // IsCapital = 1,
  17005. // CreateUserId = 208,
  17006. // CreateTime = DateTime.Now,
  17007. // IsDel = 0
  17008. // };
  17009. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17010. // //{
  17011. // districts.Add(districtInfo);
  17012. // //}
  17013. // }
  17014. // }
  17015. // }
  17016. // else
  17017. // {
  17018. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  17019. // //{
  17020. // cities.Add(cityInfo);
  17021. // //}
  17022. // }
  17023. // }
  17024. // }
  17025. // }
  17026. // else if (item1.lv == "city")//城市
  17027. // {
  17028. // provinceInfo.Level = 2;
  17029. // if (item1.c != null)
  17030. // {
  17031. // int cityId = 0;
  17032. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  17033. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17034. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17035. // foreach (var item3 in item1.c)
  17036. // {
  17037. // if (item3.lv == "district")
  17038. // {
  17039. // var districtInfo = new Sys_Cities()
  17040. // {
  17041. // CountriesId = countriesId,
  17042. // Name_CN = item3.cn,
  17043. // Name_EN = item3.en,
  17044. // Level = 3,
  17045. // ParentId = cityId,
  17046. // IsCapital = 1,
  17047. // CreateUserId = 208,
  17048. // CreateTime = DateTime.Now,
  17049. // IsDel = 0
  17050. // };
  17051. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17052. // //{
  17053. // districts.Add(districtInfo);
  17054. // //}
  17055. // }
  17056. // }
  17057. // }
  17058. // else
  17059. // {
  17060. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  17061. // //{
  17062. // cities.Add(provinceInfo);
  17063. // //}
  17064. // }
  17065. // }
  17066. // }
  17067. // }
  17068. // }
  17069. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  17070. // cities = cities.Distinct().ToList();
  17071. // districts = districts.Distinct().ToList();
  17072. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  17073. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  17074. // cities.AddRange(districts);
  17075. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  17076. // //_sqlSugar.RollbackTran();
  17077. // _sqlSugar.CommitTran();
  17078. // return Ok(JsonView(false, "操作成功!"));
  17079. //}
  17080. //[HttpPost]
  17081. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  17082. //{
  17083. // List<CountitiesInfo> infos = dto.MyProperty;
  17084. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  17085. // _sqlSugar.BeginTran();
  17086. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17087. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  17088. // foreach (var item in infos)
  17089. // {
  17090. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  17091. // if (countryInfo != null)
  17092. // {
  17093. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  17094. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  17095. // if (cityInfo1 != null)
  17096. // {
  17097. // cityInfo1.IsCapital = 0;
  17098. // cityInfos.Add(cityInfo1);
  17099. // }
  17100. // }
  17101. // }
  17102. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  17103. // .UpdateColumns(it => it.IsCapital)
  17104. // .WhereColumns(it => it.Id)
  17105. // .ExecuteCommand();
  17106. // //_sqlSugar.RollbackTran();
  17107. // _sqlSugar.CommitTran();
  17108. // return Ok(JsonView(false, "操作成功!"));
  17109. //}
  17110. //public class CounrtiesDto
  17111. //{
  17112. // public List<CountitiesInfo> MyProperty { get; set; }
  17113. //}
  17114. //public class CountitiesInfo
  17115. //{
  17116. // /// <summary>
  17117. // /// 圣约翰
  17118. // /// </summary>
  17119. // public string capital_name_chinese { get; set; }
  17120. // /// <summary>
  17121. // ///
  17122. // /// </summary>
  17123. // public string capital_name { get; set; }
  17124. // /// <summary>
  17125. // ///
  17126. // /// </summary>
  17127. // public string country_type { get; set; }
  17128. // /// <summary>
  17129. // /// 安提瓜和巴布达
  17130. // /// </summary>
  17131. // public string country_name_chinese { get; set; }
  17132. // /// <summary>
  17133. // /// 安提瓜和巴布达
  17134. // /// </summary>
  17135. // public string country_name_chinese_short { get; set; }
  17136. // /// <summary>
  17137. // /// 安提瓜和巴布达
  17138. // /// </summary>
  17139. // public string country_name_chinese_UN { get; set; }
  17140. // /// <summary>
  17141. // ///
  17142. // /// </summary>
  17143. // public string country_name_english_abbreviation { get; set; }
  17144. // /// <summary>
  17145. // ///
  17146. // /// </summary>
  17147. // public string country_name_english_formal { get; set; }
  17148. // /// <summary>
  17149. // ///
  17150. // /// </summary>
  17151. // public string country_name_english_UN { get; set; }
  17152. // /// <summary>
  17153. // ///
  17154. // /// </summary>
  17155. // public string continent_name { get; set; }
  17156. // /// <summary>
  17157. // ///
  17158. // /// </summary>
  17159. // public string subregion_name { get; set; }
  17160. // /// <summary>
  17161. // ///
  17162. // /// </summary>
  17163. // public string country_code2 { get; set; }
  17164. // /// <summary>
  17165. // ///
  17166. // /// </summary>
  17167. // public string country_code3 { get; set; }
  17168. // /// <summary>
  17169. // ///
  17170. // /// </summary>
  17171. // public string phone_code { get; set; }
  17172. //}
  17173. //public class CountriesInfo : BasicInfo
  17174. //{
  17175. // public List<CitiesInfo> c { get; set; }
  17176. //}
  17177. //public class CitiesInfo : BasicInfo
  17178. //{
  17179. // public List<AreaInfo> c { get; set; }
  17180. //}
  17181. //public class AreaInfo : BasicInfo
  17182. //{
  17183. // public List<AreaInfo> c { get; set; }
  17184. //}
  17185. //public class BasicInfo
  17186. //{
  17187. // public string code { get; set; }
  17188. // public string cn { get; set; }
  17189. // public string lv { get; set; }
  17190. // public string en { get; set; }
  17191. //}
  17192. #endregion
  17193. #region 查看邀请方
  17194. /// <summary>
  17195. /// 查看邀请方
  17196. /// 邀请方信息 Init
  17197. /// </summary>
  17198. /// <param name="dto"></param>
  17199. /// <returns></returns>
  17200. [HttpPost]
  17201. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17202. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  17203. {
  17204. string sqlWhere = string.Empty;
  17205. if (!string.IsNullOrEmpty(dto.Search))
  17206. {
  17207. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  17208. }
  17209. string sql = string.Format($@"Select
  17210. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  17211. Id,
  17212. UnitName
  17213. From Res_InvitationOfficialActivityData
  17214. Where IsDel = 0
  17215. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  17216. RefAsync<int> total = 0;
  17217. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17218. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  17219. }
  17220. /// <summary>
  17221. /// 查看邀请方
  17222. /// 国家信息 Init
  17223. /// </summary>
  17224. /// <param name="dto"></param>
  17225. /// <returns></returns>
  17226. [HttpPost]
  17227. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17228. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  17229. {
  17230. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  17231. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17232. var diids = groupInfos.Select(it => it.Id).ToList();
  17233. List<string> countrys = new List<string>();
  17234. foreach (var item in country)
  17235. {
  17236. var data = _groupRepository.FormartTeamName(item);
  17237. var dataArray = _groupRepository.GroupSplitCountry(data);
  17238. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17239. }
  17240. countrys = countrys.Distinct().ToList();
  17241. for (int i = 0; i < countrys.Count; i++)
  17242. {
  17243. string item = countrys[i];
  17244. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  17245. {
  17246. countrys.Remove(item);
  17247. i--;
  17248. }
  17249. }
  17250. RefAsync<int> total = 0;
  17251. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  17252. .Where(it => countrys.Contains(it.Name_CN))
  17253. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17254. .Select(it => new { id = it.Id, name = it.Name_CN })
  17255. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17256. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17257. }
  17258. /// <summary>
  17259. /// 查看邀请方
  17260. /// 城市信息 Init
  17261. /// </summary>
  17262. /// <param name="dto"></param>
  17263. /// <returns></returns>
  17264. [HttpPost]
  17265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17266. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  17267. {
  17268. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  17269. RefAsync<int> total = 0;
  17270. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  17271. .Where(it => it.CountriesId == dto.CountiesId)
  17272. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17273. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  17274. .Select(it => new { id = it.Id, name = it.Name_CN })
  17275. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17276. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17277. }
  17278. /// <summary>
  17279. /// 查看邀请方
  17280. /// 团组名称 Init
  17281. /// </summary>
  17282. /// <param name="dto"></param>
  17283. /// <returns></returns>
  17284. [HttpPost]
  17285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17286. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  17287. {
  17288. var watch = new Stopwatch();
  17289. watch.Start();
  17290. RefAsync<int> total = 0;
  17291. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  17292. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  17293. .Where((oa, di) => oa.IsDel == 0)
  17294. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  17295. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  17296. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  17297. .Distinct()
  17298. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17299. watch.Stop();
  17300. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  17301. }
  17302. /// <summary>
  17303. /// 查看邀请方
  17304. /// 团组 & 邀请方信息
  17305. /// </summary>
  17306. /// <param name="dto"></param>
  17307. /// <returns></returns>
  17308. [HttpPost]
  17309. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17310. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  17311. {
  17312. var watch = new Stopwatch();
  17313. watch.Start();
  17314. RefAsync<int> total = 0;
  17315. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  17316. .AS("Grp_DelegationInfo")
  17317. .Includes(x => x.InvitingInfos)
  17318. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  17319. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  17320. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  17321. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  17322. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  17323. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  17324. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17325. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  17326. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  17327. infos.ForEach(x =>
  17328. {
  17329. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  17330. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  17331. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  17332. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  17333. });
  17334. watch.Stop();
  17335. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  17336. }
  17337. #endregion
  17338. #region 报批行程
  17339. /// <summary>
  17340. /// 报批行程初始化
  17341. /// </summary>
  17342. /// <param name="dto"></param>
  17343. /// <returns></returns>
  17344. [HttpPost]
  17345. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  17346. {
  17347. const int chiNumber = 5;
  17348. var jw = JsonView(false);
  17349. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  17350. var group = groupList.First();
  17351. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  17352. group = groupList.First(x => x.Id == diid);
  17353. if (group == null)
  17354. {
  17355. jw.Msg = "暂无团组!";
  17356. return Ok(jw);
  17357. }
  17358. var data = new
  17359. {
  17360. groupList = groupList.Select(x => new
  17361. {
  17362. x.TeamName,
  17363. x.Id
  17364. }),
  17365. content = new ArrayList(),
  17366. groupInfo = new
  17367. {
  17368. group.VisitDays,
  17369. group.TourCode,
  17370. group.VisitPNumber,
  17371. group.TeamName,
  17372. group.Id,
  17373. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  17374. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  17375. },
  17376. };
  17377. var resultArr = new ArrayList();
  17378. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  17379. if (content.Count == 0)
  17380. {
  17381. var stay = "-";
  17382. var cityPath = "-";
  17383. //添加城市路径以及住宿地
  17384. //黑屏代码数据
  17385. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  17386. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17387. {
  17388. jw = JsonView(true, "黑屏代码有误!", data);
  17389. return Ok(jw);
  17390. }
  17391. foreach (DataRow row in dtBlack.Rows)
  17392. {
  17393. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17394. {
  17395. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  17396. return Ok(jw);
  17397. }
  17398. }
  17399. //黑屏代码获取时间区间
  17400. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  17401. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  17402. _sqlSugar.BeginTran();
  17403. for (int i = 0; i < timeArr.Count; i++)
  17404. {
  17405. stay = "-";
  17406. cityPath = "-";
  17407. DateTime NewData = DateTime.Parse(timeArr[i]);
  17408. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  17409. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  17410. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  17411. if (tbSelect.Length > 0)
  17412. {
  17413. List<string> threeCodeStr = new List<string>();
  17414. foreach (var item in tbSelect)
  17415. {
  17416. var threeCode = item["Three"].ToString() ?? "";
  17417. if (threeCode.Length == 6)
  17418. {
  17419. var start = threeCode.Substring(0, 3);
  17420. var end = threeCode.Substring(3, 3);
  17421. if (threeCodeStr.Count == 0)
  17422. {
  17423. threeCodeStr.Add(start);
  17424. threeCodeStr.Add(end);
  17425. }
  17426. else
  17427. {
  17428. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  17429. {
  17430. threeCodeStr.Add(end);
  17431. }
  17432. else
  17433. {
  17434. threeCodeStr.Add(start);
  17435. threeCodeStr.Add(end);
  17436. }
  17437. }
  17438. }
  17439. }
  17440. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  17441. var last = threeCodeStr.Last();
  17442. foreach (var item in threeCodeStr)
  17443. {
  17444. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  17445. if (item.Equals(last))
  17446. {
  17447. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  17448. }
  17449. }
  17450. cityPath = cityPath.Trim('-');
  17451. }
  17452. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  17453. appro.Diid = diid ?? -1;
  17454. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  17455. appro.Id = thisId;
  17456. appro.CreateUserId = dto.UserId;
  17457. appro.CreateTime = DateTime.Now;
  17458. content.Add(appro);
  17459. }
  17460. _sqlSugar.CommitTran();
  17461. }
  17462. foreach (var x in content)
  17463. {
  17464. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  17465. if (chiList.Count < chiNumber)
  17466. {
  17467. for (int i = chiList.Count; i < chiNumber; i++)
  17468. {
  17469. chiList.Add(new Grp_ApprovalTravelDetails());
  17470. }
  17471. }
  17472. resultArr.Add(new
  17473. {
  17474. x.Id,
  17475. x.Date,
  17476. x.Diid,
  17477. chiList = chiList.Select(x1 => new
  17478. {
  17479. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  17480. x1.Details,
  17481. x1.ParentId,
  17482. x1.Id
  17483. })
  17484. });
  17485. }
  17486. data = data with
  17487. {
  17488. content = resultArr,
  17489. };
  17490. jw = JsonView(true, "获取成功!", data);
  17491. return Ok(jw);
  17492. }
  17493. /// <summary>
  17494. /// 报批行程删除
  17495. /// </summary>
  17496. /// <param name="dto"></param>
  17497. /// <returns></returns>
  17498. [HttpPost]
  17499. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  17500. {
  17501. var jw = JsonView(false);
  17502. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17503. if (group == null)
  17504. {
  17505. jw.Msg = "团组参数有误!";
  17506. return Ok(jw);
  17507. }
  17508. try
  17509. {
  17510. _sqlSugar.BeginTran();
  17511. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  17512. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  17513. {
  17514. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17515. DeleteUserId = dto.uesrId,
  17516. IsDel = 1
  17517. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  17518. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  17519. {
  17520. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17521. DeleteUserId = dto.uesrId,
  17522. IsDel = 1
  17523. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  17524. _sqlSugar.CommitTran();
  17525. jw = JsonView(true, "删除成功");
  17526. }
  17527. catch (Exception ex)
  17528. {
  17529. jw = JsonView(false, ex.Message);
  17530. }
  17531. return Ok(jw);
  17532. }
  17533. /// <summary>
  17534. /// 报批行程保存
  17535. /// </summary>
  17536. /// <param name="dto"></param>
  17537. /// <returns></returns>
  17538. [HttpPost]
  17539. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  17540. {
  17541. var jw = JsonView(false);
  17542. var Find = dto.Arr.Find(x => x.id == 0);
  17543. if (Find != null)
  17544. {
  17545. jw.Msg = "生成的ID为0!";
  17546. return Ok(jw);
  17547. }
  17548. foreach (var item in dto.Arr)
  17549. {
  17550. foreach (var chi in item.chiList)
  17551. {
  17552. if (chi.parentId == 0)
  17553. {
  17554. chi.parentId = item.id;
  17555. }
  17556. }
  17557. }
  17558. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  17559. _sqlSugar.BeginTran();
  17560. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  17561. {
  17562. var parentIds = dto.Arr.Select(x => x.id).ToList();
  17563. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  17564. {
  17565. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17566. DeleteUserId = dto.UserId,
  17567. IsDel = 1
  17568. }).ExecuteCommand();
  17569. }
  17570. try
  17571. {
  17572. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  17573. {
  17574. CreateTime = DateTime.Now,
  17575. CreateUserId = dto.UserId,
  17576. Details = x.details,
  17577. ParentId = x.parentId,
  17578. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17579. Remark = "",
  17580. IsDel = 0
  17581. }).ToList()).ExecuteCommand();
  17582. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  17583. {
  17584. Id = x.id,
  17585. Details = x.details,
  17586. ParentId = x.parentId,
  17587. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17588. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  17589. {
  17590. Details = x.Details,
  17591. ParentId = x.ParentId,
  17592. Time = x.Time
  17593. }).ExecuteCommand();
  17594. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  17595. {
  17596. Id = x.id,
  17597. Date = x.date,
  17598. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  17599. {
  17600. Date = x.Date
  17601. }).ExecuteCommand();
  17602. _sqlSugar.CommitTran();
  17603. jw = JsonView(true, "保存成功!");
  17604. }
  17605. catch (Exception ex)
  17606. {
  17607. _sqlSugar.RollbackTran();
  17608. jw = JsonView(false, "保存失败!" + ex.Message);
  17609. }
  17610. return Ok(jw);
  17611. }
  17612. /// <summary>
  17613. /// 报批行程生成
  17614. /// </summary>
  17615. /// <param name="dto"></param>
  17616. /// <returns></returns>
  17617. [HttpPost]
  17618. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  17619. {
  17620. var jw = JsonView(false);
  17621. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17622. if (group == null)
  17623. {
  17624. jw.Msg = "暂无该团组!";
  17625. return Ok(jw);
  17626. }
  17627. //黑屏代码数据
  17628. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  17629. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17630. {
  17631. jw.Msg = "黑屏代码有误!";
  17632. return Ok(jw);
  17633. }
  17634. foreach (DataRow row in dtBlack.Rows)
  17635. {
  17636. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17637. {
  17638. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  17639. return Ok(jw);
  17640. }
  17641. }
  17642. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  17643. var resultArr = new ArrayList();
  17644. if (officialActivitiesArr.Count == 0)
  17645. {
  17646. jw.Msg = "暂无公务出访信息!";
  17647. return Ok(jw);
  17648. }
  17649. try
  17650. {
  17651. _sqlSugar.BeginTran();
  17652. DeleteApprovalJourney(new
  17653. Domain.Dtos.Groups.DeleteApprovalJourney
  17654. {
  17655. Diid = dto.Diid,
  17656. uesrId = dto.Userid
  17657. });
  17658. var stay = "-";
  17659. var cityPath = "-";
  17660. //添加城市路径以及住宿地
  17661. //黑屏代码获取时间区间
  17662. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  17663. var empty = "【未收入该三字码!请机票同事录入】";
  17664. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  17665. for (int i = 0; i < timeArr.Count; i++)
  17666. {
  17667. stay = "-";
  17668. cityPath = "-";
  17669. var chiarr = new List<Grp_ApprovalTravelDetails>();
  17670. DateTime NewData = DateTime.Parse(timeArr[i]);
  17671. 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();
  17672. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  17673. if (tbSelect.Length > 0)
  17674. {
  17675. List<string> threeCodeStr = new List<string>();
  17676. bool isTrade = false;
  17677. string trip = string.Empty;
  17678. var rowLast = tbSelect.Last();
  17679. var rowFirst = tbSelect.First();
  17680. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  17681. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  17682. var takeOffTime = DateTime.Parse(timeArr[i]);
  17683. var fallToTime = DateTime.Parse(timeArr[i]);
  17684. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  17685. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  17686. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  17687. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  17688. foreach (var item in tbSelect)
  17689. {
  17690. var start = string.Empty;
  17691. var end = string.Empty;
  17692. var threeCode = item["Three"].ToString() ?? "";
  17693. if (threeCode.Length == 6)
  17694. {
  17695. start = threeCode.Substring(0, 3);
  17696. end = threeCode.Substring(3, 3);
  17697. if (threeCodeStr.Count == 0)
  17698. {
  17699. threeCodeStr.Add(start);
  17700. threeCodeStr.Add(end);
  17701. }
  17702. else
  17703. {
  17704. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  17705. {
  17706. threeCodeStr.Add(end);
  17707. }
  17708. else
  17709. {
  17710. threeCodeStr.Add(start);
  17711. threeCodeStr.Add(end);
  17712. }
  17713. }
  17714. }
  17715. //处理机票信息
  17716. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  17717. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  17718. if (start_Object == null)
  17719. {
  17720. start_Object = new Res_ThreeCode()
  17721. {
  17722. AirPort = empty,
  17723. AirPort_En = empty,
  17724. City = empty,
  17725. Country = empty,
  17726. Four = empty,
  17727. Three = empty,
  17728. };
  17729. }
  17730. if (end_Object == null)
  17731. {
  17732. end_Object = new Res_ThreeCode()
  17733. {
  17734. AirPort = empty,
  17735. AirPort_En = empty,
  17736. City = empty,
  17737. Country = empty,
  17738. Four = empty,
  17739. Three = empty,
  17740. };
  17741. }
  17742. //机型判断
  17743. string airModel = item["AirModel"].ToString();
  17744. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  17745. string flightTime = item["FlightTime"].ToString();
  17746. if (flightTime!.Contains(":"))
  17747. {
  17748. flightTime = flightTime.Replace(":", "小时");
  17749. flightTime += "分钟";
  17750. }
  17751. if (flightTime.Contains("H"))
  17752. {
  17753. flightTime = flightTime.Replace("H", "小时");
  17754. }
  17755. if (flightTime.Contains("M"))
  17756. {
  17757. flightTime = flightTime.Replace("M", "分钟");
  17758. }
  17759. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  17760. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  17761. {
  17762. flightTime = flightDataTime.Hour > 0
  17763. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  17764. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  17765. ? flightDataTime.Minute.ToString() + "分钟" : "";
  17766. }
  17767. //航班号
  17768. string flightcode = item["Fliagtcode"].ToString();
  17769. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  17770. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  17771. if (aircompany == null)
  17772. {
  17773. aircompany = new Res_AirCompany
  17774. {
  17775. CnName = hsEmpty,
  17776. EnName = hsEmpty,
  17777. ShortCode = hsEmpty,
  17778. };
  17779. }
  17780. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  17781. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  17782. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  17783. if (isTrade)
  17784. {
  17785. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  17786. }
  17787. else
  17788. {
  17789. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  17790. }
  17791. }
  17792. chiarr.Add(new Grp_ApprovalTravelDetails
  17793. {
  17794. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  17795. CreateTime = DateTime.Now,
  17796. CreateUserId = dto.Userid,
  17797. ParentId = 0,
  17798. Details = trip
  17799. });
  17800. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  17801. var last = threeCodeStr.Last();
  17802. foreach (var item in threeCodeStr)
  17803. {
  17804. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  17805. if (item.Equals(last))
  17806. {
  17807. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  17808. }
  17809. }
  17810. cityPath = cityPath.Trim('-');
  17811. }
  17812. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  17813. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  17814. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  17815. appro.Diid = dto.Diid;
  17816. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  17817. appro.Id = thisId;
  17818. appro.CreateUserId = dto.Userid;
  17819. appro.CreateTime = DateTime.Now;
  17820. foreach (var item in gwinfo)
  17821. {
  17822. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  17823. chi.Details = "拜访" + item.Client;
  17824. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  17825. {
  17826. chi.Details += "," + item.ReqSample;
  17827. }
  17828. chi.ParentId = thisId;
  17829. chi.Time = item.Time;
  17830. chiarr.Add(chi);
  17831. }
  17832. if (chiarr.Count < 5)
  17833. {
  17834. for (int j = chiarr.Count; j < 5; j++)
  17835. {
  17836. chiarr.Add(new
  17837. Grp_ApprovalTravelDetails());
  17838. }
  17839. }
  17840. resultArr.Add(new
  17841. {
  17842. appro.Id,
  17843. appro.Date,
  17844. appro.Diid,
  17845. chiList = chiarr.Select(x1 => new
  17846. {
  17847. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  17848. x1.Details,
  17849. x1.ParentId,
  17850. x1.Id
  17851. })
  17852. });
  17853. }
  17854. _sqlSugar.CommitTran();
  17855. jw = JsonView(true, "生成成功!", resultArr);
  17856. }
  17857. catch (Exception ex)
  17858. {
  17859. jw.Code = 400;
  17860. jw.Msg = "生成失败!" + ex.Message;
  17861. }
  17862. return Ok(jw);
  17863. }
  17864. /// <summary>
  17865. /// 报批行程word导出
  17866. /// </summary>
  17867. /// <param name="dto"></param>
  17868. /// <returns></returns>
  17869. [HttpPost]
  17870. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  17871. {
  17872. var jw = JsonView(false);
  17873. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17874. if (group == null)
  17875. {
  17876. jw.Msg = "暂无该团组!";
  17877. return Ok(jw);
  17878. }
  17879. //模板路径
  17880. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  17881. //载入模板
  17882. Document doc = new Document(tempPath);
  17883. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17884. //获取所填表格的序数
  17885. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  17886. Aspose.Words.Tables.Row titleRowClone = null;
  17887. Aspose.Words.Tables.Row CenterRowClone = null;
  17888. int index = 0;
  17889. int indexChi = 0;
  17890. int SetIndex = 0;
  17891. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  17892. //获取数据,放到datatable
  17893. foreach (var item in ApprovalTravelArr)
  17894. {
  17895. if (index > 0)
  17896. {
  17897. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  17898. tableOne.AppendChild(titleRowClone);
  17899. }
  17900. var textTime = item.Date;
  17901. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  17902. SetCells(tableOne, doc, SetIndex, 0, textTime);
  17903. SetIndex++;
  17904. if (ChiRep.Count > 0)
  17905. {
  17906. foreach (var itemChi in ChiRep)
  17907. {
  17908. var txtTime = itemChi.Time;
  17909. var txtDetail = itemChi.Details;
  17910. if (indexChi > 0)
  17911. {
  17912. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  17913. tableOne.AppendChild(CenterRowClone);
  17914. }
  17915. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  17916. {
  17917. SetCells(tableOne, doc, SetIndex, 0, "");
  17918. SetCells(tableOne, doc, SetIndex, 1, "");
  17919. indexChi++;
  17920. SetIndex++;
  17921. break;
  17922. }
  17923. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  17924. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  17925. indexChi++;
  17926. SetIndex++;
  17927. }
  17928. }
  17929. else
  17930. {
  17931. if (indexChi > 0)
  17932. {
  17933. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  17934. tableOne.AppendChild(CenterRowClone);
  17935. }
  17936. SetCells(tableOne, doc, SetIndex, 0, "");
  17937. SetCells(tableOne, doc, SetIndex, 1, "");
  17938. indexChi++;
  17939. SetIndex++;
  17940. }
  17941. index++;
  17942. }
  17943. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  17944. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  17945. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  17946. jw.Code = 200;
  17947. jw.Msg = "";
  17948. return Ok(jw);
  17949. }
  17950. private string intToString(int numberVal)
  17951. {
  17952. string numberval = numberVal.ToString();
  17953. Dictionary<char, string> Number = new Dictionary<char, string>();
  17954. Number.Add('1', "一");
  17955. Number.Add('2', "二");
  17956. Number.Add('3', "三");
  17957. Number.Add('4', "四");
  17958. Number.Add('5', "五");
  17959. Number.Add('6', "六");
  17960. Number.Add('7', "七");
  17961. Number.Add('8', "八");
  17962. Number.Add('9', "九");
  17963. string stringNumberVal = string.Empty;
  17964. for (int i = 0; i < numberval.Length; i++)
  17965. {
  17966. if (i == 0)
  17967. {
  17968. stringNumberVal += Number[numberval[i]];
  17969. }
  17970. else if (i >= 1)
  17971. {
  17972. if (numberval[i] == '0')
  17973. {
  17974. stringNumberVal = "十";
  17975. }
  17976. else
  17977. {
  17978. stringNumberVal += "十" + Number[numberval[i]];
  17979. }
  17980. }
  17981. }
  17982. return stringNumberVal;
  17983. }
  17984. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  17985. {
  17986. //获取table中的某个单元格,从0开始
  17987. Cell lshCell = table.Rows[rows].Cells[cells];
  17988. //将单元格中段落移除
  17989. foreach (Node item in lshCell.Paragraphs)
  17990. {
  17991. lshCell.Paragraphs.Remove(item);
  17992. }
  17993. if (val.Contains("\r\n"))
  17994. {
  17995. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  17996. foreach (var item in spArr)
  17997. {
  17998. //新建一个段落
  17999. Paragraph p = new Paragraph(doc);
  18000. var r = new Run(doc, item);
  18001. //把设置的值赋给之前新建的段落
  18002. p.AppendChild(r);
  18003. //将此段落加到单元格内
  18004. lshCell.AppendChild(p);
  18005. }
  18006. }
  18007. else
  18008. {
  18009. //新建一个段落
  18010. Paragraph p = new Paragraph(doc);
  18011. var r = new Run(doc, val);
  18012. //把设置的值赋给之前新建的段落
  18013. p.AppendChild(r);
  18014. //将此段落加到单元格内
  18015. lshCell.AppendChild(p);
  18016. }
  18017. }
  18018. [HttpPost]
  18019. public async Task<IActionResult> ServerHttp(string paramStr)
  18020. {
  18021. paramStr = paramStr.TrimEnd('\'');
  18022. paramStr = paramStr.TrimStart('\'');
  18023. JsonView jw = JsonView(false);
  18024. JObject param = JObject.Parse(paramStr);
  18025. if (!param.ContainsKey("url"))
  18026. {
  18027. jw.Msg = "url null";
  18028. return Ok(jw);
  18029. }
  18030. string url = param["url"]!.ToString();
  18031. var methon = "get";
  18032. Dictionary<string, string> headValues = null;
  18033. string bodyStr = string.Empty;
  18034. if (param.ContainsKey("methon"))
  18035. {
  18036. methon = param["methon"]!.ToString().ToLower();
  18037. }
  18038. if (param.ContainsKey("header"))
  18039. {
  18040. var header = param["header"]!.ToString();
  18041. JObject headerJobject = JObject.Parse(header);
  18042. headValues = new Dictionary<string, string>();
  18043. foreach (JProperty item in headerJobject.Properties())
  18044. {
  18045. var value = item.Value.ToString();
  18046. var head = item.Path;
  18047. headValues.Add(head, value);
  18048. }
  18049. }
  18050. HttpClient client = new HttpClient();
  18051. string responseString = string.Empty;
  18052. StringContent content = null;
  18053. if (headValues != null)
  18054. {
  18055. foreach (var item in headValues.Keys)
  18056. {
  18057. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  18058. {
  18059. if (param.ContainsKey("body"))
  18060. {
  18061. bodyStr = param["body"]!.ToString();
  18062. }
  18063. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  18064. }
  18065. else
  18066. {
  18067. client.DefaultRequestHeaders.Add(item, headValues[item]);
  18068. }
  18069. }
  18070. }
  18071. try
  18072. {
  18073. if (methon == "get")
  18074. {
  18075. responseString = await client.GetStringAsync(url);
  18076. }
  18077. else if (methon == "post")
  18078. {
  18079. var request = new HttpRequestMessage(HttpMethod.Post, url)
  18080. {
  18081. Content = content
  18082. };
  18083. var response = await client.SendAsync(request);
  18084. try
  18085. {
  18086. Stream responseStream = await response.Content.ReadAsStreamAsync();
  18087. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  18088. {
  18089. using (StreamReader reader = new StreamReader(gzipStream))
  18090. {
  18091. responseString = await reader.ReadToEndAsync();
  18092. }
  18093. }
  18094. }
  18095. catch (Exception)
  18096. {
  18097. responseString = await response.Content.ReadAsStringAsync();
  18098. }
  18099. }
  18100. else
  18101. {
  18102. responseString = "methon error";
  18103. }
  18104. jw = JsonView(true, "success", responseString);
  18105. }
  18106. catch (Exception ex)
  18107. {
  18108. jw.Msg = "error " + ex.Message;
  18109. jw.Data = ex.StackTrace;
  18110. }
  18111. finally
  18112. {
  18113. client.Dispose();
  18114. }
  18115. return Ok(jw);
  18116. }
  18117. #endregion
  18118. #region 团组接待意见调查
  18119. /// <summary>
  18120. /// 团组接待意见调查 - 信息管理
  18121. /// 基础数据(团组)
  18122. /// </summary>
  18123. /// <param name="dto"></param>
  18124. /// <returns></returns>
  18125. [HttpGet]
  18126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18127. public async Task<IActionResult> OpinionaireInit()
  18128. {
  18129. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  18130. .Select(x => new
  18131. {
  18132. x.Id,
  18133. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  18134. })
  18135. .OrderByDescending(x => x.Id)
  18136. .ToListAsync();
  18137. return Ok(JsonView(groupData, groupData.Count));
  18138. }
  18139. /// <summary>
  18140. /// 团组接待意见调查 - 信息管理
  18141. /// 列表
  18142. /// </summary>
  18143. /// <param name="groupId"></param>
  18144. /// <returns></returns>
  18145. [HttpGet("{groupId}")]
  18146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18147. public async Task<IActionResult> OpinionaireManageList(int groupId)
  18148. {
  18149. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18150. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  18151. .Select(x => new
  18152. {
  18153. x.Id,
  18154. x.TourGuideName,
  18155. x.CityName,
  18156. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  18157. x.CreateTime
  18158. })
  18159. .OrderBy(x => x.Id)
  18160. .ToListAsync();
  18161. return Ok(JsonView(data));
  18162. }
  18163. /// <summary>
  18164. /// 团组接待意见调查 - 信息管理
  18165. /// 保存
  18166. /// </summary>
  18167. /// <param name="dto"></param>
  18168. /// <returns></returns>
  18169. [HttpPost]
  18170. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18171. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  18172. {
  18173. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18174. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18175. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18176. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  18177. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  18178. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  18179. _opinionaireRep.BeginTran();
  18180. if (addData != null && addData.Count > 0)
  18181. {
  18182. foreach (var item in addData)
  18183. {
  18184. item.CreateUserId = currUserInfo.UserId;
  18185. item.DiId = dto.DiId;
  18186. }
  18187. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  18188. }
  18189. if (updData != null && updData.Count > 0)
  18190. {
  18191. var upd = await _opinionaireRep._sqlSugar
  18192. .Updateable(updData)
  18193. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  18194. .WhereColumns(x => new { x.Id })
  18195. .ExecuteCommandAsync();
  18196. }
  18197. _opinionaireRep.CommitTran();
  18198. return Ok(JsonView("操作成功!"));
  18199. }
  18200. /// <summary>
  18201. /// 团组接待意见调查 - 信息管理
  18202. /// 删除
  18203. /// </summary>
  18204. /// <param name="id"></param>
  18205. /// <returns></returns>
  18206. [HttpDelete("{id}")]
  18207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18208. public async Task<IActionResult> OpinionaireManageDel(int id)
  18209. {
  18210. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18211. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18212. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  18213. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  18214. if (!del) return Ok(JsonView("操作失败!"));
  18215. return Ok(JsonView("操作成功!"));
  18216. }
  18217. /// <summary>
  18218. /// 团组接待意见调查 - 用户
  18219. /// 列表
  18220. /// </summary>
  18221. /// <param name="id"></param>
  18222. /// <returns></returns>
  18223. [HttpGet("{diId}")]
  18224. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18225. public async Task<IActionResult> OpinionaireUserList(int diId)
  18226. {
  18227. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18228. var sql = string.Format(@"
  18229. SELECT
  18230. o.Id,
  18231. o.DiId,
  18232. di.TeamName AS 'GroupName',
  18233. di.VisitPNumber AS 'PeopleNumber',
  18234. di.ClientName AS 'LeadGroup',
  18235. di.VisitCountry AS 'Travel',
  18236. di.VisitDays AS 'Days',
  18237. o.CityName,
  18238. o.TourGuideName,
  18239. o.Catering,
  18240. o.CateringReason,
  18241. o.Stay,
  18242. o.StayReason,
  18243. o.[Route],
  18244. o.RouteReason,
  18245. o.OfficialActivity,
  18246. o.OfficialActivityReason,
  18247. o.TourGuide,
  18248. o.TourGuideReason,
  18249. o.[Translate],
  18250. o.TranslateReason,
  18251. o.Trip,
  18252. o.TripReason,
  18253. o.ESFileName,
  18254. o.SignatureDate,
  18255. o.Remark
  18256. FROM
  18257. Grp_Opinionaire o
  18258. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  18259. WHERE
  18260. o.IsDel = 0
  18261. AND o.DiId = {0}
  18262. ORDER BY
  18263. o.Id ASC", diId);
  18264. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  18265. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  18266. return Ok(JsonView(data));
  18267. }
  18268. /// <summary>
  18269. /// 团组接待意见调查 - 用户
  18270. /// 保存
  18271. /// </summary>
  18272. /// <param name="id"></param>
  18273. /// <returns></returns>
  18274. [HttpPost]
  18275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18276. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  18277. {
  18278. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  18279. foreach (var item in dto)
  18280. {
  18281. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  18282. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  18283. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  18284. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  18285. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  18286. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  18287. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  18288. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  18289. }
  18290. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  18291. if (!Directory.Exists(filePathBase))
  18292. {
  18293. Directory.CreateDirectory(filePathBase);
  18294. }
  18295. #region 上传文件
  18296. var filePaths = new List<string>();
  18297. foreach (var item in dto)
  18298. {
  18299. var file = item.File;
  18300. // 将文件保存到指定位置
  18301. var filePath = Path.Combine(filePathBase, file.FileName);
  18302. using (var stream = new FileStream(filePath, FileMode.Create))
  18303. {
  18304. await file.CopyToAsync(stream);
  18305. }
  18306. //验证文件是否上传成功
  18307. if (!System.IO.File.Exists(filePath))
  18308. {
  18309. foreach (var filePathStr in filePaths)
  18310. {
  18311. System.IO.File.Delete(filePathStr);
  18312. }
  18313. return Ok(JsonView(false, "文件上传失败!"));
  18314. }
  18315. item.ESFileName = file.FileName;
  18316. }
  18317. #endregion
  18318. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  18319. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  18320. .UpdateColumns(x => new
  18321. {
  18322. x.Catering,
  18323. x.CateringReason,
  18324. x.Stay,
  18325. x.StayReason,
  18326. x.Route,
  18327. x.RouteReason,
  18328. x.OfficialActivity,
  18329. x.OfficialActivityReason,
  18330. x.TourGuide,
  18331. x.TourGuideReason,
  18332. x.Translate,
  18333. x.TranslateReason,
  18334. x.Trip,
  18335. x.TripReason,
  18336. x.ESFileName,
  18337. x.SignatureDate,
  18338. x.Remark
  18339. })
  18340. .WhereColumns(x => new { x.Id })
  18341. .ExecuteCommandAsync();
  18342. if (upd < 1)
  18343. {
  18344. foreach (var filePathStr in filePaths)
  18345. {
  18346. System.IO.File.Delete(filePathStr);
  18347. }
  18348. return Ok(JsonView(false));
  18349. }
  18350. return Ok(JsonView(true));
  18351. }
  18352. #endregion
  18353. #region 团组餐厅相关信息
  18354. /// <summary>
  18355. /// 团组相关餐厅信息
  18356. /// 基础数据(团组)
  18357. /// </summary>
  18358. /// <returns></returns>
  18359. [HttpGet]
  18360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18361. public async Task<IActionResult> RestaurantInit()
  18362. {
  18363. return Ok(await _restaurantRep.InitAsync());
  18364. }
  18365. /// <summary>
  18366. /// 团组相关餐厅信息
  18367. /// Item
  18368. /// </summary>
  18369. /// <param name="dto"></param>
  18370. /// <returns></returns>
  18371. [HttpPost]
  18372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18373. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  18374. {
  18375. int portType = dto.PortType,
  18376. groupId = dto.GroupId;
  18377. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false,MsgTips.Port));
  18378. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18379. return Ok(await _restaurantRep.ItemAsync(portType,groupId));
  18380. }
  18381. /// <summary>
  18382. /// 团组相关餐厅信息
  18383. /// List
  18384. /// </summary>
  18385. /// <param name="dto"></param>
  18386. /// <returns></returns>
  18387. [HttpPost]
  18388. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18389. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  18390. {
  18391. int portType = dto.PortType,
  18392. groupId = dto.GroupId;
  18393. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18394. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18395. var sql = string.Format(@" SELECT
  18396. ri.Id,
  18397. ri.GroupId,
  18398. ri.Date,
  18399. ri.StartTime,
  18400. ri.EndTime,
  18401. CASE WHEN ri.Type = 1 THEN '早餐'
  18402. WHEN ri.Type = 2 THEN '午餐'
  18403. WHEN ri.Type = 3 THEN '晚餐'
  18404. ELSE '其他'
  18405. END AS 'Type',
  18406. ri.Name,
  18407. ri.Address,
  18408. ri.Tel,
  18409. ri.Remark,
  18410. ri.CreateTime,
  18411. u.CnName AS CreateUserName
  18412. FROM
  18413. Grp_RestaurantInfo ri
  18414. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  18415. WHERE
  18416. ri.IsDel = 0
  18417. AND ri.GroupId = {0}
  18418. ORDER BY
  18419. ri.Date ASC
  18420. ", groupId);
  18421. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  18422. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  18423. return Ok(JsonView(infos));
  18424. }
  18425. /// <summary>
  18426. /// 团组相关餐厅信息
  18427. /// Info
  18428. /// </summary>
  18429. /// <param name="dto"></param>
  18430. /// <returns></returns>
  18431. [HttpPost]
  18432. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18433. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  18434. {
  18435. int portType = dto.PortType,
  18436. id = dto.Id;
  18437. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18438. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18439. return Ok(await _restaurantRep.InfoAsync(portType, id));
  18440. }
  18441. /// <summary>
  18442. /// 团组相关餐厅信息
  18443. /// Op
  18444. /// </summary>
  18445. /// <param name="dto"></param>
  18446. /// <returns></returns>
  18447. [HttpPost]
  18448. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18449. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  18450. {
  18451. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18452. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18453. if ( string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  18454. return Ok(await _restaurantRep.OpAsync(dto));
  18455. }
  18456. /// <summary>
  18457. /// 团组相关餐厅信息
  18458. /// Del
  18459. /// </summary>
  18460. /// <param name="dto"></param>
  18461. /// <returns></returns>
  18462. [HttpPost]
  18463. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18464. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  18465. {
  18466. int userId = dto.DeleteUserId;
  18467. var id = dto.Id;
  18468. if (userId < 1) return Ok( JsonView(false, MsgTips.UserId));
  18469. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18470. return Ok(await _restaurantRep.DelAsync(dto));
  18471. }
  18472. #endregion
  18473. // /// <summary>
  18474. // ///
  18475. // /// </summary>
  18476. // /// <param name="_dto"></param>
  18477. // /// <returns></returns>
  18478. // [HttpPost]
  18479. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18480. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18481. // {
  18482. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18483. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  18484. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  18485. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18486. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  18487. // dic_psg.Add("客人", 974);
  18488. // dic_psg.Add("司机", 975);
  18489. // dic_psg.Add("导游", 976);
  18490. // dic_psg.Add("公司内部人员", 977);
  18491. // dic_psg.Add("司机/导游/公司内部人员", 978);
  18492. // foreach (var item in list_visa)
  18493. // {
  18494. // Grp_VisaInfo temp = new Grp_VisaInfo();
  18495. // temp.Id = item.Id;
  18496. // temp.DIId = item.DIId;
  18497. // temp.VisaClient = item.VisaClient;
  18498. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  18499. // temp.VisaCurrency = item.VisaCurrency;
  18500. // temp.IsThird = item.IsThird;
  18501. // if (dic_psg.ContainsKey(item.PassengerType))
  18502. // {
  18503. // temp.PassengerType = dic_psg[item.PassengerType];
  18504. // }
  18505. // else {
  18506. // temp.PassengerType = -1;
  18507. // }
  18508. // temp.VisaNumber = item.VisaNumber;
  18509. // temp.VisaFreeNumber = item.VisaFreeNumber;
  18510. // temp.CreateUserId = item.Operators;
  18511. // DateTime dt_ct;
  18512. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  18513. // if (b_ct)
  18514. // {
  18515. // temp.CreateTime = dt_ct;
  18516. // }
  18517. // else
  18518. // {
  18519. // temp.CreateTime = DateTime.Now;
  18520. // }
  18521. // temp.DeleteTime = "";
  18522. // temp.DeleteUserId = 0;
  18523. // temp.Remark = item.Remark;
  18524. // if (string.IsNullOrEmpty(temp.Remark)) {
  18525. // temp.Remark = "";
  18526. // }
  18527. // temp.IsDel = item.IsDel;
  18528. // temp.VisaDescription = item.VisaAttachment;
  18529. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  18530. //([Id]
  18531. // ,[DIId]
  18532. // ,[VisaClient]
  18533. // ,[VisaPrice]
  18534. // ,[VisaCurrency]
  18535. // ,[IsThird]
  18536. // ,[PassengerType]
  18537. // ,[VisaNumber]
  18538. // ,[VisaFreeNumber]
  18539. // ,[CreateUserId]
  18540. // ,[CreateTime]
  18541. // ,[DeleteTime]
  18542. // ,[DeleteUserId]
  18543. // ,[Remark]
  18544. // ,[IsDel]
  18545. // ,[visaDescription])
  18546. // VALUES
  18547. // ({0},{1},'{2}',{3},{4}
  18548. //,{5},{6},{7},{8},{9}
  18549. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  18550. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  18551. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  18552. //);
  18553. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  18554. // }
  18555. // return Ok(JsonView(true, "操作成功!"));
  18556. // }
  18557. /// <summary>
  18558. /// 123132123
  18559. /// </summary>
  18560. /// <param name="_dto"></param>
  18561. /// <returns></returns>
  18562. [HttpPost]
  18563. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18564. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18565. {
  18566. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18567. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  18568. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  18569. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18570. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  18571. dicDetail.Add(789, 1034);
  18572. dicDetail.Add(790, 1035);
  18573. dicDetail.Add(791, 1036);
  18574. dicDetail.Add(792, 1037);
  18575. dicDetail.Add(793, 1038);
  18576. dicDetail.Add(794, 1039);
  18577. dicDetail.Add(795, 1040);
  18578. dicDetail.Add(796, 1041);
  18579. dicDetail.Add(797, 1042);
  18580. dicDetail.Add(798, 1043);
  18581. dicDetail.Add(801, 1044);
  18582. dicDetail.Add(802, 1045);
  18583. dicDetail.Add(803, 1046);
  18584. Dictionary<int, int> dic = new Dictionary<int, int>();
  18585. dic.Add(806, 1027);
  18586. dic.Add(807, 1028);
  18587. dic.Add(808, 1029);
  18588. dic.Add(809, 1030);
  18589. dic.Add(810, 1031);
  18590. dic.Add(811, 1032);
  18591. dic.Add(812, 1033);
  18592. foreach (var item in list_visa)
  18593. {
  18594. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  18595. temp.Coefficient = item.coefficient;
  18596. DateTime dtCrt;
  18597. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  18598. if (b1)
  18599. {
  18600. temp.CreateTime = dtCrt;
  18601. }
  18602. else
  18603. {
  18604. temp.CreateTime = DateTime.Now;
  18605. }
  18606. temp.CreateUserId = item.Operators;
  18607. temp.DeleteTime = "";
  18608. temp.DeleteUserId = 0;
  18609. temp.DiId = int.Parse(item.DIID);
  18610. temp.FilePath = item.FilePath;
  18611. temp.IsDel = item.IsDel;
  18612. temp.Price = item.Price;
  18613. temp.PriceCount = 1;
  18614. temp.PriceCurrency = item.Currency;
  18615. int detailId = 0;
  18616. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  18617. {
  18618. detailId = dicDetail[item.PriceTypeDetail];
  18619. }
  18620. temp.PriceDetailType = detailId;
  18621. temp.PriceDt = DateTime.Now;
  18622. temp.PriceName = item.PriceName;
  18623. temp.PriceSum = item.Price;
  18624. int tid = 0;
  18625. if (dic.ContainsKey(item.PriceType))
  18626. {
  18627. tid = dic[item.PriceType];
  18628. }
  18629. temp.PriceType = tid;
  18630. temp.Remark = item.Remark;
  18631. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  18632. }
  18633. return Ok(JsonView(true, "操作成功!"));
  18634. }
  18635. [HttpPost]
  18636. public IActionResult TimeTest()
  18637. {
  18638. var jw = JsonView(false, "error");
  18639. _sqlSugar.BeginTran();
  18640. try
  18641. {
  18642. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  18643. .Select(x => new Crm_NewClientData
  18644. {
  18645. Id = x.Id,
  18646. Client = x.Client,
  18647. Contact = x.Contact,
  18648. Location = x.Location,
  18649. })
  18650. .ToList();
  18651. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x=>x.Id).ToList();
  18652. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  18653. Stopwatch stopwatch = new Stopwatch();
  18654. // 开始计时
  18655. stopwatch.Start();
  18656. foreach (var item in clientList)
  18657. {
  18658. EncryptionProcessor.DecryptProperties(item);
  18659. }
  18660. stopwatch.Stop();
  18661. jw.Code = 200;
  18662. jw.Data = stopwatch.ElapsedMilliseconds;
  18663. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  18664. }
  18665. catch (Exception ex)
  18666. {
  18667. jw.Code = 400;
  18668. jw.Msg = ex.Message;
  18669. }
  18670. return Ok(jw);
  18671. }
  18672. }
  18673. }