GroupsController.cs 662 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Tables;
  4. using Microsoft.AspNetCore.SignalR;
  5. using NPOI.HSSF.UserModel;
  6. using NPOI.SS.UserModel;
  7. using NPOI.SS.Util;
  8. using NPOI.XSSF.UserModel;
  9. using OASystem.API.OAMethodLib;
  10. using OASystem.API.OAMethodLib.File;
  11. using OASystem.API.OAMethodLib.Hub.HubClients;
  12. using OASystem.API.OAMethodLib.Hub.Hubs;
  13. using OASystem.API.OAMethodLib.JuHeAPI;
  14. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  15. using OASystem.Domain.Dtos.CRM;
  16. using OASystem.Domain.Dtos.FileDto;
  17. using OASystem.Domain.Dtos.Groups;
  18. using OASystem.Domain.Entities.Customer;
  19. using OASystem.Domain.Entities.Financial;
  20. using OASystem.Domain.Entities.Groups;
  21. using OASystem.Domain.ViewModels.Groups;
  22. using OASystem.Infrastructure.Repositories.Groups;
  23. using Quartz.Util;
  24. using SqlSugar.Extensions;
  25. using System.Collections;
  26. using System.Data;
  27. using System.Diagnostics;
  28. using System.Globalization;
  29. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  30. using Bookmark = Aspose.Words.Bookmark;
  31. using Cell = Aspose.Words.Tables.Cell;
  32. using Table = Aspose.Words.Tables.Table;
  33. namespace OASystem.API.Controllers
  34. {
  35. /// <summary>
  36. /// 团组相关
  37. /// </summary>
  38. //[Authorize]
  39. [Route("api/[controller]/[action]")]
  40. public class GroupsController : ControllerBase
  41. {
  42. private readonly ILogger<GroupsController> _logger;
  43. private readonly GrpScheduleRepository _grpScheduleRep;
  44. private readonly IMapper _mapper;
  45. private readonly DelegationInfoRepository _groupRepository;
  46. private readonly TaskAssignmentRepository _taskAssignmentRep;
  47. private readonly AirTicketResRepository _airTicketResRep;
  48. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  49. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  50. private readonly DelegationEnDataRepository _delegationEnDataRep;
  51. private readonly DelegationVisaRepository _delegationVisaRep;
  52. private readonly VisaPriceRepository _visaPriceRep;
  53. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  54. private readonly HotelPriceRepository _hotelPriceRep;
  55. private readonly CustomersRepository _customersRep;
  56. private readonly MessageRepository _message;
  57. private readonly SqlSugarClient _sqlSugar;
  58. private readonly TourClientListRepository _tourClientListRep;
  59. private readonly TeamRateRepository _teamRateRep;
  60. #region 成本相关
  61. private readonly CheckBoxsRepository _checkBoxs;
  62. private readonly GroupCostRepository _GroupCostRepository;
  63. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  64. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  65. #endregion
  66. private readonly SetDataRepository _setDataRep;
  67. private string url;
  68. private string path;
  69. private readonly EnterExitCostRepository _enterExitCostRep;
  70. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  71. private readonly UsersRepository _usersRep;
  72. private readonly IJuHeApiService _juHeApi;
  73. private readonly InvertedListRepository _invertedListRep;
  74. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  75. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  76. private readonly ThreeCodeRepository _threeCodeRepository;
  77. private readonly HotelInquiryRepository _hotelInquiryRep;
  78. private readonly FeeAuditRepository _feeAuditRep;
  79. private readonly VisaCommissionRepository _visaCommissionRep;
  80. public GroupsController(ILogger<GroupsController> logger, IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  81. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  82. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  83. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  84. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  85. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  86. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  87. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep,
  88. ThreeCodeRepository threeCodeRepository, FeeAuditRepository feeAuditRep, VisaCommissionRepository visaCommissionRep)
  89. {
  90. _logger = logger;
  91. _mapper = mapper;
  92. _grpScheduleRep = grpScheduleRep;
  93. _groupRepository = groupRepository;
  94. _taskAssignmentRep = taskAssignmentRep;
  95. _airTicketResRep = airTicketResRep;
  96. _sqlSugar = sqlSugar;
  97. url = AppSettingsHelper.Get("ExcelBaseUrl");
  98. path = AppSettingsHelper.Get("ExcelBasePath");
  99. if (!System.IO.Directory.Exists(path))
  100. {
  101. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  102. }
  103. _decreasePaymentsRep = decreasePaymentsRep;
  104. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  105. _delegationEnDataRep = delegationEnDataRep;
  106. _enterExitCostRep = enterExitCostRep;
  107. _delegationVisaRep = delegationVisaRep;
  108. _message = message;
  109. _visaPriceRep = visaPriceRep;
  110. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  111. _checkBoxs = checkBoxs;
  112. _GroupCostRepository = GroupCostRepository;
  113. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  114. _GroupCostParameterRepository = GroupCostParameterRepository;
  115. _hotelPriceRep = hotelPriceRep;
  116. _customersRep = customersRep;
  117. _setDataRep = setDataRep;
  118. _tourClientListRep = tourClientListRep;
  119. _teamRateRep = teamRateRep;
  120. _hubContext = hubContext;
  121. _usersRep = usersRep;
  122. _juHeApi = juHeApi;
  123. _invertedListRep = invertedListRep;
  124. _visaFeeInfoRep = visaFeeInfoRep;
  125. _ticketBlackCodeRep = ticketBlackCodeRep;
  126. _hotelInquiryRep = hotelInquiryRep;
  127. _threeCodeRepository = threeCodeRepository;
  128. _feeAuditRep = feeAuditRep;
  129. _visaCommissionRep = visaCommissionRep;
  130. }
  131. #region 流程管控
  132. /// <summary>
  133. /// 获取团组流程管控信息
  134. /// </summary>
  135. /// <param name="paras">参数Json字符串</param>
  136. /// <returns></returns>
  137. [HttpPost]
  138. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  139. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  140. {
  141. if (string.IsNullOrEmpty(_jsonDto.Paras))
  142. {
  143. return Ok(JsonView(false, "参数为空"));
  144. }
  145. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  146. if (_ScheduleDto != null)
  147. {
  148. if (_ScheduleDto.SearchType == 2)//获取列表
  149. {
  150. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  151. return Ok(JsonView(_grpScheduleViewList));
  152. }
  153. else//获取对象
  154. {
  155. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  156. if (_grpScheduleView != null)
  157. {
  158. return Ok(JsonView(_grpScheduleView));
  159. }
  160. }
  161. }
  162. else
  163. {
  164. return Ok(JsonView(false, "参数反序列化失败"));
  165. }
  166. return Ok(JsonView(false, "暂无数据!"));
  167. }
  168. /// <summary>
  169. /// 修改团组流程管控详细表数据
  170. /// </summary>
  171. /// <param name="paras"></param>
  172. /// <returns></returns>
  173. [HttpPost]
  174. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  175. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  176. {
  177. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  178. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  179. .SetColumns(it => it.Duty == _detail.Duty)
  180. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  181. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  182. .SetColumns(it => it.JobContent == _detail.JobContent)
  183. .SetColumns(it => it.Remark == _detail.Remark)
  184. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  185. .Where(s => s.Id == dto.Id)
  186. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  187. .ExecuteCommandAsync();
  188. if (result > 0)
  189. {
  190. return Ok(JsonView(true, "保存成功!"));
  191. }
  192. return Ok(JsonView(false, "保存失败!"));
  193. }
  194. /// <summary>
  195. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  196. /// </summary>
  197. /// <param name="dto"></param>
  198. /// <returns></returns>
  199. [HttpPost]
  200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  201. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  202. {
  203. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  204. _detail.IsDel = 1;
  205. _detail.DeleteUserId = dto.Duty;
  206. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  207. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  208. .SetColumns(it => it.IsDel == _detail.IsDel)
  209. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  210. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  211. .Where(it => it.Id == dto.Id)
  212. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  213. //.WhereColumns(s => s.Id == dto.Id)
  214. .ExecuteCommandAsync();
  215. if (result > 0)
  216. {
  217. return Ok(JsonView(true, "删除成功!"));
  218. }
  219. return Ok(JsonView(false, "删除失败!"));
  220. }
  221. /// <summary>
  222. /// 增加团组流程管控详细表数据
  223. /// </summary>
  224. /// <param name="dto"></param>
  225. /// <returns></returns>
  226. [HttpPost]
  227. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  228. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  229. {
  230. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  231. if (DateTime.Now < _detail.ExpectBeginDt)
  232. {
  233. _detail.StepStatus = 0;
  234. }
  235. else
  236. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  237. _detail.StepStatus = 1;
  238. }
  239. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  240. if (result > 0)
  241. {
  242. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  243. return Ok(JsonView(true, "添加成功!", _result));
  244. }
  245. return Ok(JsonView(false, "添加失败!"));
  246. }
  247. #endregion
  248. #region 团组基本信息
  249. /// <summary>
  250. /// 接团信息列表
  251. /// </summary>
  252. /// <param name="dto">团组列表请求dto</param>
  253. /// <returns></returns>
  254. [HttpPost]
  255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  256. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  257. {
  258. var groupData = await _groupRepository.GetGroupList(dto);
  259. if (groupData.Code != 0)
  260. {
  261. return Ok(JsonView(false, groupData.Msg));
  262. }
  263. return Ok(JsonView(groupData.Data));
  264. }
  265. /// <summary>
  266. /// 分页查询团组列表
  267. /// </summary>
  268. /// <param name="dto"></param>
  269. /// <returns></returns>
  270. [HttpPost]
  271. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  272. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  273. {
  274. var watch = new Stopwatch();
  275. watch.Start();
  276. RefAsync<int> total = 0;
  277. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  278. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  279. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  280. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  281. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName , di.VisitPNumber , di.VisitCountry, di.VisitDays, di.VisitStartDate , di.VisitEndDate, di.TourCode })
  282. .Distinct()
  283. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  284. watch.Stop();
  285. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  286. }
  287. /// <summary>
  288. /// 接团信息列表 Page
  289. /// </summary>
  290. /// <param name="dto">团组列表请求dto</param>
  291. /// <returns></returns>
  292. [HttpPost]
  293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  294. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  295. {
  296. #region 参数验证
  297. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  298. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  299. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  300. #region 页面操作权限验证
  301. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  302. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  303. #endregion
  304. #endregion
  305. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  306. {
  307. string sqlWhere = string.Empty;
  308. if (dto.IsSure == 0) //未完成
  309. {
  310. sqlWhere += string.Format(@" And IsSure = 0");
  311. }
  312. else if (dto.IsSure == 1) //已完成
  313. {
  314. sqlWhere += string.Format(@" And IsSure = 1");
  315. }
  316. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  317. {
  318. string tj = dto.SearchCriteria;
  319. 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}%')",
  320. tj, tj, tj, tj, tj);
  321. }
  322. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  323. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  324. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  325. JietuanOperator,IsSure,CreateTime,IsBid
  326. From (
  327. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  328. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  329. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  330. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  331. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  332. From Grp_DelegationInfo gdi
  333. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  334. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  335. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  336. Where gdi.IsDel = 0 {0}
  337. ) temp", sqlWhere);
  338. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  339. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  340. #region 处理所属部门
  341. /*
  342. * 1.sq 和 gyy 等显示 市场部
  343. * 2.王鸽和主管及张总还有管理员号统一国交部
  344. * 2-1. 4 管理员 ,21 张海麟
  345. */
  346. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  347. List<int> userIds1 = new List<int>() { 4, 21 };
  348. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  349. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  350. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  351. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  352. .ToList();
  353. foreach (var item in _DelegationList)
  354. {
  355. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  356. }
  357. #endregion
  358. var _view = new
  359. {
  360. PageFuncAuth = pageFunAuthView,
  361. Data = _DelegationList
  362. };
  363. return Ok(JsonView(true, "查询成功!", _view, total));
  364. }
  365. else
  366. {
  367. return Ok(JsonView(false, "查询失败"));
  368. }
  369. }
  370. /// <summary>
  371. /// 团组列表
  372. /// </summary>
  373. /// <returns></returns>
  374. [HttpPost]
  375. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  376. {
  377. #region 参数验证
  378. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  379. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  380. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  381. #region 页面操作权限验证
  382. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  383. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  384. #endregion
  385. #endregion
  386. if (dto.PortType != 1 && dto.PortType != 2)
  387. {
  388. return Ok(JsonView(false, "查询失败!"));
  389. }
  390. string orderbyStr = "order by gdi.CreateTime Desc";
  391. string sqlWhere = string.Empty;
  392. if (dto.IsSure == 0) //未完成
  393. {
  394. sqlWhere += string.Format(@" And IsSure = 0");
  395. }
  396. else if (dto.IsSure == 1) //已完成
  397. {
  398. sqlWhere += string.Format(@" And IsSure = 1");
  399. }
  400. //团组类型
  401. if (dto.TeamDid > 0)
  402. {
  403. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  404. }
  405. //团组名称
  406. if (!string.IsNullOrEmpty(dto.TeamName))
  407. {
  408. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  409. }
  410. //客户名称
  411. if (!string.IsNullOrEmpty(dto.ClientName))
  412. {
  413. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  414. }
  415. //客户单位
  416. if (!string.IsNullOrEmpty(dto.ClientUnit))
  417. {
  418. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  419. }
  420. //出访时间
  421. if (!string.IsNullOrEmpty(dto.visitDataTime))
  422. {
  423. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  424. orderbyStr = "order by gdi.VisitDate";
  425. }
  426. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  427. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  428. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  429. JietuanOperator,IsSure,CreateTime
  430. From (
  431. Select row_number() over({0}) as Row_Number,
  432. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  433. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  434. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  435. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  436. From Grp_DelegationInfo gdi
  437. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  438. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  439. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  440. Where gdi.IsDel = 0 {1}
  441. ) temp ", orderbyStr, sqlWhere);
  442. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  443. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  444. #region 处理所属部门
  445. /*
  446. * 1.sq 和 gyy 等显示 市场部
  447. * 2.王鸽和主管及张总还有管理员号统一国交部
  448. * 2-1. 4 管理员 ,21 张海麟
  449. */
  450. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  451. List<int> userIds1 = new List<int>() { 4, 21 };
  452. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  453. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  454. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  455. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  456. .ToList();
  457. foreach (var item in _DelegationList)
  458. {
  459. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  460. }
  461. #endregion
  462. var _view = new
  463. {
  464. PageFuncAuth = pageFunAuthView,
  465. Data = _DelegationList
  466. };
  467. return Ok(JsonView(true, "查询成功!", _view, total));
  468. }
  469. /// <summary>
  470. /// 接团信息详情
  471. /// </summary>
  472. /// <param name="dto">团组info请求dto</param>
  473. /// <returns></returns>
  474. [HttpPost]
  475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  476. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  477. {
  478. var groupData = await _groupRepository.GetGroupInfo(dto);
  479. if (groupData.Code != 0)
  480. {
  481. return Ok(JsonView(false, groupData.Msg));
  482. }
  483. return Ok(JsonView(groupData.Data));
  484. }
  485. /// <summary>
  486. /// 接团信息 编辑添加
  487. /// 基础信息数据源
  488. /// </summary>
  489. /// <param name="dto"></param>
  490. /// <returns></returns>
  491. [HttpPost]
  492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  493. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  494. {
  495. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  496. if (groupData.Code != 0)
  497. {
  498. return Ok(JsonView(false, groupData.Msg));
  499. }
  500. return Ok(JsonView(groupData.Data));
  501. }
  502. /// <summary>
  503. /// 接团信息 操作(增改)
  504. /// </summary>
  505. /// <param name="dto"></param>
  506. /// <returns></returns>
  507. [HttpPost]
  508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  509. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  510. {
  511. try
  512. {
  513. var groupData = await _groupRepository.GroupOperation(dto);
  514. if (groupData.Code != 0)
  515. {
  516. return Ok(JsonView(false, groupData.Msg));
  517. }
  518. int diId = 0;
  519. //添加时 默认加入团组汇率
  520. if (dto.Status == 1) //添加
  521. {
  522. diId = groupData.Data;
  523. //添加默认币种
  524. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  525. //默认分配权限
  526. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  527. //消息提示 王鸽 主管号
  528. List<int> _managerIds = new List<int>() { 22, 32 };
  529. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  530. if (userIds.Count > 0)
  531. {
  532. userIds.Add(208);
  533. //创建团组管控
  534. GroupStepForDelegation.CreateWorkStep(diId);
  535. //发送消息
  536. string groupName = dto.TeamName;
  537. string createGroupUser = string.Empty;
  538. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  539. if (userInfo != null) createGroupUser = userInfo.CnName;
  540. string title = $"系统通知";
  541. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  542. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  543. }
  544. //默认创建倒推表
  545. await _invertedListRep._Create(dto.UserId, diId);
  546. }
  547. else if (dto.Status == 2)
  548. {
  549. diId = dto.Id;
  550. }
  551. return Ok(JsonView(true, "操作成功!", diId));
  552. }
  553. catch (Exception ex)
  554. {
  555. Logs("[response]" + JsonConvert.SerializeObject(dto));
  556. Logs(ex.Message);
  557. return Ok(JsonView(false, ex.Message));
  558. }
  559. }
  560. /// <summary>
  561. /// 接团流程操作(增改)
  562. /// 安卓端使用 建团时添加客户名单
  563. /// </summary>
  564. /// <param name="dto"></param>
  565. /// <returns></returns>
  566. [HttpPost]
  567. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  568. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  569. {
  570. try
  571. {
  572. #region 参数验证
  573. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  574. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  575. #region 页面操作权限验证
  576. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  577. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  578. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  579. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  580. #endregion
  581. #endregion
  582. _sqlSugar.BeginTran();
  583. var _dto = new GroupOperationDto();
  584. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  585. var groupData = await _groupRepository.GroupOperation(_dto);
  586. if (groupData.Code != 0)
  587. {
  588. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  589. }
  590. int diId = 0;
  591. //添加时 默认加入团组汇率
  592. if (dto.Status == 1) //添加
  593. {
  594. diId = groupData.Data;
  595. //添加默认币种
  596. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  597. //默认分配权限
  598. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  599. //消息提示 王鸽 主管号
  600. List<int> _managerIds = new List<int>() { 22, 32 };
  601. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  602. if (userIds.Count > 0)
  603. {
  604. userIds.Add(208);
  605. //创建团组管控
  606. GroupStepForDelegation.CreateWorkStep(diId);
  607. //发送消息
  608. string groupName = dto.TeamName;
  609. string createGroupUser = string.Empty;
  610. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  611. if (userInfo != null) createGroupUser = userInfo.CnName;
  612. string title = $"系统通知";
  613. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  614. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  615. }
  616. }
  617. if (dto.Status == 2)
  618. {
  619. diId = dto.Id;
  620. if (diId == 0)
  621. {
  622. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  623. }
  624. }
  625. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  626. if (viewData.Code != 0)
  627. {
  628. _sqlSugar.RollbackTran();
  629. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  630. }
  631. _sqlSugar.CommitTran();
  632. return Ok(JsonView(true, "添加成功"));
  633. }
  634. catch (Exception ex)
  635. {
  636. _sqlSugar.RollbackTran();
  637. return Ok(JsonView(false, ex.Message));
  638. }
  639. }
  640. /// <summary>
  641. /// 接团信息 操作(删除)
  642. /// </summary>
  643. /// <param name="dto"></param>
  644. /// <returns></returns>
  645. [HttpPost]
  646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  647. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  648. {
  649. try
  650. {
  651. var groupData = await _groupRepository.GroupDel(dto);
  652. if (groupData.Code != 0)
  653. {
  654. return Ok(JsonView(false, groupData.Msg));
  655. }
  656. return Ok(JsonView(true));
  657. }
  658. catch (Exception ex)
  659. {
  660. Logs("[response]" + JsonConvert.SerializeObject(dto));
  661. Logs(ex.Message);
  662. return Ok(JsonView(false, ex.Message));
  663. }
  664. }
  665. /// <summary>
  666. /// 获取团组销售报价号
  667. /// 团组添加时 使用
  668. /// </summary>
  669. /// <returns></returns>
  670. [HttpPost]
  671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  672. public async Task<IActionResult> GetGroupSalesQuoteNo()
  673. {
  674. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  675. if (groupData.Code != 0)
  676. {
  677. return Ok(JsonView(false, groupData.Msg));
  678. }
  679. object salesQuoteNo = new
  680. {
  681. SalesQuoteNo = groupData.Data
  682. };
  683. return Ok(JsonView(salesQuoteNo));
  684. }
  685. /// <summary>
  686. /// 设置确认出团
  687. /// </summary>
  688. /// <param name="dto"></param>
  689. /// <returns></returns>
  690. [HttpPost]
  691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  692. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  693. {
  694. var groupData = await _groupRepository.ConfirmationGroup(dto);
  695. if (groupData.Code != 0)
  696. {
  697. return Ok(JsonView(false, groupData.Msg));
  698. }
  699. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  700. #region OA消息推送
  701. try
  702. {
  703. string groupName = groupInfo.TeamName;
  704. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  705. List<int> userIds = new List<int>();
  706. listUser.ForEach(s => userIds.Add(s.Id));
  707. string title = $"系统通知";
  708. string content = $"团组[{groupName}]已确认出团!";
  709. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  710. }
  711. catch (Exception ex)
  712. {
  713. }
  714. #endregion
  715. #region 应用推送
  716. try
  717. {
  718. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  719. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  720. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  721. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  722. {
  723. List<string> userList = new List<string>() { users.QiyeChatUserId };
  724. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  725. }
  726. }
  727. catch (Exception ex)
  728. {
  729. }
  730. #endregion
  731. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  732. return Ok(JsonView(true, "操作成功!", groupData.Data));
  733. }
  734. /// <summary>
  735. /// 获取团组名称data And 签证国别Data
  736. /// </summary>
  737. /// <param name="dto"></param>
  738. /// <returns></returns>
  739. [HttpPost]
  740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  741. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  742. {
  743. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  744. if (groupData.Code != 0)
  745. {
  746. return Ok(JsonView(false, groupData.Msg));
  747. }
  748. return Ok(JsonView(groupData.Data));
  749. }
  750. /// <summary>
  751. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  752. /// </summary>
  753. /// <returns></returns>
  754. [HttpPost]
  755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  756. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  757. {
  758. try
  759. {
  760. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  761. if (groupData.Code != 0)
  762. {
  763. return Ok(JsonView(false, groupData.Msg));
  764. }
  765. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  766. }
  767. catch (Exception ex)
  768. {
  769. return Ok(JsonView(false, "程序错误!"));
  770. throw;
  771. }
  772. }
  773. #endregion
  774. #region 团组&签证
  775. /// <summary>
  776. /// 根据团组Id获取签证客户信息List
  777. /// </summary>
  778. /// <param name="dto">请求dto</param>
  779. /// <returns></returns>
  780. [HttpPost]
  781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  782. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  783. {
  784. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  785. if (groupData.Code != 0)
  786. {
  787. return Ok(JsonView(false, groupData.Msg));
  788. }
  789. return Ok(JsonView(groupData.Data));
  790. }
  791. /// <summary>
  792. /// IOS获取团组签证拍照上传进度01(团组列表)
  793. /// </summary>
  794. /// <param name="dto">请求dto</param>
  795. /// <returns></returns>
  796. [HttpPost]
  797. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  798. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  799. {
  800. if (dto == null)
  801. {
  802. return Ok(JsonView(false, "参数为空"));
  803. }
  804. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  805. return Ok(JsonView(visaList));
  806. }
  807. /// <summary>
  808. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  809. /// </summary>
  810. /// <returns></returns>
  811. [HttpPost]
  812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  813. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  814. {
  815. if (dto == null)
  816. {
  817. return Ok(JsonView(false, "请求错误:"));
  818. }
  819. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  820. return Ok(JsonView(list));
  821. }
  822. /// <summary>
  823. /// IOS获取团组签证拍照上传进度03(相册)
  824. /// </summary>
  825. /// <returns></returns>
  826. [HttpPost]
  827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  828. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  829. {
  830. if (dto == null)
  831. {
  832. return Ok(JsonView(false, "请求错误:"));
  833. }
  834. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  835. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  836. list.ForEach(s => s.url = url);
  837. return Ok(JsonView(list));
  838. }
  839. /// <summary>
  840. /// IOS获取团组签证拍照上传进度04(图片上传)
  841. /// </summary>
  842. /// <param name="dto"></param>
  843. /// <returns></returns>
  844. [HttpPost]
  845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  846. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  847. {
  848. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  849. //if (!string.IsNullOrEmpty(result))
  850. //{
  851. //}
  852. //else {
  853. // return Ok(JsonView(false, "上传失败"));
  854. //}
  855. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  856. int sucNum = 0;
  857. try
  858. {
  859. foreach (var item in dto.base64DataList)
  860. {
  861. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  862. string result = decodeBase64ToImage(item, imageName);
  863. if (!string.IsNullOrEmpty(result))
  864. {
  865. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  866. pic.CreateUserId = dto.CreateUserId;
  867. pic.PicName = imageName;
  868. pic.PicPath = result;
  869. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  870. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  871. if (insertResult > 0)
  872. {
  873. sucNum++;
  874. }
  875. }
  876. }
  877. }
  878. catch (Exception ex)
  879. {
  880. return Ok(JsonView(false, ex.Message));
  881. }
  882. string msg = string.Format(@"成功上传{0}张", sucNum);
  883. return Ok(JsonView(true, msg));
  884. }
  885. private string decodeBase64ToImage(string base64DataURL, string imgName)
  886. {
  887. string filename = "";//声明一个string类型的相对路径
  888. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  889. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  890. try//会有异常抛出,try,catch一下
  891. {
  892. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  893. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  894. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  895. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  896. //文件名称
  897. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  898. //上传的文件的路径
  899. string filePath = "";
  900. if (!Directory.Exists(fileDir))
  901. {
  902. Directory.CreateDirectory(fileDir);
  903. }
  904. //上传的文件的路径
  905. filePath = fileDir + filename;
  906. //string url = HttpRuntime.AppDomainAppPath.ToString();
  907. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  908. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  909. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  910. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  911. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  912. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  913. ms.Close();//关闭当前流,并释放所有与之关联的资源
  914. bitmap.Dispose();
  915. }
  916. catch (Exception e)
  917. {
  918. string massage = e.Message;
  919. Logs("IOS图片上传Error:" + massage);
  920. //filename = e.Message;
  921. }
  922. return filename;//返回相对路径
  923. }
  924. /// <summary>
  925. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  926. /// </summary>
  927. /// <param name="dto"></param>
  928. /// <returns></returns>
  929. [HttpPost]
  930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  931. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  932. {
  933. if (dto == null)
  934. {
  935. return Ok(JsonView(false, "请求错误:"));
  936. }
  937. string msg = "参数错误";
  938. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  939. {
  940. try
  941. {
  942. //_delegationVisaRep.BeginTran();
  943. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  944. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  945. .Where(s => s.Id == dto.visaProgressCustomerId)
  946. .ExecuteCommandAsync();
  947. if (updCount > 0 && dto.publishCode == 1)
  948. {
  949. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  950. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  951. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  952. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  953. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  954. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  955. if (groupData == null)
  956. {
  957. _delegationVisaRep.RollbackTran();
  958. }
  959. string title = string.Format(@"[签证进度更新]");
  960. string content = string.Format(@"测试文本");
  961. bool rst = await _message.AddMsg(new MessageDto()
  962. {
  963. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  964. IssuerId = dto.publisher,
  965. Title = title,
  966. Content = content,
  967. ReleaseTime = DateTime.Now,
  968. UIdList = new List<int> {
  969. 234
  970. }
  971. });
  972. if (rst)
  973. {
  974. return Ok(JsonView(true, "发送通知成功"));
  975. }
  976. }
  977. //_delegationVisaRep.CommitTran();
  978. }
  979. catch (Exception)
  980. {
  981. //_delegationVisaRep.RollbackTran();
  982. }
  983. }
  984. return Ok(JsonView(true, msg));
  985. }
  986. #endregion
  987. #region 团组任务分配
  988. /// <summary>
  989. /// 团组任务分配初始化
  990. /// </summary>
  991. /// <param name="dto"></param>
  992. /// <returns></returns>
  993. [HttpPost]
  994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  995. public async Task<IActionResult> GetTaskAssignmen()
  996. {
  997. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  998. if (groupData.Code != 0)
  999. {
  1000. return Ok(JsonView(false, groupData.Msg));
  1001. }
  1002. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1003. }
  1004. /// <summary>
  1005. /// 团组任务分配查询
  1006. /// </summary>
  1007. /// <param name="dto"></param>
  1008. /// <returns></returns>
  1009. [HttpPost]
  1010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1011. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1012. {
  1013. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1014. if (groupData.Code != 0)
  1015. {
  1016. return Ok(JsonView(false, groupData.Msg));
  1017. }
  1018. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1019. }
  1020. /// <summary>
  1021. /// 团组任务分配操作
  1022. /// </summary>
  1023. /// <param name="dto"></param>
  1024. /// <returns></returns>
  1025. [HttpPost]
  1026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1027. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1028. {
  1029. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1030. if (groupData.Code != 0)
  1031. {
  1032. return Ok(JsonView(false, groupData.Msg));
  1033. }
  1034. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1035. }
  1036. /// <summary>
  1037. /// 团组任务分配
  1038. /// 批量分配
  1039. /// 查询团组
  1040. /// </summary>
  1041. /// <param name="dto"></param>
  1042. /// <returns></returns>
  1043. [HttpPost]
  1044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1045. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1046. {
  1047. //参数验证
  1048. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1049. if (!DateTime.TryParse(dto.VisitBeginDt,out _) || !DateTime.TryParse(dto.VisitEndDt,out _))
  1050. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1051. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1052. }
  1053. /// <summary>
  1054. /// 团组任务分配
  1055. /// 批量分配
  1056. /// </summary>
  1057. /// <param name="dto"></param>
  1058. /// <returns></returns>
  1059. [HttpPost]
  1060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1061. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1062. {
  1063. //参数验证
  1064. if (dto.UserId < 1 ) return Ok(JsonView(false, MsgTips.UserId));
  1065. if (dto.OperateId < 1) return Ok(JsonView(false, MsgTips.OperateId));
  1066. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请传入有效的GroupIds数组参数!"));
  1067. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1068. }
  1069. #endregion
  1070. #region 团组费用审核
  1071. /// <summary>
  1072. /// 费用审核
  1073. /// 团组列表 Page
  1074. /// </summary>
  1075. /// <param name="_dto">团组列表请求dto</param>
  1076. /// <returns></returns>
  1077. [HttpPost]
  1078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1079. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1080. {
  1081. #region 参数验证
  1082. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1083. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1084. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1085. #region 页面操作权限验证
  1086. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1087. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1088. #endregion
  1089. #endregion
  1090. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1091. {
  1092. string sqlWhere = string.Empty;
  1093. if (_dto.IsSure == 0) //未完成
  1094. {
  1095. sqlWhere += string.Format(@" And IsSure = 0");
  1096. }
  1097. else if (_dto.IsSure == 1) //已完成
  1098. {
  1099. sqlWhere += string.Format(@" And IsSure = 1");
  1100. }
  1101. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1102. {
  1103. string tj = _dto.SearchCriteria;
  1104. 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}%')",
  1105. tj, tj, tj, tj, tj);
  1106. }
  1107. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1108. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1109. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1110. From (
  1111. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1112. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1113. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1114. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1115. From Grp_DelegationInfo gdi
  1116. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1117. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1118. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1119. Where gdi.IsDel = 0 {0}
  1120. ) temp ", sqlWhere);
  1121. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1122. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1123. var _view = new
  1124. {
  1125. PageFuncAuth = pageFunAuthView,
  1126. Data = _DelegationList
  1127. };
  1128. return Ok(JsonView(true, "查询成功!", _view, total));
  1129. }
  1130. else
  1131. {
  1132. return Ok(JsonView(false, "查询失败"));
  1133. }
  1134. }
  1135. /// <summary>
  1136. /// 获取团组费用审核
  1137. /// </summary>
  1138. /// <param name="paras">参数Json字符串</param>
  1139. /// <returns></returns>
  1140. [HttpPost]
  1141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1142. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1143. {
  1144. try
  1145. {
  1146. #region 参数验证
  1147. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1148. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1149. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1150. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1151. #region 页面操作权限验证
  1152. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1153. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1154. #endregion
  1155. #endregion
  1156. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1157. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1158. #region 费用清单
  1159. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1160. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1161. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1162. List<Grp_CreditCardPayment> entityList = _groupRepository
  1163. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1164. .Where(exp.ToExpression())
  1165. .ToList();
  1166. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1167. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1168. /*
  1169. * 76://酒店预订
  1170. */
  1171. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1172. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1173. .ToListAsync();
  1174. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1175. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1176. .ToListAsync();
  1177. /*
  1178. * 79://车/导游地接
  1179. */
  1180. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1181. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1182. .ToListAsync();
  1183. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1184. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1185. .ToListAsync();
  1186. /*
  1187. * 80: //签证
  1188. */
  1189. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1190. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1191. .ToListAsync();
  1192. /*
  1193. *81: //邀请/公务活动
  1194. */
  1195. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1196. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1197. .ToListAsync();
  1198. /*
  1199. * 82: //团组客户保险
  1200. */
  1201. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1202. /*
  1203. * Lable = 85 机票预订
  1204. */
  1205. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1206. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1207. .ToListAsync();
  1208. /*
  1209. * 85 机票预定
  1210. */
  1211. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1212. /*
  1213. * 98 其他款项
  1214. */
  1215. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1216. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1217. .ToListAsync();
  1218. /*
  1219. * 285:收款退还
  1220. */
  1221. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1222. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1223. .ToListAsync();
  1224. /*
  1225. * 1015: //超支费用
  1226. */
  1227. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1228. /*
  1229. * 币种信息
  1230. */
  1231. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1232. /*
  1233. * 车/导游地接 费用类型
  1234. */
  1235. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1236. /*
  1237. * 车/导游地接 费用类型
  1238. */
  1239. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1240. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1241. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1242. /*
  1243. * 用户信息
  1244. */
  1245. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1246. /*
  1247. * 费用模块
  1248. */
  1249. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1250. string priceModule = string.Empty;
  1251. if (sdPriceName != null)
  1252. {
  1253. priceModule = sdPriceName.Name;
  1254. }
  1255. /*
  1256. * 成本信息
  1257. */
  1258. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1259. decimal _groupRate = 0.0000M;
  1260. string _groupCurrencyCode = "-";
  1261. if (groupCost != null)
  1262. {
  1263. _groupRate = groupCost.Rate;
  1264. if (int.TryParse(groupCost.Currency, out int _currency))
  1265. {
  1266. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1267. }
  1268. else _groupCurrencyCode = groupCost.Currency;
  1269. }
  1270. string costContentSql = $"Select * From Grp_GroupCost";
  1271. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1272. //处理日期为空的天数
  1273. for (int i = 0; i < groupCostDetails.Count; i++)
  1274. if (i != 0)
  1275. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1276. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1277. /*
  1278. * 处理详情数据
  1279. */
  1280. foreach (var entity in entityList)
  1281. {
  1282. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1283. _detail.Id = entity.Id;
  1284. _detail.PriceName = priceModule;
  1285. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1286. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1287. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1288. /*
  1289. * 应付款金额
  1290. */
  1291. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1292. string PaymentCurrency_WaitPay = "Unknown";
  1293. string hotelCurrncyCode = "Unknown";
  1294. string hotelCurrncyName = "Unknown";
  1295. if (sdPaymentCurrency_WaitPay != null)
  1296. {
  1297. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1298. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1299. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1300. if (hotelCurrncyCode.Equals("CNY"))
  1301. {
  1302. entity.DayRate = 1.0000M;
  1303. }
  1304. }
  1305. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1306. /*
  1307. * 此次付款金额
  1308. */
  1309. decimal CurrPayStr = 0;
  1310. if (entity.PayPercentage == 0)
  1311. {
  1312. if (entity.PayThenMoney != 0)
  1313. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1314. }
  1315. else
  1316. {
  1317. if (entity.PayMoney != 0)
  1318. {
  1319. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1320. }
  1321. }
  1322. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1323. /*
  1324. * 剩余尾款
  1325. */
  1326. decimal BalanceStr = 0;
  1327. if (CurrPayStr != 0)
  1328. {
  1329. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1330. BalanceStr = 0;
  1331. else
  1332. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1333. }
  1334. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1335. /*
  1336. * Bus名称
  1337. */
  1338. _detail.BusName = "待增加";
  1339. /*
  1340. *费用所属
  1341. */
  1342. switch (entity.CTable)
  1343. {
  1344. case 76://酒店预订
  1345. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1346. if (hotelReservations != null)
  1347. {
  1348. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1349. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1350. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1351. string roomFeeStr = "", roomFeestr1 = "";
  1352. //是否比较房型价格
  1353. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1354. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1355. roomFeeStr += $"<br/>";
  1356. if (hotelReservations.SingleRoomPrice > 0)
  1357. {
  1358. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1359. __isSingle = true;
  1360. }
  1361. if (hotelReservations.DoubleRoomPrice > 0)
  1362. {
  1363. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1364. __isDouble = true;
  1365. }
  1366. if (hotelReservations.SuiteRoomPrice > 0)
  1367. {
  1368. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1369. __isSuite = true;
  1370. }
  1371. if (hotelReservations.OtherRoomPrice > 0)
  1372. {
  1373. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1374. __isOther = true;
  1375. }
  1376. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1377. else roomFeeStr += " 0.00 * 0";
  1378. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1379. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1380. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1381. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1382. /*
  1383. * 费用类型
  1384. * 1:房费
  1385. * 2:早餐
  1386. * 3:地税
  1387. * 4:城市税
  1388. * </summary>
  1389. */
  1390. //地税
  1391. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1392. if (governmentRentData != null)
  1393. {
  1394. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1395. governmentRentFee = governmentRentData.Price;
  1396. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1397. if (governmentRentCurrData != null)
  1398. {
  1399. governmentRentCode = governmentRentCurrData.Name;
  1400. governmentRentName = $"({governmentRentCurrData.Remark})";
  1401. }
  1402. }
  1403. //城市税
  1404. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1405. if (cityTaxData != null)
  1406. {
  1407. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1408. cityTaxFee = cityTaxData.Price;
  1409. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1410. if (cityTaxCurrData != null)
  1411. {
  1412. cityTaxCode = cityTaxCurrData.Name;
  1413. cityTaxName = $"({cityTaxCurrData.Remark})";
  1414. }
  1415. }
  1416. //酒店早餐
  1417. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1418. if (breakfastData != null)
  1419. {
  1420. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1421. breakfastFee = breakfastData.Price;
  1422. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1423. if (breakfastCurrData != null)
  1424. {
  1425. breakfastCode = breakfastCurrData.Name;
  1426. breakfastName = $"({breakfastCurrData.Remark})";
  1427. }
  1428. }
  1429. //房间费用
  1430. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1431. if (roomData != null)
  1432. {
  1433. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1434. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1435. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1436. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1437. roomFee = roomData.Price;
  1438. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1439. if (roomCurrData != null)
  1440. {
  1441. roomCode = roomCurrData.Name;
  1442. roomName = $"({roomCurrData.Remark})";
  1443. }
  1444. }
  1445. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1446. string hotelCostStr = "";
  1447. decimal hotelCsotTotal = 0.00M;
  1448. if (groupCost != null)
  1449. {
  1450. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1451. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1452. }
  1453. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1454. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1455. string hotelCost_day = "";
  1456. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1457. foreach (var item in hotelCostDetails1)
  1458. {
  1459. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1460. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1461. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1462. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1463. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1464. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1465. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1466. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1467. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1468. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1469. hotelCost_day += @$"</br>";
  1470. }
  1471. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1472. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1473. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1474. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1475. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1476. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1477. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1478. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1479. $"房间说明: {hotelReservations.Remark} <br/>" +
  1480. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1481. $"{hotelBreakfastStr}" +
  1482. $"{hotelGovernmentRentStr}" +
  1483. $"{hotelCityTaxStr}";
  1484. _detail.PriceNameContent = hotelReservations.HotelName;
  1485. }
  1486. break;
  1487. case 79://车/导游地接
  1488. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1489. if (touristGuideGroundReservations != null)
  1490. {
  1491. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1492. {
  1493. _detail.BusName = touristGuideGroundReservations.BusName;
  1494. }
  1495. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1496. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1497. //if (isInt)
  1498. //{
  1499. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1500. // if (cityInfo != null)
  1501. // {
  1502. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1503. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1504. // if (carFeeItem != null)
  1505. // {
  1506. // nameContent += $@"({carFeeItem.Name})";
  1507. // }
  1508. // _detail.PriceNameContent = nameContent;
  1509. // }
  1510. //}
  1511. //else
  1512. //{
  1513. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1514. //}
  1515. var touristGuideGroundReservationsContents =
  1516. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1517. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1518. foreach (var item in touristGuideGroundReservationsContents)
  1519. {
  1520. string typeName = "Unknown";
  1521. string carCurrencyCode = "Unknown";
  1522. string carCurrencyName = "Unknown";
  1523. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1524. if (carTypeData != null) typeName = carTypeData.Name;
  1525. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1526. if (currencyData != null)
  1527. {
  1528. carCurrencyCode = currencyData.Name;
  1529. carCurrencyName = currencyData.Remark;
  1530. }
  1531. //op、成本 币种是否一致
  1532. bool IsCurrencyAgreement = false;
  1533. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1534. string opCostStr = string.Empty;
  1535. decimal opCostTypePrice = 0.00M;
  1536. #region 处理成本各项费用
  1537. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1538. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1539. if (opCost.Count > 0)
  1540. {
  1541. switch (item.SId)
  1542. {
  1543. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1544. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1545. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1546. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1547. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1548. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1549. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1550. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1551. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1552. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1553. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1554. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1555. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1556. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1557. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1558. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1559. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1560. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1561. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1562. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1563. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1564. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1565. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1566. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1567. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1568. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1569. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1570. }
  1571. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1572. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1573. }
  1574. #endregion
  1575. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})" ;
  1576. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1577. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1578. $"{opTypeStr} {opCostStr}<br/>" +
  1579. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1580. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1581. }
  1582. _detail.PriceMsgContent = priceMsg;
  1583. }
  1584. break;
  1585. case 80: //签证
  1586. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1587. if (visaInfo != null)
  1588. {
  1589. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1590. _detail.PriceNameContent = visaInfo.VisaDescription ;
  1591. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1592. }
  1593. break;
  1594. case 81: //邀请/公务活动
  1595. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1596. if (_ioa != null)
  1597. {
  1598. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1599. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1600. sendCurrName = "Unknown", //快递费用币种 Name
  1601. sendCurrCode = "Unknown", //快递费用币种 Code
  1602. eventsCurrName = "Unknown", //公务活动费币种 Name
  1603. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1604. translateCurrName = "Unknown", //公务翻译费 Name
  1605. translateCurrCode = "Unknown"; //公务翻译费 Code
  1606. #region 处理费用币种
  1607. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1608. if (inviteCurrData != null)
  1609. {
  1610. inviteCurrName = inviteCurrData.Remark;
  1611. inviteCurrCode = inviteCurrData.Name;
  1612. }
  1613. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1614. if (sendCurrData != null)
  1615. {
  1616. sendCurrName = sendCurrData.Remark;
  1617. sendCurrCode = sendCurrData.Name;
  1618. }
  1619. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1620. if (eventsCurrData != null)
  1621. {
  1622. eventsCurrName = eventsCurrData.Remark;
  1623. eventsCurrCode = eventsCurrData.Name;
  1624. }
  1625. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1626. if (translateCurrData != null)
  1627. {
  1628. translateCurrName = translateCurrData.Remark;
  1629. translateCurrCode = translateCurrData.Name;
  1630. }
  1631. #endregion
  1632. _detail.PriceNameContent = _ioa.InviterArea;
  1633. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1634. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1635. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1636. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1637. $@"备注:" + _ioa.Remark + "<br/>";
  1638. }
  1639. break;
  1640. case 82: //团组客户保险
  1641. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1642. if (customers != null)
  1643. {
  1644. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1645. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1646. }
  1647. break;
  1648. case 85: //机票预订
  1649. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1650. if (jpRes != null)
  1651. {
  1652. string FlightsDescription = jpRes.FlightsDescription;
  1653. string PriceDescription = jpRes.PriceDescription;
  1654. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1655. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1656. }
  1657. break;
  1658. case 98://其他款项
  1659. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1660. if (gdpRes != null)
  1661. {
  1662. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1663. _detail.PriceNameContent = gdpRes.PriceName;
  1664. }
  1665. break;
  1666. case 285://收款退还
  1667. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1668. if (refundAndOtherMoney != null)
  1669. {
  1670. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1671. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1672. }
  1673. break;
  1674. case 751://酒店早餐
  1675. break;
  1676. case 1015://超支费用
  1677. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1678. if (groupExtraCost != null)
  1679. {
  1680. _detail.PriceNameContent = groupExtraCost.PriceName;
  1681. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1682. }
  1683. break;
  1684. default:
  1685. break;
  1686. }
  1687. /*
  1688. * 申请人
  1689. */
  1690. string operatorName = " - ";
  1691. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1692. if (_opUser != null)
  1693. {
  1694. operatorName = _opUser.CnName;
  1695. }
  1696. _detail.OperatorName = operatorName;
  1697. /*
  1698. * 审核人
  1699. */
  1700. string auditOperatorName = "Unknown";
  1701. if (entity.AuditGMOperate == 0)
  1702. auditOperatorName = " - ";
  1703. else if (entity.AuditGMOperate == 4)
  1704. auditOperatorName = "自动审核";
  1705. else
  1706. {
  1707. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1708. if (_adUser != null)
  1709. {
  1710. auditOperatorName = _adUser.CnName;
  1711. }
  1712. }
  1713. _detail.AuditOperatorName = auditOperatorName;
  1714. /*
  1715. * 超预算比例
  1716. */
  1717. string overBudgetStr = "";
  1718. if (entity.ExceedBudget == -1)
  1719. overBudgetStr = sdPriceName.Name + "尚无预算";
  1720. else if (entity.ExceedBudget == 0)
  1721. {
  1722. if (entity.CTable == 76 || entity.CTable == 79)
  1723. {
  1724. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  1725. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  1726. }
  1727. else
  1728. {
  1729. overBudgetStr = "未超预算";
  1730. }
  1731. }
  1732. else
  1733. overBudgetStr = entity.ExceedBudget.ToString("P");
  1734. _detail.OverBudget = overBudgetStr;
  1735. /*
  1736. * 费用总计
  1737. */
  1738. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1739. {
  1740. CurrencyId = entity.PaymentCurrency,
  1741. CurrencyName = PaymentCurrency_WaitPay,
  1742. AmountPayable = entity.PayMoney,
  1743. ThisPayment = CurrPayStr,
  1744. BalancePayment = BalanceStr,
  1745. AuditedFunds = CurrPayStr
  1746. });
  1747. _detail.IsAuditGM = entity.IsAuditGM;
  1748. detailList.Add(_detail);
  1749. }
  1750. #endregion
  1751. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1752. /*
  1753. * 下方描述处理
  1754. */
  1755. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1756. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1757. if (ccpCurrencyPrice != null)
  1758. {
  1759. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1760. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1761. }
  1762. else
  1763. {
  1764. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1765. }
  1766. string amountPayableStr = string.Format(@"应付款总金额: ");
  1767. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1768. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1769. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1770. foreach (var item in nonDuplicat)
  1771. {
  1772. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1773. if (strs.Count > 0)
  1774. {
  1775. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1776. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1777. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1778. //单独处理此次付款金额
  1779. if (item.CurrencyId == 836) //人民币
  1780. {
  1781. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1782. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1783. }
  1784. else
  1785. {
  1786. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1787. }
  1788. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1789. //单独处理已审核费用
  1790. if (item.CurrencyId == 836) //人民币
  1791. {
  1792. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1793. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1794. }
  1795. else
  1796. {
  1797. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1798. }
  1799. }
  1800. }
  1801. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1802. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1803. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1804. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1805. var _view1 = new
  1806. {
  1807. PageFuncAuth = pageFunAuthView,
  1808. Data = _view
  1809. };
  1810. return Ok(JsonView(_view1));
  1811. }
  1812. catch (Exception ex)
  1813. {
  1814. return Ok(JsonView(false, ex.Message));
  1815. }
  1816. }
  1817. /// <summary>
  1818. /// 费用审核
  1819. /// 修改团组费用审核状态
  1820. /// </summary>
  1821. /// <param name="_dto">参数Json字符串</param>
  1822. /// <returns></returns>
  1823. [HttpPost]
  1824. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1825. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1826. {
  1827. #region 参数验证
  1828. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1829. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1830. #endregion
  1831. #region 页面操作权限验证
  1832. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1833. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1834. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1835. #endregion
  1836. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1837. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1838. DateTime dtNow = DateTime.Now;
  1839. _groupRepository.BeginTran();
  1840. int rst = 0;
  1841. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1842. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1843. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1844. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1845. List<dynamic> msgDatas = new List<dynamic>();
  1846. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  1847. foreach (var item in idList)
  1848. {
  1849. int CreditId = int.Parse(item);
  1850. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1851. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1852. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1853. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1854. .Where(s => s.Id == CreditId)
  1855. .ExecuteCommandAsync();
  1856. if (result < 1)
  1857. {
  1858. rst = -1;
  1859. _groupRepository.RollbackTran();
  1860. return Ok(JsonView(false, "操作失败并回滚!"));
  1861. }
  1862. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1863. if (creditData != null)
  1864. {
  1865. #region 应用通知配置
  1866. try
  1867. {
  1868. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  1869. }
  1870. catch (Exception ex)
  1871. {
  1872. }
  1873. #endregion
  1874. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1875. string groupNameStr = string.Empty;
  1876. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1877. if (groupData != null) groupNameStr = groupData.TeamName;
  1878. string creditTypeStr = string.Empty;
  1879. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1880. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1881. string creditCurrency = string.Empty;
  1882. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1883. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1884. if (creditCurrency.Equals("CNY"))
  1885. {
  1886. creditData.DayRate = 1.0000M;
  1887. }
  1888. if (creditData.PayPercentage == 0.00M)
  1889. {
  1890. creditData.PayPercentage = 100M;
  1891. }
  1892. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1893. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1894. string msgContent = "";
  1895. if (creditCurrency.Equals("CNY"))
  1896. {
  1897. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1898. }
  1899. else
  1900. {
  1901. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1902. }
  1903. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1904. }
  1905. }
  1906. if (rst == 0)
  1907. {
  1908. _groupRepository.CommitTran();
  1909. foreach (var item in msgDatas)
  1910. {
  1911. //发送消息
  1912. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1913. }
  1914. #region 应用推送
  1915. try
  1916. {
  1917. foreach (var ccpId in dic_ccp_user.Keys)
  1918. {
  1919. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  1920. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  1921. }
  1922. }
  1923. catch (Exception)
  1924. {
  1925. }
  1926. #endregion
  1927. return Ok(JsonView(true, "操作成功!"));
  1928. }
  1929. return Ok(JsonView(false, "操作失败!"));
  1930. }
  1931. #endregion
  1932. #region 机票费用录入
  1933. /// <summary>
  1934. /// 机票录入当前登录人可操作团组
  1935. /// </summary>
  1936. /// <param name="dto"></param>
  1937. /// <returns></returns>
  1938. [HttpPost]
  1939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1940. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1941. {
  1942. try
  1943. {
  1944. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1945. if (groupData.Code != 0)
  1946. {
  1947. return Ok(JsonView(false, groupData.Msg));
  1948. }
  1949. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1950. }
  1951. catch (Exception ex)
  1952. {
  1953. return Ok(JsonView(false, "程序错误!"));
  1954. throw;
  1955. }
  1956. }
  1957. /// <summary>
  1958. /// 机票费用录入列表
  1959. /// </summary>
  1960. /// <param name="dto"></param>
  1961. /// <returns></returns>
  1962. [HttpPost]
  1963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1964. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1965. {
  1966. try
  1967. {
  1968. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1969. if (groupData.Code != 0)
  1970. {
  1971. return Ok(JsonView(false, groupData.Msg));
  1972. }
  1973. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1974. }
  1975. catch (Exception ex)
  1976. {
  1977. return Ok(JsonView(false, ex.Message));
  1978. throw;
  1979. }
  1980. }
  1981. /// <summary>
  1982. /// 根据id查询费用录入信息
  1983. /// </summary>
  1984. /// <param name="dto"></param>
  1985. /// <returns></returns>
  1986. [HttpPost]
  1987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1988. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1989. {
  1990. try
  1991. {
  1992. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1993. if (groupData.Code != 0)
  1994. {
  1995. return Ok(JsonView(false, groupData.Msg));
  1996. }
  1997. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1998. }
  1999. catch (Exception ex)
  2000. {
  2001. return Ok(JsonView(false, "程序错误!"));
  2002. throw;
  2003. }
  2004. }
  2005. /// <summary>
  2006. /// 机票费用录入操作(Status:1.新增,2.修改)
  2007. /// </summary>
  2008. /// <param name="dto"></param>
  2009. /// <returns></returns>
  2010. [HttpPost]
  2011. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2012. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2013. {
  2014. try
  2015. {
  2016. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2017. if (groupData.Code != 0)
  2018. {
  2019. return Ok(JsonView(false, groupData.Msg));
  2020. }
  2021. #region 应用推送
  2022. try
  2023. {
  2024. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2025. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2026. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2027. }
  2028. catch (Exception ex)
  2029. {
  2030. }
  2031. #endregion
  2032. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2033. }
  2034. catch (Exception ex)
  2035. {
  2036. return Ok(JsonView(false, "程序错误!"));
  2037. throw;
  2038. }
  2039. }
  2040. /// <summary>
  2041. /// 根据舱位类型查询接团客户名单信息
  2042. /// </summary>
  2043. /// <param name="dto"></param>
  2044. /// <returns></returns>
  2045. [HttpPost]
  2046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2047. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2048. {
  2049. try
  2050. {
  2051. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2052. if (crm_Groups.Count != 0)
  2053. {
  2054. List<dynamic> Customer = new List<dynamic>();
  2055. foreach (var item in crm_Groups)
  2056. {
  2057. var data = new
  2058. {
  2059. Id = item.Id,
  2060. Pinyin = item.Pinyin,
  2061. Name = item.LastName + item.FirstName
  2062. };
  2063. Customer.Add(data);
  2064. }
  2065. return Ok(JsonView(true, "查询成功!", Customer));
  2066. }
  2067. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2068. }
  2069. catch (Exception ex)
  2070. {
  2071. return Ok(JsonView(false, "程序错误!"));
  2072. throw;
  2073. }
  2074. }
  2075. /// <summary>
  2076. /// 根据团号获取客户信息
  2077. /// </summary>
  2078. /// <param name="dto"></param>
  2079. /// <returns></returns>
  2080. [HttpPost]
  2081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2082. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2083. {
  2084. var jw = JsonView(false);
  2085. if (dto.DIID < 1)
  2086. {
  2087. jw.Msg += "请输入正确的diid";
  2088. return Ok(jw);
  2089. }
  2090. var arr = getSimplClientList(dto.DIID);
  2091. jw = JsonView(true, "获取成功!", arr);
  2092. return Ok(jw);
  2093. }
  2094. private List<SimplClientInfo> getSimplClientList(int diId)
  2095. {
  2096. 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);
  2097. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2098. return arr;
  2099. }
  2100. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2101. {
  2102. string result = origin;
  2103. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2104. {
  2105. string[] temparr = origin.Split(',');
  2106. string fistrStr = temparr[0];
  2107. int count = temparr.Count();
  2108. int tempId;
  2109. bool success = int.TryParse(fistrStr, out tempId);
  2110. if (success)
  2111. {
  2112. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2113. if (tempInfo != null)
  2114. {
  2115. if (count > 1)
  2116. {
  2117. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2118. }
  2119. else
  2120. {
  2121. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2122. }
  2123. }
  2124. }
  2125. }
  2126. return result;
  2127. }
  2128. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2129. {
  2130. string result = origin;
  2131. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2132. {
  2133. string[] temparr = origin.Split(',');
  2134. result = "";
  2135. foreach (var item in temparr)
  2136. {
  2137. int tempId;
  2138. bool success = int.TryParse(item, out tempId);
  2139. if (success)
  2140. {
  2141. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2142. if (tempInfo != null)
  2143. {
  2144. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2145. }
  2146. }
  2147. }
  2148. }
  2149. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2150. return result;
  2151. }
  2152. /// <summary>
  2153. /// 机票费用录入,删除
  2154. /// </summary>
  2155. /// <param name="dto"></param>
  2156. /// <returns></returns>
  2157. [HttpPost]
  2158. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2159. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2160. {
  2161. try
  2162. {
  2163. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2164. if (res)
  2165. {
  2166. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2167. {
  2168. IsDel = 1,
  2169. DeleteUserId = dto.DeleteUserId,
  2170. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2171. }).ExecuteCommandAsync();
  2172. return Ok(JsonView(true, "删除成功!"));
  2173. }
  2174. return Ok(JsonView(false, "删除失败!"));
  2175. }
  2176. catch (Exception ex)
  2177. {
  2178. return Ok(JsonView(false, "程序错误!"));
  2179. throw;
  2180. }
  2181. }
  2182. /// <summary>
  2183. /// 导出机票录入报表
  2184. /// </summary>
  2185. /// <param name="dto"></param>
  2186. /// <returns></returns>
  2187. [HttpPost]
  2188. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2189. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2190. {
  2191. try
  2192. {
  2193. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2194. if (groupData.Code != 0)
  2195. {
  2196. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2197. }
  2198. else
  2199. {
  2200. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2201. if (AirTicketReservations.Count != 0)
  2202. {
  2203. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2204. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2205. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2206. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2207. WorkbookDesigner designer = new WorkbookDesigner();
  2208. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2209. decimal countCost = 0;
  2210. foreach (var item in AirTicketReservations)
  2211. {
  2212. #region 处理客人姓名
  2213. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2214. item.ClientName = clientNames;
  2215. #endregion
  2216. if (item.BankType == "其他")
  2217. {
  2218. item.BankNo = "--";
  2219. }
  2220. else
  2221. {
  2222. if (!string.IsNullOrEmpty(item.BankType))
  2223. {
  2224. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2225. }
  2226. }
  2227. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2228. item.Price = System.Decimal.Round(item.Price, 2);
  2229. countCost += Convert.ToDecimal(item.Price);
  2230. }
  2231. designer.SetDataSource("Export", AirTicketReservations);
  2232. designer.SetDataSource("ExportDiCode", diCode);
  2233. designer.SetDataSource("ExportDiName", diName);
  2234. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2235. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2236. designer.Process();
  2237. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2238. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2239. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2240. return Ok(JsonView(true, "成功", url = rst));
  2241. }
  2242. else
  2243. {
  2244. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2245. }
  2246. }
  2247. }
  2248. catch (Exception ex)
  2249. {
  2250. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2251. throw;
  2252. }
  2253. }
  2254. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2255. /// <summary>
  2256. /// 行程单导出
  2257. /// </summary>
  2258. /// <param name="dto"></param>
  2259. /// <returns></returns>
  2260. [HttpPost]
  2261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2262. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2263. {
  2264. try
  2265. {
  2266. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2267. if (groupData.Code != 0)
  2268. {
  2269. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2270. }
  2271. else
  2272. {
  2273. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2274. if (dto.Language == "CN")
  2275. {
  2276. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2277. DocumentBuilder builder = new DocumentBuilder(doc);
  2278. int tableIndex = 0;//表格索引
  2279. //得到文档中的第一个表格
  2280. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2281. foreach (var item in _AirTicketReservations)
  2282. {
  2283. #region 处理固定数据
  2284. string[] FlightsCode = item.FlightsCode.Split('/');
  2285. if (FlightsCode.Length != 0)
  2286. {
  2287. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2288. if (_AirCompany != null)
  2289. {
  2290. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2291. }
  2292. else
  2293. {
  2294. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2295. }
  2296. }
  2297. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2298. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2299. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2300. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2301. string name = "";
  2302. foreach (string clientName in nameArray)
  2303. {
  2304. if (!name.Contains(clientName))
  2305. {
  2306. name += clientName + ",";
  2307. }
  2308. }
  2309. if (!string.IsNullOrWhiteSpace(name))
  2310. {
  2311. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2312. }
  2313. else
  2314. {
  2315. table.Range.Bookmarks["ClientName"].Text = "--";
  2316. }
  2317. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2318. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2319. table.Range.Bookmarks["JointTicket"].Text = "--";
  2320. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2321. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2322. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2323. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2324. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2325. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2326. #endregion
  2327. #region 循环数据处理
  2328. List<AirInfo> airs = new List<AirInfo>();
  2329. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2330. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2331. for (int i = 0; i < FlightsCode.Length; i++)
  2332. {
  2333. AirInfo air = new AirInfo();
  2334. string[] tempstr = DayArray[i]
  2335. .Replace("\r\n", string.Empty)
  2336. .Replace("\\r\\n", string.Empty)
  2337. .TrimStart().TrimEnd()
  2338. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2339. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2340. string starCity = "";
  2341. if (star_Three != null)
  2342. {
  2343. starCity = star_Three.AirPort;
  2344. }
  2345. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2346. string EndCity = "";
  2347. if (End_Three != null)
  2348. {
  2349. EndCity = End_Three.AirPort;
  2350. }
  2351. air.Destination = starCity + "/" + EndCity;
  2352. air.Flight = FlightsCode[i];
  2353. air.SeatingClass = item.CTypeName;
  2354. string dateTime = tempstr[2];
  2355. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2356. air.FlightDate = DateTemp;
  2357. air.DepartureTime = tempstr[5];
  2358. air.LandingTime = tempstr[6];
  2359. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2360. air.TicketStatus = "--";
  2361. air.Luggage = "--";
  2362. air.DepartureTerminal = "--";
  2363. air.LandingTerminal = "--";
  2364. airs.Add(air);
  2365. }
  2366. int row = 13;
  2367. for (int i = 0; i < airs.Count; i++)
  2368. {
  2369. if (airs.Count > 2)
  2370. {
  2371. for (int j = 0; j < airs.Count - 2; j++)
  2372. {
  2373. var CopyRow = table.Rows[12].Clone(true);
  2374. table.Rows.Add(CopyRow);
  2375. }
  2376. }
  2377. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2378. int index = 0;
  2379. foreach (PropertyInfo property in properties)
  2380. {
  2381. string value = property.GetValue(airs[i]).ToString();
  2382. Cell ishcel0 = table.Rows[row].Cells[index];
  2383. Paragraph p = new Paragraph(doc);
  2384. string s = value;
  2385. p.AppendChild(new Run(doc, s));
  2386. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2387. ishcel0.AppendChild(p);
  2388. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2389. index++;
  2390. }
  2391. row++;
  2392. }
  2393. #endregion
  2394. Paragraph lastParagraph = new Paragraph(doc);
  2395. //第一个表格末尾加段落
  2396. table.ParentNode.InsertAfter(lastParagraph, table);
  2397. //复制第一个表格
  2398. Table cloneTable = (Table)table.Clone(true);
  2399. //在文档末尾段落后面加入复制的表格
  2400. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2401. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2402. {
  2403. int rownewsIndex = 13;
  2404. for (int i = 0; i < 2; i++)
  2405. {
  2406. var CopyRow = table.Rows[12].Clone(true);
  2407. table.Rows.RemoveAt(13);
  2408. table.Rows.Add(CopyRow);
  2409. rownewsIndex++;
  2410. }
  2411. }
  2412. else
  2413. {
  2414. table.Rows.RemoveAt(12);
  2415. }
  2416. cloneTable.Rows.RemoveAt(12);
  2417. }
  2418. if (_AirTicketReservations.Count != 0)
  2419. {
  2420. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2421. if (FlightsCode.Length != 0)
  2422. {
  2423. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2424. if (_AirCompany != null)
  2425. {
  2426. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2427. }
  2428. else
  2429. {
  2430. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2431. }
  2432. }
  2433. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2434. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2435. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2436. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2437. string name = "";
  2438. foreach (string clientName in nameArray)
  2439. {
  2440. if (!name.Contains(clientName))
  2441. {
  2442. name += clientName + ",";
  2443. }
  2444. }
  2445. if (!string.IsNullOrWhiteSpace(name))
  2446. {
  2447. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2448. }
  2449. else
  2450. {
  2451. table.Range.Bookmarks["ClientName"].Text = "--";
  2452. }
  2453. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2454. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2455. table.Range.Bookmarks["JointTicket"].Text = "--";
  2456. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2457. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2458. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2459. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2460. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2461. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2462. }
  2463. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2464. //保存合并后的文档
  2465. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2466. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2467. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2468. return Ok(JsonView(true, "成功!", rst));
  2469. }
  2470. else
  2471. {
  2472. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2473. DocumentBuilder builder = new DocumentBuilder(doc);
  2474. int tableIndex = 0;//表格索引
  2475. //得到文档中的第一个表格
  2476. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2477. List<string> texts = new List<string>();
  2478. foreach (var item in _AirTicketReservations)
  2479. {
  2480. string[] FlightsCode = item.FlightsCode.Split('/');
  2481. if (FlightsCode.Length != 0)
  2482. {
  2483. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2484. if (_AirCompany != null)
  2485. {
  2486. if (!transDic.ContainsKey(_AirCompany.CnName))
  2487. {
  2488. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2489. }
  2490. }
  2491. else
  2492. {
  2493. if (!transDic.ContainsKey("--"))
  2494. {
  2495. transDic.Add("--", "--");
  2496. }
  2497. }
  2498. }
  2499. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2500. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2501. string name = "";
  2502. foreach (string clientName in nameArray)
  2503. {
  2504. name += clientName + ",";
  2505. }
  2506. if (!texts.Contains(name))
  2507. {
  2508. texts.Add(name);
  2509. }
  2510. List<AirInfo> airs = new List<AirInfo>();
  2511. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2512. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2513. for (int i = 0; i < FlightsCode.Length; i++)
  2514. {
  2515. AirInfo air = new AirInfo();
  2516. string[] tempstr = DayArray[i]
  2517. .Replace("\r\n", string.Empty)
  2518. .Replace("\\r\\n", string.Empty)
  2519. .TrimStart().TrimEnd()
  2520. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2521. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2522. if (star_Three != null)
  2523. {
  2524. if (!transDic.ContainsKey(star_Three.AirPort))
  2525. {
  2526. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2527. }
  2528. }
  2529. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2530. if (End_Three != null)
  2531. {
  2532. if (!transDic.ContainsKey(End_Three.AirPort))
  2533. {
  2534. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2535. }
  2536. }
  2537. if (!texts.Contains(item.CTypeName))
  2538. {
  2539. texts.Add(item.CTypeName);
  2540. }
  2541. }
  2542. }
  2543. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2544. if (transData.Count > 0)
  2545. {
  2546. foreach (TranslateResult item in transData)
  2547. {
  2548. if (!transDic.ContainsKey(item.Query))
  2549. {
  2550. transDic.Add(item.Query, item.Translation);
  2551. }
  2552. }
  2553. }
  2554. foreach (var item in _AirTicketReservations)
  2555. {
  2556. #region 处理固定数据
  2557. string[] FlightsCode = item.FlightsCode.Split('/');
  2558. if (FlightsCode.Length != 0)
  2559. {
  2560. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2561. if (_AirCompany != null)
  2562. {
  2563. string str = "--";
  2564. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2565. if (!string.IsNullOrEmpty(translateResult))
  2566. {
  2567. str = translateResult;
  2568. str = _airTicketResRep.Processing(str);
  2569. }
  2570. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2571. }
  2572. else
  2573. {
  2574. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2575. }
  2576. }
  2577. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2578. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2579. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2580. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2581. string names = "";
  2582. foreach (string clientName in nameArray)
  2583. {
  2584. names += clientName + ",";
  2585. }
  2586. if (!string.IsNullOrWhiteSpace(names))
  2587. {
  2588. string str = "--";
  2589. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2590. if (!string.IsNullOrEmpty(translateResult))
  2591. {
  2592. str = translateResult;
  2593. str = _airTicketResRep.Processing(str);
  2594. }
  2595. table.Range.Bookmarks["ClientName"].Text = str;
  2596. }
  2597. else
  2598. {
  2599. table.Range.Bookmarks["ClientName"].Text = "--";
  2600. }
  2601. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2602. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2603. table.Range.Bookmarks["JointTicket"].Text = "--";
  2604. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2605. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2606. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2607. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2608. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2609. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2610. #endregion
  2611. #region 循环数据处理
  2612. List<AirInfo> airs = new List<AirInfo>();
  2613. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2614. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2615. for (int i = 0; i < FlightsCode.Length; i++)
  2616. {
  2617. AirInfo air = new AirInfo();
  2618. string[] tempstr = DayArray[i]
  2619. .Replace("\r\n", string.Empty)
  2620. .Replace("\\r\\n", string.Empty)
  2621. .TrimStart().TrimEnd()
  2622. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2623. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2624. string starCity = "";
  2625. if (star_Three != null)
  2626. {
  2627. string str2 = "--";
  2628. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2629. if (!string.IsNullOrEmpty(translateResult2))
  2630. {
  2631. str2 = translateResult2;
  2632. str2 = _airTicketResRep.Processing(str2);
  2633. }
  2634. starCity = str2;
  2635. }
  2636. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2637. string EndCity = "";
  2638. if (End_Three != null)
  2639. {
  2640. string str1 = "--";
  2641. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2642. if (!string.IsNullOrEmpty(translateResult1))
  2643. {
  2644. str1 = translateResult1;
  2645. str1 = _airTicketResRep.Processing(str1);
  2646. }
  2647. EndCity = str1;
  2648. }
  2649. air.Destination = starCity + "/" + EndCity;
  2650. air.Flight = FlightsCode[i];
  2651. string str = "--";
  2652. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2653. if (!string.IsNullOrEmpty(translateResult))
  2654. {
  2655. str = translateResult;
  2656. str = _airTicketResRep.Processing(str);
  2657. }
  2658. air.SeatingClass = str;
  2659. string dateTime = tempstr[2];
  2660. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2661. air.FlightDate = DateTemp;
  2662. air.DepartureTime = tempstr[5];
  2663. air.LandingTime = tempstr[6];
  2664. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2665. air.TicketStatus = "--";
  2666. air.Luggage = "--";
  2667. air.DepartureTerminal = "--";
  2668. air.LandingTerminal = "--";
  2669. airs.Add(air);
  2670. }
  2671. int row = 13;
  2672. for (int i = 0; i < airs.Count; i++)
  2673. {
  2674. if (airs.Count > 2)
  2675. {
  2676. for (int j = 0; j < airs.Count - 2; j++)
  2677. {
  2678. var CopyRow = table.Rows[12].Clone(true);
  2679. table.Rows.Add(CopyRow);
  2680. }
  2681. }
  2682. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2683. int index = 0;
  2684. foreach (PropertyInfo property in properties)
  2685. {
  2686. string value = property.GetValue(airs[i]).ToString();
  2687. Cell ishcel0 = table.Rows[row].Cells[index];
  2688. Paragraph p = new Paragraph(doc);
  2689. string s = value;
  2690. p.AppendChild(new Run(doc, s));
  2691. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2692. ishcel0.AppendChild(p);
  2693. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2694. //ishcel0.CellFormat.VerticalAlignment=
  2695. index++;
  2696. }
  2697. row++;
  2698. }
  2699. #endregion
  2700. Paragraph lastParagraph = new Paragraph(doc);
  2701. //第一个表格末尾加段落
  2702. table.ParentNode.InsertAfter(lastParagraph, table);
  2703. //复制第一个表格
  2704. Table cloneTable = (Table)table.Clone(true);
  2705. //在文档末尾段落后面加入复制的表格
  2706. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2707. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2708. {
  2709. int rownewsIndex = 13;
  2710. for (int i = 0; i < 2; i++)
  2711. {
  2712. var CopyRow = table.Rows[12].Clone(true);
  2713. table.Rows.RemoveAt(13);
  2714. table.Rows.Add(CopyRow);
  2715. rownewsIndex++;
  2716. }
  2717. }
  2718. else
  2719. {
  2720. table.Rows.RemoveAt(12);
  2721. }
  2722. cloneTable.Rows.RemoveAt(12);
  2723. }
  2724. if (_AirTicketReservations.Count != 0)
  2725. {
  2726. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2727. if (FlightsCode.Length != 0)
  2728. {
  2729. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2730. if (_AirCompany != null)
  2731. {
  2732. string str = "--";
  2733. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2734. if (!string.IsNullOrEmpty(translateResult))
  2735. {
  2736. str = translateResult;
  2737. str = _airTicketResRep.Processing(str);
  2738. }
  2739. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2740. }
  2741. else
  2742. {
  2743. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2744. }
  2745. }
  2746. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2747. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2748. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2749. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2750. string names = "";
  2751. foreach (string clientName in nameArray)
  2752. {
  2753. names += clientName + ",";
  2754. }
  2755. if (!string.IsNullOrWhiteSpace(names))
  2756. {
  2757. string str = "--";
  2758. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2759. if (!string.IsNullOrEmpty(translateResult))
  2760. {
  2761. str = translateResult;
  2762. str = _airTicketResRep.Processing(str);
  2763. }
  2764. table.Range.Bookmarks["ClientName"].Text = str;
  2765. }
  2766. else
  2767. {
  2768. table.Range.Bookmarks["ClientName"].Text = "--";
  2769. }
  2770. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2771. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2772. table.Range.Bookmarks["JointTicket"].Text = "--";
  2773. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2774. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2775. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2776. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2777. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2778. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2779. }
  2780. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2781. //保存合并后的文档
  2782. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2783. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2784. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2785. return Ok(JsonView(true, "成功!", rst));
  2786. }
  2787. }
  2788. }
  2789. catch (Exception ex)
  2790. {
  2791. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  2792. throw;
  2793. }
  2794. }
  2795. #endregion
  2796. #region 团组增减款项 --> 其他款项
  2797. /// <summary>
  2798. /// 团组增减款项下拉框绑定
  2799. /// </summary>
  2800. /// <param name="dto"></param>
  2801. /// <returns></returns>
  2802. [HttpPost]
  2803. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2804. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2805. {
  2806. #region 参数验证
  2807. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2808. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2809. #endregion
  2810. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  2811. }
  2812. /// <summary>
  2813. /// 根据团组Id查询团组增减款项
  2814. /// </summary>
  2815. /// <param name="dto"></param>
  2816. /// <returns></returns>
  2817. [HttpPost]
  2818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2819. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2820. {
  2821. #region 参数验证
  2822. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2823. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2824. #endregion
  2825. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  2826. }
  2827. /// <summary>
  2828. /// 团组增减款项操作(Status:1.新增,2.修改)
  2829. /// </summary>
  2830. /// <param name="dto"></param>
  2831. /// <returns></returns>
  2832. [HttpPost]
  2833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2834. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2835. {
  2836. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2837. if (groupData.Code != 200)
  2838. {
  2839. return Ok(JsonView(false, groupData.Msg));
  2840. }
  2841. #region 应用推送
  2842. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2843. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2844. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2845. #endregion
  2846. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2847. }
  2848. /// <summary>
  2849. /// 团组增减款项操作 删除
  2850. /// </summary>
  2851. /// <param name="dto"></param>
  2852. /// <returns></returns>
  2853. [HttpPost]
  2854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2855. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2856. {
  2857. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  2858. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  2859. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  2860. if (res.Code == 0)
  2861. {
  2862. return Ok(JsonView(true, "删除成功!"));
  2863. }
  2864. return Ok(JsonView(false, "删除失败!"));
  2865. }
  2866. /// <summary>
  2867. /// 根据团组增减款项Id查询
  2868. /// </summary>
  2869. /// <param name="dto"></param>
  2870. /// <returns></returns>
  2871. [HttpPost]
  2872. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2873. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2874. {
  2875. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  2876. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  2877. }
  2878. /// <summary>
  2879. /// 查询供应商名称
  2880. /// </summary>
  2881. /// <param name="dto"></param>
  2882. /// <returns></returns>
  2883. [HttpPost]
  2884. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  2885. {
  2886. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  2887. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  2888. ?? new List<Grp_DecreasePayments>();
  2889. dbResult = dbResult.Distinct(new
  2890. ProductComparer()).ToList();
  2891. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  2892. {
  2893. x.Id,
  2894. x.SupplierAddress,
  2895. x.SupplierArea,
  2896. x.SupplierContact,
  2897. x.SupplierContactNumber,
  2898. x.SupplierEmail,
  2899. x.SupplierName,
  2900. x.SupplierSocialAccount,
  2901. x.SupplierTypeId,
  2902. }).ToList());
  2903. return Ok(jw);
  2904. }
  2905. #endregion
  2906. #region 文件上传、删除
  2907. /// <summary>
  2908. /// region 文件上传 可以带参数
  2909. /// </summary>
  2910. /// <param name="file"></param>
  2911. /// <returns></returns>
  2912. [HttpPost]
  2913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2914. public async Task<IActionResult> UploadProject(IFormFile file)
  2915. {
  2916. try
  2917. {
  2918. var TypeName = Request.Headers["TypeName"].ToString();
  2919. if (file != null)
  2920. {
  2921. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2922. //文件名称
  2923. string projectFileName = file.FileName;
  2924. //上传的文件的路径
  2925. string filePath = "";
  2926. if (TypeName == "A")//A代表团组增减款项
  2927. {
  2928. if (!Directory.Exists(fileDir))
  2929. {
  2930. Directory.CreateDirectory(fileDir);
  2931. }
  2932. //上传的文件的路径
  2933. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2934. }
  2935. else if (TypeName == "B")//B代表商邀相关文件
  2936. {
  2937. if (!Directory.Exists(fileDir))
  2938. {
  2939. Directory.CreateDirectory(fileDir);
  2940. }
  2941. //上传的文件的路径
  2942. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2943. }
  2944. using (FileStream fs = System.IO.File.Create(filePath))
  2945. {
  2946. file.CopyTo(fs);
  2947. fs.Flush();
  2948. }
  2949. return Ok(JsonView(true, "上传成功!", projectFileName));
  2950. }
  2951. else
  2952. {
  2953. return Ok(JsonView(false, "上传失败!"));
  2954. }
  2955. }
  2956. catch (Exception ex)
  2957. {
  2958. return Ok(JsonView(false, "程序错误!"));
  2959. throw;
  2960. }
  2961. }
  2962. /// <summary>
  2963. /// 删除指定文件
  2964. /// </summary>
  2965. /// <param name="dto"></param>
  2966. /// <returns></returns>
  2967. [HttpPost]
  2968. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2969. public async Task<IActionResult> DelFile(DelFileDto dto)
  2970. {
  2971. try
  2972. {
  2973. var TypeName = Request.Headers["TypeName"].ToString();
  2974. string filePath = "";
  2975. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2976. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2977. int id = 0;
  2978. if (TypeName == "A")
  2979. {
  2980. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2981. // 删除该文件
  2982. System.IO.File.Delete(filePath);
  2983. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2984. }
  2985. else if (TypeName == "B")
  2986. {
  2987. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2988. // 删除该文件
  2989. System.IO.File.Delete(filePath);
  2990. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2991. }
  2992. if (id != 0)
  2993. {
  2994. return Ok(JsonView(true, "成功!"));
  2995. }
  2996. else
  2997. {
  2998. return Ok(JsonView(false, "失败!"));
  2999. }
  3000. }
  3001. catch (Exception ex)
  3002. {
  3003. return Ok(JsonView(false, "程序错误!"));
  3004. throw;
  3005. }
  3006. }
  3007. #endregion
  3008. #region 商邀费用录入
  3009. /// <summary>
  3010. /// 根据团组Id查询商邀费用列表
  3011. /// </summary>
  3012. /// <param name="dto"></param>
  3013. /// <returns></returns>
  3014. [HttpPost]
  3015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3016. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3017. {
  3018. try
  3019. {
  3020. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3021. if (groupData.Code != 0)
  3022. {
  3023. return Ok(JsonView(false, groupData.Msg));
  3024. }
  3025. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3026. }
  3027. catch (Exception ex)
  3028. {
  3029. return Ok(JsonView(false, "程序错误!"));
  3030. throw;
  3031. }
  3032. }
  3033. //
  3034. /// <summary>
  3035. /// 商邀费用 Info Page 基础数据源
  3036. /// </summary>
  3037. /// <param name="dto"></param>
  3038. /// <returns></returns>
  3039. [HttpPost]
  3040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3041. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3042. {
  3043. try
  3044. {
  3045. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3046. if (groupData.Code != 0)
  3047. {
  3048. return Ok(JsonView(false, groupData.Msg));
  3049. }
  3050. return Ok(JsonView(true, "操作成功", groupData.Data));
  3051. }
  3052. catch (Exception ex)
  3053. {
  3054. return Ok(JsonView(false, ex.Message));
  3055. throw;
  3056. }
  3057. }
  3058. /// <summary>
  3059. /// 根据商邀费用ID查询C表和商邀费用数据
  3060. /// </summary>
  3061. /// <param name="dto"></param>
  3062. /// <returns></returns>
  3063. [HttpPost]
  3064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3065. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3066. {
  3067. try
  3068. {
  3069. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3070. if (groupData.Code != 0)
  3071. {
  3072. return Ok(JsonView(false, groupData.Msg));
  3073. }
  3074. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3075. }
  3076. catch (Exception ex)
  3077. {
  3078. return Ok(JsonView(false, ex.Message));
  3079. throw;
  3080. }
  3081. }
  3082. /// <summary>
  3083. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3084. /// </summary>
  3085. /// <param name="dto"></param>
  3086. /// <returns></returns>
  3087. [HttpPost]
  3088. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3089. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3090. {
  3091. try
  3092. {
  3093. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3094. if (groupData.Code != 0)
  3095. {
  3096. return Ok(JsonView(false, groupData.Msg));
  3097. }
  3098. #region 应用推送
  3099. try
  3100. {
  3101. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3102. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3103. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3104. }
  3105. catch (Exception ex)
  3106. {
  3107. }
  3108. #endregion
  3109. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3110. }
  3111. catch (Exception ex)
  3112. {
  3113. return Ok(JsonView(false, "程序错误!"));
  3114. throw;
  3115. }
  3116. }
  3117. /// <summary>
  3118. /// 商邀删除
  3119. /// </summary>
  3120. /// <param name="dto"></param>
  3121. /// <returns></returns>
  3122. [HttpPost]
  3123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3124. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3125. {
  3126. try
  3127. {
  3128. _sqlSugar.BeginTran();
  3129. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3130. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3131. {
  3132. IsDel = 1,
  3133. DeleteUserId = dto.DeleteUserId,
  3134. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3135. })
  3136. .Where(it => it.Id == dto.Id)
  3137. .ExecuteCommand();
  3138. if (res1 > 0)
  3139. {
  3140. int _diId = 0;
  3141. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3142. if (_ioaInfo != null)
  3143. {
  3144. _diId = _ioaInfo.DiId;
  3145. }
  3146. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3147. .SetColumns(a => new Grp_CreditCardPayment()
  3148. {
  3149. IsDel = 1,
  3150. DeleteUserId = dto.DeleteUserId,
  3151. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3152. })
  3153. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3154. .ExecuteCommand();
  3155. if (res2 > 0)
  3156. {
  3157. _sqlSugar.CommitTran();
  3158. return Ok(JsonView(true, "删除成功!"));
  3159. }
  3160. }
  3161. _sqlSugar.RollbackTran();
  3162. return Ok(JsonView(false, "删除失败"));
  3163. }
  3164. catch (Exception ex)
  3165. {
  3166. _sqlSugar.RollbackTran();
  3167. return Ok(JsonView(false, ex.Message));
  3168. }
  3169. }
  3170. /// <summary>
  3171. /// 团组模块文件上传
  3172. /// </summary>
  3173. /// <param name="dto"></param>
  3174. /// <returns></returns>
  3175. [HttpPost]
  3176. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3177. {
  3178. var jw = JsonView(false);
  3179. long M = 1024 * 1024;
  3180. if (dto.Files == null || dto.Files.Count == 0)
  3181. {
  3182. jw.Msg = "无文件信息!";
  3183. return Ok(jw);
  3184. }
  3185. if (dto.Files.Sum(x=>x.Length) > 20 * M)
  3186. {
  3187. jw.Msg = "文件大小超过20M!";
  3188. return Ok(jw);
  3189. }
  3190. //var nameSp = dto.File.FileName.Split(".");
  3191. //if (nameSp.Length < 2)
  3192. //{
  3193. // jw.Msg = "拓展名称有误!";
  3194. // return Ok(jw);
  3195. //}
  3196. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3197. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3198. //{
  3199. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3200. // return Ok(jw);
  3201. //}
  3202. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3203. if (Ctable == null)
  3204. {
  3205. jw.Msg = "Ctable指向有误!";
  3206. return Ok(jw);
  3207. }
  3208. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3209. if (groupInfo == null)
  3210. {
  3211. jw.Msg = "团组信息不存在!";
  3212. return Ok(jw);
  3213. }
  3214. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3215. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3216. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3217. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3218. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3219. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3220. try
  3221. {
  3222. if (!Directory.Exists(fileBase))
  3223. {
  3224. Directory.CreateDirectory(fileBase);
  3225. }
  3226. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3227. foreach (var fileStream in dto.Files)
  3228. {
  3229. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3230. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3231. {
  3232. Cid = dto.Cid,
  3233. CreateTime = DateTime.Now,
  3234. CreateUserId = dto.Userid,
  3235. Ctable = dto.Ctable,
  3236. Diid = dto.Diid,
  3237. IsDel = 0,
  3238. FilePath = saveFilePath,
  3239. FileName = fileStream.FileName
  3240. };
  3241. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3242. {
  3243. fileStream.CopyTo(fs);
  3244. fs.Flush();
  3245. }
  3246. saveArr.Add(file);
  3247. }
  3248. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3249. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3250. jw = JsonView(true, "保存成功!", new
  3251. {
  3252. count = addResult,
  3253. filesName = saveArr.Select(x => x.FileName)
  3254. }) ;
  3255. }
  3256. catch (Exception ex)
  3257. {
  3258. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3259. {
  3260. count = 0,
  3261. filesName = new string[0],
  3262. }) ;
  3263. }
  3264. return Ok(jw);
  3265. }
  3266. /// <summary>
  3267. /// 查询各模块已保存文件
  3268. /// </summary>
  3269. /// <param name="dto"></param>
  3270. /// <returns></returns>
  3271. [HttpPost]
  3272. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3273. {
  3274. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3275. .AndIF(dto.UserId != -1 , x => x.CreateUserId == dto.UserId);
  3276. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x=>x.Id).ToList();
  3277. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3278. {
  3279. expression = Expressionable.Create<Grp_GroupModelFile>()
  3280. .And(x=>visaIds.Contains(x.CreateUserId));
  3281. }
  3282. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3283. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3284. .Where(expression.ToExpression())
  3285. .ToList();
  3286. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3287. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3288. {
  3289. x.FileName,
  3290. x.Id,
  3291. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3292. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3293. })));
  3294. }
  3295. /// <summary>
  3296. /// 下载该团组下的所有文件
  3297. /// </summary>
  3298. /// <param name="dto"></param>
  3299. /// <returns></returns>
  3300. [HttpPost]
  3301. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3302. {
  3303. var jw = JsonView(false);
  3304. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3305. if (groupInfo == null)
  3306. {
  3307. jw.Msg = "团组信息不存在!";
  3308. return Ok(jw);
  3309. }
  3310. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3311. var isModule = Convert.ToBoolean(dto.isModule);
  3312. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3313. IOOperatorHelper io = new IOOperatorHelper();
  3314. if (isModule)
  3315. {
  3316. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3317. foreach (var moduleArr in moduleGroup)
  3318. {
  3319. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3320. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3321. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3322. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3323. foreach (var item in moduleArr)
  3324. {
  3325. if (System.IO.File.Exists(item.FilePath))
  3326. {
  3327. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3328. {
  3329. byte[] bytes = new byte[fileStream.Length];
  3330. fileStream.Read(bytes, 0, bytes.Length);
  3331. fileStream.Close();
  3332. Stream stream = new MemoryStream(bytes);
  3333. chiZips.Add(item.FileName, stream);
  3334. }
  3335. }
  3336. }
  3337. if (chiZips.Count > 0)
  3338. {
  3339. var byts = io.ConvertZipStream(chiZips);
  3340. Stream stream = new MemoryStream(byts);
  3341. Zips.Add(key.Name+"_.zip", stream);
  3342. }
  3343. }
  3344. }
  3345. else
  3346. {
  3347. foreach (var item in dbQuery)
  3348. {
  3349. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3350. {
  3351. byte[] bytes = new byte[fileStream.Length];
  3352. fileStream.Read(bytes, 0, bytes.Length);
  3353. fileStream.Close();
  3354. Stream stream = new MemoryStream(bytes);
  3355. while (Zips.Keys.Contains(item.FileName))
  3356. {
  3357. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3358. }
  3359. Zips.Add(item.FileName, stream);
  3360. }
  3361. }
  3362. }
  3363. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3364. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3365. if (Zips.Count > 0)
  3366. {
  3367. var byts = io.ConvertZipStream(Zips);
  3368. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3369. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  3370. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  3371. }
  3372. else
  3373. {
  3374. jw.Msg = "暂无生成文件!";
  3375. }
  3376. return Ok(jw);
  3377. }
  3378. /// <summary>
  3379. /// 下载该团组下此模块的所有文件
  3380. /// </summary>
  3381. /// <param name="dto"></param>
  3382. /// <returns></returns>
  3383. [HttpPost]
  3384. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  3385. {
  3386. var jw = JsonView(false);
  3387. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3388. if (groupInfo == null)
  3389. {
  3390. jw.Msg = "团组信息不存在!";
  3391. return Ok(jw);
  3392. }
  3393. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  3394. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  3395. && x.IsDel == 0);
  3396. if (key == null)
  3397. {
  3398. jw.Msg = "Ctable指向错误!";
  3399. return Ok(jw);
  3400. }
  3401. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3402. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3403. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3404. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3405. IOOperatorHelper io = new IOOperatorHelper();
  3406. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3407. foreach (var item in dbQuery)
  3408. {
  3409. if (System.IO.File.Exists(item.FilePath))
  3410. {
  3411. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3412. {
  3413. byte[] bytes = new byte[fileStream.Length];
  3414. fileStream.Read(bytes, 0, bytes.Length);
  3415. fileStream.Close();
  3416. Stream stream = new MemoryStream(bytes);
  3417. while (Zips.Keys.Contains(item.FileName))
  3418. {
  3419. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3420. }
  3421. Zips.Add(item.FileName, stream);
  3422. }
  3423. }
  3424. }
  3425. if (Zips.Count > 0)
  3426. {
  3427. var byts = io.ConvertZipStream(Zips);
  3428. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3429. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  3430. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  3431. }
  3432. else
  3433. {
  3434. jw.Msg = "暂无生成文件!";
  3435. }
  3436. return Ok(jw);
  3437. }
  3438. /// <summary>
  3439. /// 删除该团组下的指定文件
  3440. /// </summary>
  3441. /// <param name="dto"></param>
  3442. /// <returns></returns>
  3443. [HttpPost]
  3444. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  3445. {
  3446. var jw = JsonView(false);
  3447. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  3448. if (sing == null)
  3449. {
  3450. jw.Msg = "暂无";
  3451. return Ok(jw);
  3452. }
  3453. if (System.IO.File.Exists(sing.FilePath))
  3454. {
  3455. try
  3456. {
  3457. System.IO.File.Delete(sing.FilePath);
  3458. }
  3459. catch (Exception ex)
  3460. {
  3461. jw.Msg = "删除失败!" + ex.Message;
  3462. return Ok(jw);
  3463. }
  3464. }
  3465. sing.IsDel = 1;
  3466. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  3467. sing.DeleteUserId = dto.UserId;
  3468. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  3469. jw = JsonView(true, "删除成功!");
  3470. return Ok(jw);
  3471. }
  3472. #endregion
  3473. #region 团组英文资料
  3474. /// <summary>
  3475. /// 查询团组英文所有资料
  3476. /// </summary>
  3477. /// <param name="dto"></param>
  3478. /// <returns></returns>
  3479. [HttpPost]
  3480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3481. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3482. {
  3483. try
  3484. {
  3485. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3486. if (groupData.Code != 0)
  3487. {
  3488. return Ok(JsonView(false, groupData.Msg));
  3489. }
  3490. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3491. }
  3492. catch (Exception ex)
  3493. {
  3494. return Ok(JsonView(false, "程序错误!"));
  3495. throw;
  3496. }
  3497. }
  3498. /// <summary>
  3499. /// 团组英文资料操作(Status:1.新增,2.修改)
  3500. /// </summary>
  3501. /// <param name="dto"></param>
  3502. /// <returns></returns>
  3503. [HttpPost]
  3504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3505. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3506. {
  3507. try
  3508. {
  3509. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3510. if (groupData.Code != 0)
  3511. {
  3512. return Ok(JsonView(false, groupData.Msg));
  3513. }
  3514. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3515. }
  3516. catch (Exception ex)
  3517. {
  3518. return Ok(JsonView(false, "程序错误!"));
  3519. throw;
  3520. }
  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> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3530. {
  3531. try
  3532. {
  3533. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3534. if (_DelegationEnData != null)
  3535. {
  3536. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3537. }
  3538. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3539. }
  3540. catch (Exception ex)
  3541. {
  3542. return Ok(JsonView(false, "程序错误!"));
  3543. throw;
  3544. }
  3545. }
  3546. /// <summary>
  3547. /// 团组英文资料删除
  3548. /// </summary>
  3549. /// <param name="dto"></param>
  3550. /// <returns></returns>
  3551. [HttpPost]
  3552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3553. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3554. {
  3555. try
  3556. {
  3557. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3558. if (!res)
  3559. {
  3560. return Ok(JsonView(false, "删除失败"));
  3561. }
  3562. return Ok(JsonView(true, "删除成功!"));
  3563. }
  3564. catch (Exception ex)
  3565. {
  3566. return Ok(JsonView(false, "程序错误!"));
  3567. throw;
  3568. }
  3569. }
  3570. #endregion
  3571. #region 导出邀请函
  3572. /// <summary>
  3573. /// 导出邀请函页面初始化
  3574. /// </summary>
  3575. /// <param name="dto"></param>
  3576. /// <returns></returns>
  3577. [HttpPost]
  3578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3579. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3580. {
  3581. try
  3582. {
  3583. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3584. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3585. if (dto.DiId == 0)
  3586. {
  3587. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3588. }
  3589. else
  3590. {
  3591. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3592. }
  3593. return Ok(JsonView(true, "查询成功!", new
  3594. {
  3595. deleClient = crm_Deles,
  3596. delegations = grp_Delegations
  3597. }));
  3598. }
  3599. catch (Exception ex)
  3600. {
  3601. return Ok(JsonView(false, "程序错误!"));
  3602. throw;
  3603. }
  3604. }
  3605. /// <summary>
  3606. /// 导出邀请函
  3607. /// </summary>
  3608. /// <param name="dto"></param>
  3609. /// <returns></returns>
  3610. [HttpPost]
  3611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3612. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3613. {
  3614. #region 参数验证
  3615. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3616. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3617. #endregion
  3618. try
  3619. {
  3620. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3621. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3622. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3623. From Grp_TourClientList tcl
  3624. Left Join
  3625. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3626. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3627. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3628. From Crm_DeleClient dc
  3629. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3630. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3631. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3632. Where dc.IsDel = 0) temp
  3633. On temp.DcId =tcl.ClientId
  3634. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3635. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3636. List<string> texts = new List<string>();
  3637. if (datas.Count != 0)
  3638. {
  3639. foreach (TourClientListDetailsView item in datas)
  3640. {
  3641. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3642. {
  3643. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3644. }
  3645. else
  3646. {
  3647. string name = item.LastName + item.FirstName;
  3648. texts.Add(name);
  3649. }
  3650. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3651. {
  3652. if (!transDic.ContainsKey(item.Job))
  3653. {
  3654. texts.Add(item.Job);
  3655. }
  3656. }
  3657. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3658. {
  3659. texts.Add(item.CompanyFullName);
  3660. }
  3661. }
  3662. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3663. if (transData.Count > 0)
  3664. {
  3665. foreach (TranslateResult item in transData)
  3666. {
  3667. if (!transDic.ContainsKey(item.Query))
  3668. {
  3669. transDic.Add(item.Query, item.Translation);
  3670. }
  3671. }
  3672. }
  3673. List<GuestList> list = new List<GuestList>();
  3674. foreach (TourClientListDetailsView dele in datas)
  3675. {
  3676. GuestList guestList = new GuestList();
  3677. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3678. {
  3679. guestList.Name = dele.Pinyin;
  3680. }
  3681. else
  3682. {
  3683. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3684. guestList.Name = Name;
  3685. }
  3686. if (dele.Sex == 0)
  3687. {
  3688. guestList.Sex = "Male";
  3689. }
  3690. else if (dele.Sex == 1)
  3691. {
  3692. guestList.Sex = "Female";
  3693. }
  3694. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3695. if (!string.IsNullOrEmpty(dele.Job))
  3696. {
  3697. guestList.Job = dele.Job;
  3698. }
  3699. list.Add(guestList);
  3700. }
  3701. //载入模板
  3702. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3703. DocumentBuilder builder = new DocumentBuilder(doc);
  3704. //获取word里所有表格
  3705. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3706. //获取所填表格的序数
  3707. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3708. var rowStart = tableOne.Rows[0]; //获取第1行
  3709. //循环赋值
  3710. for (int i = 0; i < list.Count; i++)
  3711. {
  3712. builder.MoveToCell(0, i + 1, 0, 0);
  3713. builder.Write(list[i].Name.ToString());
  3714. builder.MoveToCell(0, i + 1, 1, 0);
  3715. builder.Write(list[i].Sex.ToString());
  3716. builder.MoveToCell(0, i + 1, 2, 0);
  3717. builder.Write(list[i].DOB.ToString());
  3718. builder.MoveToCell(0, i + 1, 3, 0);
  3719. builder.Write(list[i].Job.ToString());
  3720. }
  3721. //删除多余行
  3722. while (tableOne.Rows.Count > list.Count + 1)
  3723. {
  3724. tableOne.Rows.RemoveAt(list.Count + 1);
  3725. }
  3726. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3727. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3728. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3729. doc.Save(filePath);
  3730. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3731. return Ok(JsonView(true, "操作成功!", Url));
  3732. }
  3733. else
  3734. {
  3735. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3736. }
  3737. }
  3738. catch (Exception ex)
  3739. {
  3740. return Ok(JsonView(false, ex.Message));
  3741. throw;
  3742. }
  3743. }
  3744. #endregion
  3745. #region 团组经理模块 出入境费用
  3746. ///// <summary>
  3747. ///// 团组模块 - 出入境费用
  3748. ///// </summary>
  3749. ///// <returns></returns>
  3750. //[HttpPost]
  3751. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3752. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3753. //{
  3754. // try
  3755. // {
  3756. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3757. // if (data.Code != 0)
  3758. // {
  3759. // return Ok(JsonView(false, data.Msg));
  3760. // }
  3761. // return Ok(JsonView(true, "查询成功!"));
  3762. // }
  3763. // catch (Exception ex)
  3764. // {
  3765. // return Ok(JsonView(false, ex.Message));
  3766. // throw;
  3767. // }
  3768. //}
  3769. /// <summary>
  3770. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3771. /// </summary>
  3772. /// <returns></returns>
  3773. [HttpPost]
  3774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3775. public async Task<IActionResult> SetDayAndCostAreaChange()
  3776. {
  3777. try
  3778. {
  3779. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3780. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3781. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3782. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3783. foreach (var item in unite) //处理交集数据
  3784. {
  3785. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3786. }
  3787. foreach (var item in merge) //处理差集数据
  3788. {
  3789. int nationalTravelFeeId = 0;
  3790. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3791. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3792. else
  3793. {
  3794. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3795. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3796. }
  3797. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3798. }
  3799. //只更新dayAndCost 的 nationalTravelFeeId;
  3800. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3801. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3802. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3803. }
  3804. catch (Exception ex)
  3805. {
  3806. return Ok(JsonView(false, ex.Message));
  3807. throw;
  3808. }
  3809. }
  3810. /// <summary>
  3811. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3812. /// </summary>
  3813. /// <returns></returns>
  3814. [HttpPost]
  3815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3816. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3817. {
  3818. try
  3819. {
  3820. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3821. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3822. //SetDataInfoView
  3823. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3824. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3825. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3826. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3827. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3828. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3829. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3830. //默认币种显示
  3831. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3832. {
  3833. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3834. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3835. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3836. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3837. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3838. };
  3839. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3840. if (_currencyRate.Count > 0)
  3841. {
  3842. foreach (var item in _currencyInfos)
  3843. {
  3844. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3845. if (rateInfo != null)
  3846. {
  3847. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3848. rate1 *= 1.035M;
  3849. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3850. }
  3851. }
  3852. }
  3853. return Ok(JsonView(true, "查询成功!", new
  3854. {
  3855. GroupNameData = groupNameData.Data,
  3856. CurrencyData = _CurrencyData,
  3857. WordTypeData = _WordTypeData,
  3858. ExcelTypeData = _ExcelTypeData,
  3859. CurrencyInit = _currencyInfos
  3860. }));
  3861. }
  3862. catch (Exception ex)
  3863. {
  3864. return Ok(JsonView(false, ex.Message));
  3865. throw;
  3866. }
  3867. }
  3868. /// <summary>
  3869. /// 团组模块 - 出入境费用
  3870. /// 实时汇率 tips
  3871. /// 签证费用 tips
  3872. /// </summary>
  3873. /// <returns></returns>
  3874. [HttpPost]
  3875. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3876. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  3877. {
  3878. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  3879. //默认币种显示
  3880. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3881. {
  3882. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3883. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3884. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3885. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3886. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3887. };
  3888. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3889. List<dynamic> reteInfos = new List<dynamic>();
  3890. if (_currencyRate.Count > 0)
  3891. {
  3892. foreach (var item in _currencyInfos)
  3893. {
  3894. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3895. if (rateInfo != null)
  3896. {
  3897. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3898. decimal rate1 = item.Rate;
  3899. rate1 *= 1.03M;
  3900. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3901. reteInfos.Add(new
  3902. {
  3903. currCode = item.CurrencyCode,
  3904. currName = item.CurrencyName,
  3905. rate = rate2,
  3906. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3907. });
  3908. }
  3909. }
  3910. }
  3911. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  3912. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  3913. return Ok(JsonView(true, "查询成功!", new
  3914. {
  3915. //GroupNameData = groupNameData.Data,
  3916. visaData = visaData.Data,
  3917. airData = airData.Data,
  3918. reteInfos = reteInfos
  3919. }));
  3920. }
  3921. /// <summary>
  3922. /// 团组模块 - 出入境费用 - Info
  3923. /// </summary>
  3924. /// <returns></returns>
  3925. [HttpPost]
  3926. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3927. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3928. {
  3929. try
  3930. {
  3931. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3932. if (data.Code != 0)
  3933. {
  3934. return Ok(JsonView(false, data.Msg));
  3935. }
  3936. return Ok(JsonView(true, "查询成功!", data.Data));
  3937. }
  3938. catch (Exception ex)
  3939. {
  3940. return Ok(JsonView(false, ex.Message));
  3941. }
  3942. }
  3943. /// <summary>
  3944. /// 团组模块 - 出入境费用 - Add And Update
  3945. /// </summary>
  3946. /// <returns></returns>
  3947. [HttpPost]
  3948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3949. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3950. {
  3951. try
  3952. {
  3953. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3954. if (data.Code != 0)
  3955. {
  3956. return Ok(JsonView(false, data.Msg));
  3957. }
  3958. //生成默认文件pdf并且通知人员
  3959. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  3960. {
  3961. DiId = dto.DiId,
  3962. ExportType = 1,
  3963. SubTypeId = 1005
  3964. }, "pdf");
  3965. //发送通知
  3966. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  3967. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  3968. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  3969. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign,fileUrl);
  3970. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208","233","21" }, dto.UserId, url);
  3971. return Ok(JsonView(true, data.Msg, data.Data));
  3972. }
  3973. catch (Exception ex)
  3974. {
  3975. return Ok(JsonView(false, ex.Message));
  3976. }
  3977. }
  3978. /// <summary>
  3979. /// 团组模块 - 出入境费用 - Confirm 费用
  3980. /// </summary>
  3981. /// <returns></returns>
  3982. [HttpPost]
  3983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3984. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  3985. {
  3986. //TODO:测试完毕需把对应的用户ID更改
  3987. //1、数据表添加字段
  3988. //2、更改字段接口()
  3989. var _view = await _enterExitCostRep.ConfirmCost(dto);
  3990. //3、确认成功 给财务发送消息
  3991. if (_view.Code == 200)
  3992. {
  3993. if (dto.Type == 1)
  3994. {
  3995. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  3996. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  3997. }
  3998. }
  3999. return Ok(_view);
  4000. }
  4001. /// <summary>
  4002. /// 团组模块 - 出入境费用 - File downlaod
  4003. /// </summary>
  4004. /// <param name="dto"></param>
  4005. /// <returns></returns>
  4006. [HttpPost]
  4007. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4008. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4009. {
  4010. try
  4011. {
  4012. if (dto.DiId < 1)
  4013. {
  4014. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4015. }
  4016. if (dto.ExportType < 1)
  4017. {
  4018. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  4019. }
  4020. if (dto.SubTypeId < 1)
  4021. {
  4022. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  4023. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4024. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4025. 3 团组成员名单 1 团组成员名单"));
  4026. }
  4027. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4028. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4029. if (_EnterExitCosts == null)
  4030. {
  4031. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  4032. }
  4033. //数据源
  4034. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4035. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4036. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4037. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4038. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4039. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4040. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4041. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4042. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4043. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4044. .Select((tcl, dc, cc) => new
  4045. {
  4046. Name = dc.LastName + dc.FirstName,
  4047. Sex = dc.Sex,
  4048. Birthday = dc.BirthDay,
  4049. Company = cc.CompanyFullName,
  4050. Job = dc.Job
  4051. })
  4052. .ToList();
  4053. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4054. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4055. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4056. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4057. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4058. if (dto.ExportType == 1) //明细表
  4059. {
  4060. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4061. {
  4062. //获取模板
  4063. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4064. //载入模板
  4065. Document doc = new Document(tempPath);
  4066. DocumentBuilder builder = new DocumentBuilder(doc);
  4067. //利用键值对存放数据
  4068. Dictionary<string, string> dic = new Dictionary<string, string>();
  4069. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4070. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4071. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4072. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4073. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4074. //境内费用(其他费用)
  4075. if (_EnterExitCosts.ChoiceOne == 1)
  4076. {
  4077. string row1_1 = "";
  4078. if (_EnterExitCosts.Visa > 0)
  4079. {
  4080. //insidePayTotal += _EnterExitCosts.Visa;
  4081. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4082. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4083. {
  4084. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4085. }
  4086. }
  4087. string row1_2 = "";
  4088. if (_EnterExitCosts.YiMiao > 0)
  4089. {
  4090. //insidePayTotal += _EnterExitCosts.YiMiao;
  4091. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4092. }
  4093. if (_EnterExitCosts.HeSuan > 0)
  4094. {
  4095. //insidePayTotal += _EnterExitCosts.HeSuan;
  4096. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4097. }
  4098. if (_EnterExitCosts.Service > 0)
  4099. {
  4100. //insidePayTotal += _EnterExitCosts.Service;
  4101. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4102. }
  4103. string row1_3 = "";
  4104. if (_EnterExitCosts.Safe > 0)
  4105. {
  4106. //insidePayTotal += _EnterExitCosts.Safe;
  4107. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4108. }
  4109. if (_EnterExitCosts.Ticket > 0)
  4110. {
  4111. //insidePayTotal += _EnterExitCosts.Ticket;
  4112. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4113. }
  4114. string row1 = "";
  4115. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4116. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4117. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4118. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4119. dic.Add("Row1Str", row1);
  4120. }
  4121. string airTotalStr = string.Empty,
  4122. airPriceStr = string.Empty;
  4123. //经济舱
  4124. if (_EnterExitCosts.SumJJC == 1)
  4125. {
  4126. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4127. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4128. }
  4129. //公务舱
  4130. if (_EnterExitCosts.SumGWC == 1)
  4131. {
  4132. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4133. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4134. }
  4135. //头等舱
  4136. if (_EnterExitCosts.SumTDC == 1)
  4137. {
  4138. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4139. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4140. }
  4141. dic.Add("AirTotalStr", airTotalStr);
  4142. dic.Add("AirPriceStr", airPriceStr);
  4143. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4144. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4145. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4146. int table1Row = 0,
  4147. table2Row = 0,
  4148. table3Row = 0,
  4149. table4Row = 0;
  4150. //住宿费
  4151. if (_EnterExitCosts.ChoiceThree == 1)
  4152. {
  4153. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4154. table1Row = dac1.Count;
  4155. #region 填充word表格内容
  4156. for (int i = 0; i < dac1.Count; i++)
  4157. {
  4158. Grp_DayAndCost dac = dac1[i];
  4159. if (dac == null) continue;
  4160. builder.MoveToCell(0, i, 0, 0);
  4161. builder.Write("第" + dac.Days.ToString() + "晚:");
  4162. builder.MoveToCell(0, i, 1, 0);
  4163. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4164. //builder.Write(dac.Place == null ? "" : dac.Place);
  4165. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4166. builder.MoveToCell(0, i, 2, 0);
  4167. builder.Write("费用标准:");
  4168. string curr = "";
  4169. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4170. if (currData != null)
  4171. {
  4172. curr = currData.Name;
  4173. }
  4174. builder.MoveToCell(0, i, 3, 0);
  4175. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4176. builder.MoveToCell(0, i, 4, 0);
  4177. builder.Write("费用小计:");
  4178. builder.MoveToCell(0, i, 5, 0);
  4179. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4180. }
  4181. #endregion
  4182. }else dic.Add("SubZS","0.00");
  4183. //删除多余行
  4184. while (table1.Rows.Count > table1Row)
  4185. {
  4186. table1.Rows.RemoveAt(table1Row);
  4187. }
  4188. //伙食费
  4189. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4190. if (_EnterExitCosts.ChoiceFour == 1)
  4191. {
  4192. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4193. table2Row = dac2.Count;
  4194. #region 填充word表格内容
  4195. for (int i = 0; i < dac2.Count; i++)
  4196. {
  4197. Grp_DayAndCost dac = dac2[i];
  4198. if (dac == null) continue;
  4199. builder.MoveToCell(1, i, 0, 0);
  4200. builder.Write("第" + dac.Days.ToString() + "天:");
  4201. builder.MoveToCell(1, i, 1, 0);
  4202. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4203. builder.MoveToCell(1, i, 2, 0);
  4204. builder.Write("费用标准:");
  4205. string curr = "";
  4206. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4207. if (currData != null)
  4208. {
  4209. curr = currData.Name;
  4210. }
  4211. builder.MoveToCell(1, i, 3, 0);
  4212. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4213. builder.MoveToCell(1, i, 4, 0);
  4214. builder.Write("费用小计:");
  4215. builder.MoveToCell(1, i, 5, 0);
  4216. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4217. }
  4218. #endregion
  4219. }else dic.Add("SubHS","0.00");
  4220. //删除多余行
  4221. while (table2.Rows.Count > table2Row)
  4222. {
  4223. table2.Rows.RemoveAt(table2Row);
  4224. }
  4225. //公杂费
  4226. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4227. if (_EnterExitCosts.ChoiceFive == 1)
  4228. {
  4229. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4230. table3Row = dac3.Count;
  4231. #region 填充word表格内容
  4232. for (int i = 0; i < dac3.Count; i++)
  4233. {
  4234. Grp_DayAndCost dac = dac3[i];
  4235. if (dac == null) continue;
  4236. builder.MoveToCell(2, i, 0, 0);
  4237. builder.Write("第" + dac.Days.ToString() + "天:");
  4238. builder.MoveToCell(2, i, 1, 0);
  4239. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4240. builder.MoveToCell(2, i, 2, 0);
  4241. builder.Write("费用标准:");
  4242. string curr = "";
  4243. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4244. if (currData != null)
  4245. {
  4246. curr = currData.Name;
  4247. }
  4248. builder.MoveToCell(2, i, 3, 0);
  4249. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4250. builder.MoveToCell(2, i, 4, 0);
  4251. builder.Write("费用小计:");
  4252. builder.MoveToCell(2, i, 5, 0);
  4253. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4254. }
  4255. //删除多余行
  4256. while (table3.Rows.Count > table3Row)
  4257. {
  4258. table3.Rows.RemoveAt(table3Row);
  4259. }
  4260. #endregion
  4261. }else dic.Add("SubGZF", "0.00");
  4262. //删除多余行
  4263. while (table3.Rows.Count > table3Row)
  4264. {
  4265. table3.Rows.RemoveAt(table3Row);
  4266. }
  4267. //培训费
  4268. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4269. if (_EnterExitCosts.ChoiceSix == 1)
  4270. {
  4271. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4272. dic.Add("SubPX", pxStr);
  4273. table4Row = dac4.Count;
  4274. #region 填充word表格内容
  4275. for (int i = 0; i < dac4.Count; i++)
  4276. {
  4277. Grp_DayAndCost dac = dac4[i];
  4278. if (dac == null) continue;
  4279. builder.MoveToCell(3, i, 0, 0);
  4280. builder.Write("第" + dac.Days.ToString() + "天:");
  4281. builder.MoveToCell(3, i, 1, 0);
  4282. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4283. builder.MoveToCell(3, i, 2, 0);
  4284. builder.Write("费用标准:");
  4285. string curr = "";
  4286. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4287. if (currData != null)
  4288. {
  4289. curr = currData.Name;
  4290. }
  4291. builder.MoveToCell(3, i, 3, 0);
  4292. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4293. builder.MoveToCell(3, i, 4, 0);
  4294. builder.Write("费用小计:");
  4295. builder.MoveToCell(3, i, 5, 0);
  4296. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4297. }
  4298. #endregion
  4299. }
  4300. //else dic.Add("SubPX","0.00");
  4301. //删除多余行
  4302. while (table4.Rows.Count > table4Row)
  4303. {
  4304. table4.Rows.RemoveAt(table4Row);
  4305. }
  4306. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal;
  4307. decimal subJJC = 0.00M,
  4308. subGWC = 0.00M,
  4309. subTDC = 0.00M;
  4310. //经济舱
  4311. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  4312. //公务舱
  4313. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  4314. //头等舱
  4315. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  4316. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  4317. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  4318. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  4319. #region 填充word模板书签内容
  4320. foreach (var key in dic.Keys)
  4321. {
  4322. builder.MoveToBookmark(key);
  4323. builder.Write(dic[key]);
  4324. }
  4325. #endregion
  4326. //文件名
  4327. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  4328. AsposeHelper.removewatermark_v2180();
  4329. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4330. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4331. return Ok(JsonView(true, "成功", new { Url = url }));
  4332. }
  4333. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  4334. {
  4335. //获取模板
  4336. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4337. //载入模板
  4338. Document doc = new Document(tempPath);
  4339. DocumentBuilder builder = new DocumentBuilder(doc);
  4340. Dictionary<string, string> dic = new Dictionary<string, string>();
  4341. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4342. {
  4343. List<string> list = new List<string>();
  4344. try
  4345. {
  4346. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4347. foreach (var item in spilitArr)
  4348. {
  4349. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4350. var depCode = spDotandEmpty[2].Substring(0, 3);
  4351. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4352. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4353. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4354. list.Add(depName);
  4355. list.Add(arrName);
  4356. }
  4357. list = list.Distinct().ToList();
  4358. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4359. }
  4360. catch (Exception)
  4361. {
  4362. dic.Add("ReturnCode", "行程录入不正确!");
  4363. }
  4364. }
  4365. else
  4366. {
  4367. dic.Add("ReturnCode", "未录入行程!");
  4368. }
  4369. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4370. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4371. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4372. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4373. {
  4374. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4375. dic.Add("Day", sp.Days.ToString());
  4376. }
  4377. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4378. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4379. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4380. //dic.Add("Names", Names);
  4381. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4382. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4383. decimal dac1totalPrice = 0.00M;
  4384. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  4385. foreach (var dac in dac1)
  4386. {
  4387. if (dac.SubTotal == 0.00M)
  4388. {
  4389. continue;
  4390. }
  4391. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4392. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4393. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4394. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4395. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4396. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4397. builder.Write(currency);//币种
  4398. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4399. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4400. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4401. builder.Write("");//人数
  4402. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4403. builder.Write("");//天数
  4404. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4405. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4406. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4407. decimal rate = 0.00M;
  4408. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4409. builder.Write(rate.ToString("#0.0000"));//汇率
  4410. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4411. decimal rbmPrice = dac.SubTotal;
  4412. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4413. accommodationStartIndex++;
  4414. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4415. }
  4416. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4417. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  4418. {
  4419. table1.Rows.RemoveAt(i - 1);
  4420. foodandotherStartIndex--;
  4421. }
  4422. if (dac2.Count == dac3.Count)//国家 币种 金额
  4423. {
  4424. for (int i = 0; i < dac2.Count; i++)
  4425. {
  4426. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4427. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4428. }
  4429. }
  4430. decimal dac2totalPrice = 0.00M;
  4431. foreach (var dac in dac2)
  4432. {
  4433. if (dac.SubTotal == 0)
  4434. {
  4435. continue;
  4436. }
  4437. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4438. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4439. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4440. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4441. builder.Write(currency);//币种
  4442. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4443. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4444. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4445. builder.Write("");//人数
  4446. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4447. builder.Write("");//天数
  4448. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4449. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4450. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4451. decimal rate = 0.00M;
  4452. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4453. builder.Write(rate.ToString("#0.0000"));//汇率
  4454. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4455. decimal rbmPrice = dac.SubTotal;
  4456. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4457. foodandotherStartIndex++;
  4458. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4459. }
  4460. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4461. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  4462. {
  4463. table1.Rows.RemoveAt(i - 1);
  4464. }
  4465. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4466. string otherFeeStr = "";
  4467. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4468. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4469. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4470. if (otherFeeStr.Length > 0)
  4471. {
  4472. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4473. otherFeeStr = $"({otherFeeStr})";
  4474. dic.Add("OtherFeeStr", otherFeeStr);
  4475. }
  4476. //总计
  4477. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  4478. //国际旅费
  4479. string outsideAir = string.Empty;
  4480. string allPriceAir = string.Empty;
  4481. if (_EnterExitCosts.SumJJC == 1)
  4482. {
  4483. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4484. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  4485. }
  4486. if (_EnterExitCosts.SumGWC == 1)
  4487. {
  4488. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  4489. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4490. }
  4491. if (_EnterExitCosts.SumTDC == 1)
  4492. {
  4493. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  4494. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  4495. }
  4496. dic.Add("InTravelPrice", $"({outsideAir})");
  4497. dic.Add("FinalSumPrice", $"({allPriceAir})");
  4498. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  4499. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  4500. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  4501. foreach (var key in dic.Keys)
  4502. {
  4503. builder.MoveToBookmark(key);
  4504. builder.Write(dic[key]);
  4505. }
  4506. //模板文件名
  4507. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  4508. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4509. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4510. return Ok(JsonView(true, "成功", new { Url = url }));
  4511. }
  4512. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4513. {
  4514. //获取模板
  4515. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4516. //载入模板
  4517. WorkbookDesigner designer = new WorkbookDesigner();
  4518. designer.Workbook = new Workbook(tempPath);
  4519. Dictionary<string, string> dic = new Dictionary<string, string>();
  4520. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4521. {
  4522. List<string> list = new List<string>();
  4523. try
  4524. {
  4525. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4526. foreach (var item in spilitArr)
  4527. {
  4528. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4529. var depCode = spDotandEmpty[2].Substring(0, 3);
  4530. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4531. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4532. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4533. list.Add(depName);
  4534. list.Add(arrName);
  4535. }
  4536. list = list.Distinct().ToList();
  4537. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4538. }
  4539. catch (Exception)
  4540. {
  4541. dic.Add("ReturnCode", "行程录入不正确!");
  4542. }
  4543. }
  4544. else
  4545. {
  4546. dic.Add("ReturnCode", "未录入行程!");
  4547. }
  4548. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4549. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4550. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4551. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4552. {
  4553. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4554. dic.Add("Day", sp.Days.ToString());
  4555. }
  4556. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4557. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4558. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4559. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4560. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4561. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4562. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4563. designer.SetDataSource("Name", Names);
  4564. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4565. designer.SetDataSource("Day", dic["Day"] + "天");
  4566. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4567. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4568. int startIndex = 10;
  4569. const int startIndexcopy = 10;
  4570. if (dac2.Count == dac3.Count)//国家 币种 金额
  4571. {
  4572. for (int i = 0; i < dac2.Count; i++)
  4573. {
  4574. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4575. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4576. }
  4577. }
  4578. DataTable dtdac1 = new DataTable();
  4579. List<string> place = new List<string>();
  4580. dtdac1.Columns.AddRange(new DataColumn[] {
  4581. new DataColumn(){ ColumnName = "city"},
  4582. new DataColumn(){ ColumnName = "curr"},
  4583. new DataColumn(){ ColumnName = "criterion"},
  4584. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4585. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4586. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4587. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4588. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4589. });
  4590. DataTable dtdac2 = new DataTable();
  4591. dtdac2.Columns.AddRange(new DataColumn[] {
  4592. new DataColumn(){ ColumnName = "city"},
  4593. new DataColumn(){ ColumnName = "curr"},
  4594. new DataColumn(){ ColumnName = "criterion"},
  4595. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4596. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4597. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4598. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4599. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4600. });
  4601. dtdac1.TableName = "tb1";
  4602. dtdac2.TableName = "tb2";
  4603. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4604. foreach (var item in dac1)
  4605. {
  4606. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4607. if (place.Contains(item.Place))
  4608. {
  4609. continue;
  4610. }
  4611. DataRow row = dtdac1.NewRow();
  4612. row["city"] = item.Place;
  4613. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4614. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4615. row["curr"] = currency;
  4616. row["rate"] = rate.ToString("#0.0000");
  4617. row["criterion"] = item.Cost.ToString("#0.00");
  4618. row["number"] = 1;
  4619. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4620. //row["costRMB"] = rbmPrice;
  4621. dtdac1.Rows.Add(row);
  4622. place.Add(item.Place);
  4623. }
  4624. place = new List<string>();
  4625. foreach (var item in dac2)
  4626. {
  4627. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4628. if (place.Contains(item.Place))
  4629. {
  4630. continue;
  4631. }
  4632. DataRow row = dtdac2.NewRow();
  4633. row["city"] = item.Place;
  4634. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4635. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4636. row["curr"] = currency;
  4637. row["rate"] = rate.ToString("#0.0000");
  4638. row["criterion"] = item.Cost.ToString("#0.00");
  4639. row["number"] = 1;
  4640. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4641. //row["cost"] = item.SubTotal;
  4642. //row["costRMB"] = rbmPrice;
  4643. dtdac2.Rows.Add(row);
  4644. place.Add(item.Place);
  4645. //dac2totalPrice += rbmPrice;
  4646. }
  4647. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4648. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4649. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4650. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4651. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4652. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4653. string cell4Str1 = string.Empty;
  4654. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  4655. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  4656. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  4657. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  4658. string cellStr = $" 5.其他费用(";
  4659. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4660. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4661. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4662. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4663. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4664. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4665. if (cellStr.Length > 8)
  4666. {
  4667. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4668. }
  4669. cellStr += ")";
  4670. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4671. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  4672. decimal pxFee = dac4.Sum(it => it.Cost);
  4673. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  4674. string celllastStr1 = "";
  4675. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4676. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4677. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4678. celllastStr1 += $",国际旅费 元";
  4679. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4680. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4681. designer.SetDataSource("cell4Str", cell4Str);
  4682. designer.SetDataSource("cellStr", cellStr);
  4683. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4684. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4685. designer.SetDataSource("celllastStr", celllastStr);
  4686. Workbook wb = designer.Workbook;
  4687. var sheet = wb.Worksheets[0];
  4688. //绑定datatable数据集
  4689. designer.SetDataSource(dtdac1);
  4690. designer.SetDataSource(dtdac2);
  4691. designer.Process();
  4692. var rowStart = dtdac1.Rows.Count;
  4693. while (rowStart > 0)
  4694. {
  4695. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4696. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4697. startIndex++;
  4698. rowStart--;
  4699. }
  4700. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4701. startIndex += 1; //总计行
  4702. rowStart = dtdac2.Rows.Count;
  4703. while (rowStart > 0)
  4704. {
  4705. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4706. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4707. startIndex++;
  4708. rowStart--;
  4709. }
  4710. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4711. wb.CalculateFormula(true);
  4712. //模板文件名
  4713. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4714. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4715. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4716. return Ok(JsonView(true, "成功", new { Url = url }));
  4717. }
  4718. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4719. {
  4720. //获取模板
  4721. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4722. //载入模板
  4723. Document doc = new Document(tempPath);
  4724. DocumentBuilder builder = new DocumentBuilder(doc);
  4725. Dictionary<string, string> dic = new Dictionary<string, string>();
  4726. dic.Add("GroupName", _DelegationInfo.TeamName);
  4727. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4728. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4729. string missionLeaderJob = "";//负责人job
  4730. int groupNumber = 0; //团人数
  4731. if (DeleClientList.Count > 0)
  4732. {
  4733. missionLeader = DeleClientList[0]?.Name ?? "";
  4734. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4735. }
  4736. dic.Add("MissionLeader", missionLeader); //团负责人
  4737. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4738. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4739. #region MyRegion
  4740. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4741. //{
  4742. // List<string> list = new List<string>();
  4743. // try
  4744. // {
  4745. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4746. // foreach (var item in spilitArr)
  4747. // {
  4748. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4749. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4750. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4751. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4752. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4753. // list.Add(depName);
  4754. // list.Add(arrName);
  4755. // }
  4756. // list = list.Distinct().ToList();
  4757. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4758. // }
  4759. // catch (Exception)
  4760. // {
  4761. // dic.Add("ReturnCode", "行程录入不正确!");
  4762. // }
  4763. //}
  4764. //else
  4765. //{
  4766. // dic.Add("ReturnCode", "未录入行程!");
  4767. //}
  4768. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4769. dic.Add("ReturnCode", string.Join("、", countrys));
  4770. #endregion
  4771. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4772. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4773. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4774. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4775. //{
  4776. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4777. // dic.Add("Day", sp.Days.ToString());
  4778. //}
  4779. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4780. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4781. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4782. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4783. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4784. //培训人员名单
  4785. int cultivateRowIndex = 7;
  4786. foreach (var item in DeleClientList)
  4787. {
  4788. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4789. builder.Write(item.Name);
  4790. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4791. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4792. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4793. string birthDay = "";
  4794. if (item.Birthday != null)
  4795. {
  4796. DateTime dt = Convert.ToDateTime(item.Birthday);
  4797. birthDay = $"{dt.Year}.{dt.Month}";
  4798. }
  4799. builder.Write(birthDay);
  4800. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4801. builder.Write(item.Company);
  4802. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4803. builder.Write(item.Job);
  4804. cultivateRowIndex++;
  4805. }
  4806. //删除多余行
  4807. //cultivateRowIndex -= 2;
  4808. int delRows = 10 + 7 - cultivateRowIndex;
  4809. if (delRows > 0)
  4810. {
  4811. for (int i = 0; i < delRows; i++)
  4812. {
  4813. table1.Rows.RemoveAt(cultivateRowIndex);
  4814. //cultivateRowIndex++;
  4815. }
  4816. }
  4817. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4818. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4819. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4820. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4821. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4822. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4823. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4824. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4825. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  4826. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4827. //其他费用
  4828. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  4829. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4830. //其他费用合计
  4831. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4832. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4833. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4834. //公务舱合计
  4835. //国际旅费
  4836. string outsideJJ = "";
  4837. string allPriceJJ = "";
  4838. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  4839. {
  4840. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4841. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4842. }
  4843. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  4844. {
  4845. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  4846. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4847. }
  4848. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  4849. {
  4850. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  4851. dic.Add("AirFeeTotal", airFeeTotalStr);
  4852. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4853. dic.Add("FeeTotal", feeTotalStr);
  4854. }
  4855. foreach (var key in dic.Keys)
  4856. {
  4857. builder.MoveToBookmark(key);
  4858. builder.Write(dic[key]);
  4859. }
  4860. //模板文件名
  4861. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4862. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4863. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4864. return Ok(JsonView(true, "成功", new { Url = url }));
  4865. }
  4866. }
  4867. else if (dto.ExportType == 2) //表格
  4868. {
  4869. //利用键值对存放数据
  4870. Dictionary<string, string> dic = new Dictionary<string, string>();
  4871. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4872. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4873. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4874. dic.Add("Day", sp.Days.ToString());
  4875. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4876. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4877. {
  4878. //获取模板
  4879. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4880. //载入模板
  4881. Document doc = new Document(tempPath);
  4882. DocumentBuilder builder = new DocumentBuilder(doc);
  4883. dic.Add("TeamName", _DelegationInfo.TeamName);
  4884. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4885. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4886. string missionLeaderName = "",
  4887. missionLeaderJob = "";
  4888. if (DeleClientList.Count > 0)
  4889. {
  4890. missionLeaderName = DeleClientList[0].Name;
  4891. missionLeaderJob = DeleClientList[0].Job;
  4892. }
  4893. dic.Add("MissionLeaderName", missionLeaderName);
  4894. dic.Add("MissionLeaderJob", missionLeaderJob);
  4895. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4896. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4897. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4898. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4899. int rowCount = 10;//总人数行
  4900. int startRowIndex = 7; //起始行
  4901. for (int i = 0; i < DeleClientList.Count; i++)
  4902. {
  4903. builder.MoveToCell(0, startRowIndex, 0, 0);
  4904. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4905. builder.MoveToCell(0, startRowIndex, 1, 0);
  4906. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4907. builder.Write(sex);//性别
  4908. builder.MoveToCell(0, startRowIndex, 2, 0);
  4909. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4910. builder.MoveToCell(0, startRowIndex, 3, 0);
  4911. builder.Write(DeleClientList[i].Company);//工作单位
  4912. builder.MoveToCell(0, startRowIndex, 4, 0);
  4913. builder.Write(DeleClientList[i].Job);//职务及级别
  4914. builder.MoveToCell(0, startRowIndex, 5, 0);
  4915. builder.Write("");//人员属性
  4916. builder.MoveToCell(0, startRowIndex, 6, 0);
  4917. builder.Write("");//上次出国时间
  4918. startRowIndex++;
  4919. }
  4920. int nullRow = rowCount - DeleClientList.Count;//空行
  4921. for (int i = 0; i < nullRow; i++)
  4922. {
  4923. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4924. }
  4925. foreach (var key in dic.Keys)
  4926. {
  4927. builder.MoveToBookmark(key);
  4928. builder.Write(dic[key]);
  4929. }
  4930. //模板文件名
  4931. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4932. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4933. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4934. return Ok(JsonView(true, "成功", new { Url = url }));
  4935. }
  4936. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4937. {
  4938. //获取模板
  4939. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4940. //载入模板
  4941. Document doc = new Document(tempPath);
  4942. DocumentBuilder builder = new DocumentBuilder(doc);
  4943. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4944. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4945. dic.Add("Names", Names);
  4946. int accommodationRows = 12, foodandotherRows = 12;
  4947. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4948. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4949. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4950. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4951. int accommodationStartIndex = 6;
  4952. decimal dac1totalPrice = 0.00M;
  4953. foreach (var dac in dac1)
  4954. {
  4955. if (dac.SubTotal == 0)
  4956. {
  4957. continue;
  4958. }
  4959. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4960. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4961. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4962. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4963. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4964. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4965. builder.Write(currency);//币种
  4966. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4967. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4968. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4969. builder.Write("");//人数
  4970. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4971. builder.Write("");//天数
  4972. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4973. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4974. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4975. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4976. builder.Write(rate.ToString("#0.0000"));//汇率
  4977. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4978. decimal rbmPrice = rate * dac.SubTotal;
  4979. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4980. accommodationStartIndex++;
  4981. dac1totalPrice += rbmPrice;
  4982. }
  4983. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4984. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4985. builder.Write("小计");
  4986. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4987. builder.Write(dac1totalPrice.ToString("#0.00"));
  4988. accommodationStartIndex++;
  4989. int nullRow = accommodationRows - dac1.Count;
  4990. //删除空行
  4991. //if (nullRow > 0)
  4992. //{
  4993. // int rowIndex = accommodationStartIndex;
  4994. // for (int i = 0; i < nullRow; i++)
  4995. // {
  4996. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  4997. // row.Remove();
  4998. // rowIndex++;
  4999. // }
  5000. //}
  5001. if (dac2.Count == dac3.Count)//国家 币种 金额
  5002. {
  5003. for (int i = 0; i < dac2.Count; i++)
  5004. {
  5005. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5006. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5007. }
  5008. }
  5009. int foodandotherStartIndex = 19;//
  5010. decimal dac2totalPrice = 0.00M;
  5011. foreach (var dac in dac2)
  5012. {
  5013. if (dac.SubTotal == 0)
  5014. {
  5015. continue;
  5016. }
  5017. //foodandotherStartIndex = 12;
  5018. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5019. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5020. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5021. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5022. builder.Write(currency);//币种
  5023. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5024. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5025. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5026. builder.Write("");//人数
  5027. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5028. builder.Write("");//天数
  5029. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5030. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5031. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5032. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5033. builder.Write(rate.ToString("#0.0000"));//汇率
  5034. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5035. decimal rbmPrice = rate * dac.SubTotal;
  5036. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5037. foodandotherStartIndex++;
  5038. dac2totalPrice += rbmPrice;
  5039. }
  5040. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5041. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5042. //删除空行
  5043. //if (dac2.Count < foodandotherRows)
  5044. //{
  5045. // while (table2.Rows.Count > dac2.Count)
  5046. // {
  5047. // table2.Rows.RemoveAt(dac2.Count);
  5048. // }
  5049. //}
  5050. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5051. string otherFeeStr = "";
  5052. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5053. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5054. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5055. if (otherFeeStr.Length > 0)
  5056. {
  5057. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5058. otherFeeStr = $"({otherFeeStr})";
  5059. dic.Add("OtherFeeStr", otherFeeStr);
  5060. }
  5061. foreach (var key in dic.Keys)
  5062. {
  5063. builder.MoveToBookmark(key);
  5064. builder.Write(dic[key]);
  5065. }
  5066. //模板文件名
  5067. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5068. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5069. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5070. return Ok(JsonView(true, "成功", new { Url = url }));
  5071. }
  5072. }
  5073. else if (dto.ExportType == 3)
  5074. {
  5075. if (dto.SubTypeId == 1) //团组成员名单
  5076. {
  5077. if (DeleClientList.Count < 1)
  5078. {
  5079. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  5080. }
  5081. //获取模板
  5082. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5083. //载入模板
  5084. Document doc = new Document(tempPath);
  5085. DocumentBuilder builder = new DocumentBuilder(doc);
  5086. //获取word里所有表格
  5087. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5088. //获取所填表格的序数
  5089. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5090. var rowStart = tableOne.Rows[0]; //获取第1行
  5091. //循环赋值
  5092. for (int i = 0; i < DeleClientList.Count; i++)
  5093. {
  5094. builder.MoveToCell(0, i + 1, 0, 0);
  5095. builder.Write(DeleClientList[i].Name);
  5096. builder.MoveToCell(0, i + 1, 1, 0);
  5097. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5098. builder.Write(sex);
  5099. builder.MoveToCell(0, i + 1, 2, 0);
  5100. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5101. builder.MoveToCell(0, i + 1, 3, 0);
  5102. builder.Write(DeleClientList[i].Company);
  5103. builder.MoveToCell(0, i + 1, 4, 0);
  5104. builder.Write(DeleClientList[i].Job);
  5105. }
  5106. //删除多余行
  5107. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5108. {
  5109. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5110. }
  5111. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5112. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5113. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5114. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5115. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5116. return Ok(JsonView(true, "成功", new { Url = url }));
  5117. }
  5118. }
  5119. return Ok(JsonView(false, "操作失败!"));
  5120. }
  5121. catch (Exception ex)
  5122. {
  5123. return Ok(JsonView(false, ex.Message));
  5124. }
  5125. }
  5126. /// <summary>
  5127. /// 获取三公费用标准city
  5128. /// </summary>
  5129. /// <param name="placeData"></param>
  5130. /// <param name="nationalTravelFeeId"></param>
  5131. /// <returns></returns>
  5132. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5133. {
  5134. string _city = string.Empty;
  5135. if (placeData.Count < 1) return _city;
  5136. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5137. if (data == null) return _city;
  5138. string country = data.Country;
  5139. string city = data.City;
  5140. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5141. else _city = city;
  5142. return _city;
  5143. }
  5144. /// <summary>
  5145. /// 团组模块 - 出入境费用 - 明细表导出
  5146. /// </summary>
  5147. /// <returns></returns>
  5148. [HttpPost]
  5149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5150. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5151. {
  5152. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5153. if (data.Code != 0)
  5154. {
  5155. return Ok(JsonView(false, data.Msg));
  5156. }
  5157. return Ok(JsonView(true, data.Msg, data.Data));
  5158. }
  5159. /// <summary>
  5160. /// 团组模块 - 出入境费用 - 一键清空
  5161. /// </summary>
  5162. /// <returns></returns>
  5163. [HttpPost]
  5164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5165. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5166. {
  5167. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5168. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5169. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5170. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5171. if (_view.Code == 0)
  5172. {
  5173. return Ok(JsonView(true, "操作成功"));
  5174. }
  5175. return Ok(JsonView(false, "操作失败"));
  5176. }
  5177. /// <summary>
  5178. /// 团组模块 - 出入境费用 - 子项删除
  5179. /// </summary>
  5180. /// <returns></returns>
  5181. [HttpPost]
  5182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5183. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5184. {
  5185. try
  5186. {
  5187. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5188. if (data.Code != 0)
  5189. {
  5190. return Ok(JsonView(false, data.Msg));
  5191. }
  5192. return Ok(JsonView(true, "操作成功!", data.Data));
  5193. }
  5194. catch (Exception ex)
  5195. {
  5196. return Ok(JsonView(false, ex.Message));
  5197. }
  5198. }
  5199. /// <summary>
  5200. /// 团组模块 - 出入境国家费用标准 List
  5201. /// </summary>
  5202. /// <returns></returns>
  5203. [HttpPost]
  5204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5205. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  5206. {
  5207. try
  5208. {
  5209. Stopwatch sw = new Stopwatch();
  5210. sw.Start();
  5211. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  5212. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5213. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5214. Where gntf.Isdel = 0");
  5215. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  5216. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  5217. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  5218. //foreach (var item in nationalTravel)
  5219. //{
  5220. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  5221. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  5222. // if (otherData != null)
  5223. // {
  5224. // cityData.Remove(otherData);
  5225. // cityData.Add(otherData);
  5226. // }
  5227. // nationalTravelFeeData1.Add(new
  5228. // {
  5229. // Country = item.Country,
  5230. // CityData = cityData
  5231. // });
  5232. //}
  5233. sw.Stop();
  5234. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  5235. }
  5236. catch (Exception ex)
  5237. {
  5238. return Ok(JsonView(false, ex.Message));
  5239. throw;
  5240. }
  5241. }
  5242. /// <summary>
  5243. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  5244. /// </summary>
  5245. /// <returns></returns>
  5246. [HttpPost]
  5247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5248. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  5249. {
  5250. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  5251. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  5252. List<string> countryData = new List<string>();
  5253. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  5254. countryData = countryData.Distinct().ToList();
  5255. List<dynamic> dataSource = new List<dynamic>();
  5256. foreach (var item in countryData)
  5257. {
  5258. List<string> cityData1 = new List<string>();
  5259. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  5260. var countryData2 = new
  5261. {
  5262. CountryName = item,
  5263. CityData = cityData1
  5264. };
  5265. dataSource.Add(countryData2);
  5266. }
  5267. return Ok(JsonView(true, "查询成功!", dataSource));
  5268. }
  5269. /// <summary>
  5270. /// 团组模块 - 出入境国家费用标准 Page List
  5271. /// </summary>
  5272. /// <returns></returns>
  5273. [HttpPost]
  5274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5275. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  5276. {
  5277. int portId = dto.PortType;
  5278. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5279. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  5280. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  5281. string whereSql = string.Empty;
  5282. if (!string.IsNullOrEmpty(dto.Country))
  5283. {
  5284. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  5285. }
  5286. if (!string.IsNullOrEmpty(dto.City))
  5287. {
  5288. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  5289. }
  5290. string pageSql = string.Format(@"Select * From (
  5291. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  5292. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  5293. From Grp_NationalTravelFee gntf
  5294. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5295. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5296. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  5297. RefAsync<int> total = 0;
  5298. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  5299. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  5300. }
  5301. /// <summary>
  5302. /// 团组模块 - 出入境国家费用标准 根据城市查询
  5303. /// </summary>
  5304. /// <returns></returns>
  5305. [HttpPost]
  5306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5307. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  5308. {
  5309. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  5310. int portId = dto.PortType;
  5311. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5312. string whereSql = string.Empty;
  5313. if (!string.IsNullOrEmpty(dto.Country))
  5314. {
  5315. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  5316. }
  5317. if (!string.IsNullOrEmpty(dto.City))
  5318. {
  5319. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  5320. }
  5321. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  5322. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  5323. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  5324. From Grp_NationalTravelFee gntf
  5325. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5326. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5327. Where gntf.Isdel = 0 {0} ", whereSql);
  5328. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  5329. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  5330. }
  5331. /// <summary>
  5332. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  5333. /// </summary>
  5334. /// <returns></returns>
  5335. [HttpPost]
  5336. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5337. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  5338. {
  5339. try
  5340. {
  5341. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  5342. if (data.Code != 0)
  5343. {
  5344. return Ok(JsonView(false, data.Msg));
  5345. }
  5346. return Ok(JsonView(true, "操作成功!", data.Data));
  5347. }
  5348. catch (Exception ex)
  5349. {
  5350. return Ok(JsonView(false, ex.Message));
  5351. }
  5352. }
  5353. /// <summary>
  5354. /// 团组模块 - 出入境国家费用标准 - Del
  5355. /// </summary>
  5356. /// <returns></returns>
  5357. [HttpPost]
  5358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5359. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  5360. {
  5361. try
  5362. {
  5363. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  5364. {
  5365. Id = dto.Id,
  5366. DeleteUserId = dto.DeleteUserId,
  5367. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5368. IsDel = 1
  5369. };
  5370. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  5371. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  5372. .WhereColumns(it => new { it.Id })
  5373. .ExecuteCommandAsync();
  5374. if (delStatus <= 0)
  5375. {
  5376. return Ok(JsonView(false, "删除失败!"));
  5377. }
  5378. return Ok(JsonView(true, "操作成功!"));
  5379. }
  5380. catch (Exception ex)
  5381. {
  5382. return Ok(JsonView(false, ex.Message));
  5383. }
  5384. }
  5385. #endregion
  5386. #region 签证费用录入
  5387. /// <summary>
  5388. /// 根据diid查询签证费用列表
  5389. /// </summary>
  5390. /// <param name="dto"></param>
  5391. /// <returns></returns>
  5392. [HttpPost]
  5393. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5394. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  5395. {
  5396. try
  5397. {
  5398. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  5399. if (groupData.Code != 0)
  5400. {
  5401. return Ok(JsonView(false, groupData.Msg));
  5402. }
  5403. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5404. }
  5405. catch (Exception ex)
  5406. {
  5407. return Ok(JsonView(false, ex.Message));
  5408. }
  5409. }
  5410. /// <summary>
  5411. /// 根据签证费用Id查询单条数据及c表数据
  5412. /// </summary>
  5413. /// <param name="dto"></param>
  5414. /// <returns></returns>
  5415. [HttpPost]
  5416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5417. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  5418. {
  5419. try
  5420. {
  5421. Result groupData = await _visaPriceRep.PostVisaById(dto);
  5422. if (groupData.Code != 0)
  5423. {
  5424. return Ok(JsonView(false, groupData.Msg));
  5425. }
  5426. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5427. }
  5428. catch (Exception ex)
  5429. {
  5430. return Ok(JsonView(false, ex.Message));
  5431. }
  5432. }
  5433. /// <summary>
  5434. /// 签证费用删除
  5435. /// </summary>
  5436. /// <param name="dto"></param>
  5437. /// <returns></returns>
  5438. [HttpPost]
  5439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5440. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  5441. {
  5442. _sqlSugar.BeginTran();
  5443. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  5444. if (!res)
  5445. {
  5446. _sqlSugar.RollbackTran();
  5447. return Ok(JsonView(false, "删除失败"));
  5448. }
  5449. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5450. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  5451. .SetColumns(a => new Grp_CreditCardPayment()
  5452. {
  5453. IsDel = 1,
  5454. DeleteUserId = dto.DeleteUserId,
  5455. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5456. }).ExecuteCommand();
  5457. if (resSub < 1)
  5458. {
  5459. _sqlSugar.RollbackTran();
  5460. return Ok(JsonView(false, "删除失败"));
  5461. }
  5462. _sqlSugar.CommitTran();
  5463. return Ok(JsonView(true, "删除成功!"));
  5464. }
  5465. /// <summary>
  5466. /// 签证费用录入下拉框初始化
  5467. /// </summary>
  5468. /// <returns></returns>
  5469. [HttpPost]
  5470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5471. public async Task<IActionResult> VisaPriceAddSelect()
  5472. {
  5473. try
  5474. {
  5475. //支付方式
  5476. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  5477. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  5478. //币种
  5479. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  5480. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  5481. //乘客类型
  5482. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  5483. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  5484. //卡类型
  5485. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  5486. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  5487. var data = new
  5488. {
  5489. Payment = _Payment,
  5490. CurrencyList = _CurrencyList,
  5491. PassengerType = _PassengerType,
  5492. BankCard = _BankCard
  5493. };
  5494. return Ok(JsonView(true, "查询成功!", data));
  5495. }
  5496. catch (Exception ex)
  5497. {
  5498. return Ok(JsonView(false, "程序错误!"));
  5499. throw;
  5500. }
  5501. }
  5502. /// <summary>
  5503. /// 签证费用录入操作(Status:1.新增,2.修改)
  5504. /// </summary>
  5505. /// <param name="dto"></param>
  5506. /// <returns></returns>
  5507. [HttpPost]
  5508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5509. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  5510. {
  5511. try
  5512. {
  5513. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  5514. if (groupData.Code != 0)
  5515. {
  5516. return Ok(JsonView(false, groupData.Msg));
  5517. }
  5518. #region 应用推送
  5519. try
  5520. {
  5521. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5522. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5523. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5524. }
  5525. catch (Exception ex)
  5526. {
  5527. }
  5528. #endregion
  5529. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5530. }
  5531. catch (Exception ex)
  5532. {
  5533. return Ok(JsonView(false, ex.Message));
  5534. }
  5535. }
  5536. #endregion
  5537. #region 签证提成录入
  5538. /// <summary>
  5539. /// 签证提成录入
  5540. /// 基础数据
  5541. /// </summary>
  5542. /// <param name="_dto"></param>
  5543. /// <returns></returns>
  5544. [HttpGet]
  5545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5546. public async Task<IActionResult> VisaCommissionInit()
  5547. {
  5548. return Ok(await _visaCommissionRep._Init());
  5549. }
  5550. /// <summary>
  5551. /// 签证提成录入
  5552. /// Item
  5553. /// </summary>
  5554. /// <param name="_dto"></param>
  5555. /// <returns></returns>
  5556. [HttpGet]
  5557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5558. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto dto)
  5559. {
  5560. var validator = new VisaCommissionItemDtoValidator();
  5561. var validatorRes = await validator.ValidateAsync(dto);
  5562. if (!validatorRes.IsValid)
  5563. {
  5564. StringBuilder sb = new StringBuilder();
  5565. foreach (var item in validatorRes.Errors)
  5566. {
  5567. sb.AppendLine(item.ErrorMessage);
  5568. }
  5569. return Ok(JsonView(false, sb.ToString()));
  5570. }
  5571. return Ok(await _visaCommissionRep._Init());
  5572. }
  5573. #endregion
  5574. #region op费用录入
  5575. /// <summary>
  5576. /// 根据diid查询op费用列表
  5577. /// </summary>
  5578. /// <param name="dto"></param>
  5579. /// <returns></returns>
  5580. [HttpPost]
  5581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5582. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  5583. {
  5584. try
  5585. {
  5586. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  5587. if (groupData.Code != 0)
  5588. {
  5589. return Ok(JsonView(false, groupData.Msg));
  5590. }
  5591. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5592. }
  5593. catch (Exception ex)
  5594. {
  5595. return Ok(JsonView(false, ex.Message));
  5596. }
  5597. }
  5598. /// <summary>
  5599. /// 根据op费用Id查询单条数据及c表数据
  5600. /// </summary>
  5601. /// <param name="dto"></param>
  5602. /// <returns></returns>
  5603. [HttpPost]
  5604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5605. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  5606. {
  5607. try
  5608. {
  5609. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  5610. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  5611. var data = new
  5612. {
  5613. CarTouristGuideGround = _groupData,
  5614. CreditCardPayment = _creditCardPayment
  5615. };
  5616. return Ok(JsonView(true, "查询成功!", data));
  5617. }
  5618. catch (Exception ex)
  5619. {
  5620. return Ok(JsonView(false, "程序错误!"));
  5621. }
  5622. }
  5623. /// <summary>
  5624. /// op费用删除
  5625. /// </summary>
  5626. /// <param name="dto"></param>
  5627. /// <returns></returns>
  5628. [HttpPost]
  5629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5630. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  5631. {
  5632. try
  5633. {
  5634. _sqlSugar.BeginTran();
  5635. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  5636. if (!res)
  5637. {
  5638. return Ok(JsonView(false, "删除失败"));
  5639. }
  5640. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  5641. {
  5642. IsDel = 1,
  5643. DeleteUserId = dto.DeleteUserId,
  5644. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5645. }).ExecuteCommandAsync();
  5646. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  5647. {
  5648. IsDel = 1,
  5649. DeleteUserId = dto.DeleteUserId,
  5650. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5651. }).ExecuteCommandAsync();
  5652. #region 删除超支相关数据
  5653. //删除导入的超支数据
  5654. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  5655. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  5656. {
  5657. IsDel = 1,
  5658. DeleteUserId = dto.DeleteUserId,
  5659. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5660. }).ExecuteCommand();
  5661. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  5662. {
  5663. IsDel = 1,
  5664. DeleteUserId = dto.DeleteUserId,
  5665. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5666. }).ExecuteCommand() ;
  5667. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x=>x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  5668. {
  5669. IsDel = 1,
  5670. DeleteUserId = dto.DeleteUserId,
  5671. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5672. }).ExecuteCommand();
  5673. #endregion
  5674. _sqlSugar.CommitTran();
  5675. return Ok(JsonView(true, "删除成功!"));
  5676. }
  5677. catch (Exception ex)
  5678. {
  5679. _sqlSugar.RollbackTran();
  5680. return Ok(JsonView(false, "程序错误!" + ex.Message));
  5681. }
  5682. }
  5683. /// <summary>
  5684. /// op费用录入操作(Status:1.新增,2.修改)
  5685. /// </summary>
  5686. /// <param name="dto"></param>
  5687. /// <returns></returns>
  5688. [HttpPost]
  5689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5690. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5691. {
  5692. try
  5693. {
  5694. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5695. if (groupData.Code != 0)
  5696. {
  5697. return Ok(JsonView(false, groupData.Msg));
  5698. }
  5699. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5700. }
  5701. catch (Exception ex)
  5702. {
  5703. return Ok(JsonView(false, ex.Message));
  5704. }
  5705. }
  5706. /// <summary>
  5707. /// 填写费用详细页面初始化绑定
  5708. /// </summary>
  5709. /// <param name="dto"></param>
  5710. /// <returns></returns>
  5711. [HttpPost]
  5712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5713. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  5714. {
  5715. try
  5716. {
  5717. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  5718. if (groupData.Code != 0)
  5719. {
  5720. return Ok(JsonView(false, groupData.Msg));
  5721. }
  5722. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5723. }
  5724. catch (Exception ex)
  5725. {
  5726. return Ok(JsonView(false, ex.Message));
  5727. }
  5728. }
  5729. /// <summary>
  5730. /// 根据op费用Id查询详细数据
  5731. /// </summary>
  5732. /// <param name="dto"></param>
  5733. /// <returns></returns>
  5734. [HttpPost]
  5735. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5736. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  5737. {
  5738. try
  5739. {
  5740. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  5741. if (groupData.Code != 0)
  5742. {
  5743. return Ok(JsonView(false, groupData.Msg));
  5744. }
  5745. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5746. }
  5747. catch (Exception ex)
  5748. {
  5749. return Ok(JsonView(false, ex.Message));
  5750. }
  5751. }
  5752. /// <summary>
  5753. /// OP费用录入填写详情
  5754. /// </summary>
  5755. /// <param name="dto"></param>
  5756. /// <returns></returns>
  5757. [HttpPost]
  5758. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5759. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  5760. {
  5761. try
  5762. {
  5763. #region 参数校验
  5764. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  5765. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  5766. if (di == null) return Ok(JsonView(false, "团组错误!"));
  5767. #endregion
  5768. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5769. if (groupData.Code != 0)
  5770. {
  5771. return Ok(JsonView(false, groupData.Msg));
  5772. }
  5773. //自动审核
  5774. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  5775. #region 应用推送
  5776. try
  5777. {
  5778. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5779. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5780. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5781. }
  5782. catch (Exception ex)
  5783. {
  5784. }
  5785. #endregion
  5786. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5787. }
  5788. catch (Exception ex)
  5789. {
  5790. return Ok(JsonView(false, ex.Message));
  5791. }
  5792. }
  5793. /// <summary>
  5794. /// 获取三公详细所有城市
  5795. /// </summary>
  5796. /// <returns></returns>
  5797. [HttpGet]
  5798. public IActionResult OpCarCityResult()
  5799. {
  5800. var jw = JsonView(false);
  5801. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  5802. {
  5803. x.Id,
  5804. x.Country,
  5805. x.City,
  5806. }).ToList();
  5807. if (data.Count > 0)
  5808. {
  5809. jw = JsonView(true, "获取成功!", data);
  5810. }
  5811. else
  5812. {
  5813. jw.Msg = "城市数据为空!";
  5814. jw.Data = new string[0];
  5815. }
  5816. return Ok(jw);
  5817. }
  5818. /// <summary>
  5819. /// 导出地接费用明细
  5820. /// </summary>
  5821. /// <param name="dto"></param>
  5822. /// <returns></returns>
  5823. [HttpPost]
  5824. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  5825. {
  5826. var jw = JsonView(false);
  5827. if (dto.Diid < 1)
  5828. {
  5829. jw.Msg = "请输入正确的diid!";
  5830. return Ok(jw);
  5831. }
  5832. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5833. if (group == null)
  5834. {
  5835. jw.Msg = "未找到团组信息!";
  5836. return Ok(jw);
  5837. }
  5838. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  5839. if (localGuideArr.Count == 0)
  5840. {
  5841. jw.Msg = "该团组暂无地接信息!";
  5842. return Ok(jw);
  5843. }
  5844. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  5845. var overspendSoure = new Dictionary<int, int>
  5846. {
  5847. { 91, 982 }, //车
  5848. { 92 , 1059} ,//导游
  5849. { 994 , 1073}, //翻译
  5850. { 988 , 1074 }, //早餐
  5851. { 93 , 1075 }, //午餐
  5852. { 989 , 1076 }, //晚餐
  5853. };
  5854. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5855. foreach (var groupArr in localGroup)
  5856. {
  5857. var keyValue = groupArr.Key;
  5858. if (int.TryParse(keyValue, out int cityid))
  5859. {
  5860. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  5861. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  5862. }
  5863. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  5864. foreach (var item in groupArr)
  5865. {
  5866. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  5867. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  5868. new Grp_CarTouristGuideGroundReservationsContentExtend
  5869. {
  5870. Count = a.Count,
  5871. CreateTime = a.CreateTime,
  5872. CreateUserId = a.CreateUserId,
  5873. CTGGRId = a.CTGGRId,
  5874. Currency = a.Currency,
  5875. DatePrice = a.DatePrice,
  5876. DeleteTime = a.DeleteTime,
  5877. DeleteUserId = a.DeleteUserId,
  5878. DiId = a.DiId,
  5879. Id = a.Id,
  5880. IsDel = a.IsDel,
  5881. Price = a.Price,
  5882. PriceContent = a.PriceContent,
  5883. Remark = a.Remark,
  5884. SId = a.SId,
  5885. SidName = b.Name,
  5886. Units = a.Units,
  5887. }
  5888. ).ToList();
  5889. if (content.Count > 0)
  5890. {
  5891. contentArr.Add(content);
  5892. }
  5893. }
  5894. //open excel
  5895. //set excel
  5896. //save excel
  5897. try
  5898. {
  5899. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  5900. IWorkbook workbook;
  5901. if (Path.GetExtension(filePath).ToLower() == ".xls")
  5902. {
  5903. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5904. }
  5905. else
  5906. {
  5907. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5908. }
  5909. ISheet sheet = workbook.GetSheetAt(0);
  5910. var rowStartIndex = 2;
  5911. var clounmCount = 10;
  5912. var initStyleRow = sheet.GetRow(2);
  5913. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  5914. //var overspendArrDetail =
  5915. var existsId = new List<CarCompare>();
  5916. var lastElem = arr.Last();
  5917. var thisSid = -1;
  5918. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  5919. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  5920. {
  5921. Name = "未知币种!",
  5922. Remark = "未知币种!",
  5923. };
  5924. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  5925. Action cloneRowFn = () =>
  5926. {
  5927. rowStartIndex++;
  5928. var cloneRow = sheet.CreateRow(rowStartIndex);
  5929. // 复制样式
  5930. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  5931. {
  5932. ICell sourceCell = initStyleRow.GetCell(i);
  5933. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  5934. // 确保单元格存在样式
  5935. if (sourceCell.CellStyle != null)
  5936. {
  5937. targetCell.CellStyle = sourceCell.CellStyle;
  5938. }
  5939. }
  5940. };
  5941. var mergeRow = () =>
  5942. {
  5943. for (int i = 2; i < sheet.LastRowNum; i++)
  5944. {
  5945. var row = sheet.GetRow(i);
  5946. var cellFirst = row.GetCell(0);
  5947. var thisIndex = i + 1;
  5948. while (thisIndex < sheet.LastRowNum)
  5949. {
  5950. var nextRow = sheet.GetRow(thisIndex);
  5951. var nextCellFirst = nextRow.GetCell(0);
  5952. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  5953. {
  5954. thisIndex++;
  5955. }
  5956. else
  5957. {
  5958. break;
  5959. }
  5960. }
  5961. thisIndex--;
  5962. if (thisIndex != i)
  5963. {
  5964. //合并row
  5965. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5966. i, // 起始行索引(0-based)
  5967. thisIndex, // 结束行索引(0-based)
  5968. 0, // 起始列索引(0-based)
  5969. 0 // 结束列索引(0-based)
  5970. );
  5971. sheet.AddMergedRegion(cellRangeAddress);
  5972. i = thisIndex;
  5973. }
  5974. }
  5975. };
  5976. var chaoshiNumber = 0;
  5977. var totalNumber = 0.00M;
  5978. string lastStr = "";
  5979. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  5980. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  5981. {
  5982. b.IsAuditGM,
  5983. x.Id,
  5984. x.Area,
  5985. b.PayPercentage,
  5986. b.PayMoney,
  5987. }).ToList();
  5988. string yesPayment = "", noPayment = "";
  5989. foreach (var item in queryCarArrByCityAndDiid)
  5990. {
  5991. if (item.IsAuditGM == 1)
  5992. {
  5993. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5994. }
  5995. else
  5996. {
  5997. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5998. }
  5999. }
  6000. lastStr = yesPayment + noPayment;
  6001. foreach (var item in arr)
  6002. {
  6003. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  6004. {
  6005. if (thisSid != item.SId)
  6006. {
  6007. if (thisSid == -1)
  6008. {
  6009. thisSid = item.SId;
  6010. }
  6011. else
  6012. {
  6013. //合并小计行
  6014. //创建合并区域的实例
  6015. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6016. rowStartIndex, // 起始行索引(0-based)
  6017. rowStartIndex, // 结束行索引(0-based)
  6018. 0, // 起始列索引(0-based)
  6019. 3 // 结束列索引(0-based)
  6020. );
  6021. sheet.AddMergedRegion(cellRangeAddress);
  6022. var CellStyle = workbook.CreateCellStyle();
  6023. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6024. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6025. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6026. for (int i = 0; i <= clounmCount; i++)
  6027. {
  6028. if (i > 6)
  6029. {
  6030. var CellStyle1 = workbook.CreateCellStyle();
  6031. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6032. IFont Font = workbook.CreateFont(); // 创建字体
  6033. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6034. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6035. CellStyle1.SetFont(Font);
  6036. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6037. }
  6038. else
  6039. {
  6040. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6041. }
  6042. }
  6043. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6044. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6045. //超时合计
  6046. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6047. //超时数
  6048. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6049. //超时合计费用
  6050. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6051. thisSid = item.SId;
  6052. cloneRowFn();
  6053. chaoshiNumber = 0;
  6054. totalNumber = 0;
  6055. }
  6056. }
  6057. IRow row = sheet.GetRow(rowStartIndex);
  6058. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6059. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  6060. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  6061. if (isOpenOverspendSoure)
  6062. {
  6063. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6064. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  6065. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  6066. }
  6067. for (int i = 0; i <= clounmCount; i++)
  6068. {
  6069. var cell = row.GetCell(i);
  6070. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  6071. if (cell == null)
  6072. {
  6073. cell = row.CreateCell(i);
  6074. }
  6075. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  6076. fontRed.CloneStyleFrom(cell.CellStyle);
  6077. IFont Font = workbook.CreateFont(); // 创建字体
  6078. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  6079. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6080. fontRed.SetFont(Font);
  6081. byte[] rgb = new byte[3] { 255, 242, 204 };
  6082. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  6083. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  6084. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  6085. if (workbook is XSSFWorkbook)
  6086. {
  6087. BackgroundColor255_242_204.FillForegroundColor = 0;
  6088. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  6089. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  6090. }
  6091. else
  6092. {
  6093. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  6094. }
  6095. if (i == 1 || i > 6)
  6096. {
  6097. if (i > 6)
  6098. {
  6099. fontRed.FillForegroundColor = 0;
  6100. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  6101. fontRed.FillPattern = FillPattern.SolidForeground;
  6102. }
  6103. cell.CellStyle = fontRed;
  6104. }
  6105. if (i > 2 && i < 7)
  6106. {
  6107. cell.CellStyle = BackgroundColor255_242_204;
  6108. }
  6109. cell.SetCellValue(setCellValue); //写入单元格
  6110. }
  6111. if (overspendSoure.ContainsKey(thisSid))
  6112. {
  6113. var overspendId = overspendSoure[thisSid];
  6114. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6115. }
  6116. cloneRowFn();
  6117. existsId.Add(new CarCompare
  6118. {
  6119. DataPrice = item.DatePrice.ObjToDate(),
  6120. Sid = item.SId
  6121. });
  6122. }
  6123. if (item.Equals(lastElem))
  6124. {
  6125. //合并小计行
  6126. //创建合并区域的实例
  6127. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6128. rowStartIndex, // 起始行索引(0-based)
  6129. rowStartIndex, // 结束行索引(0-based)
  6130. 0, // 起始列索引(0-based)
  6131. 3 // 结束列索引(0-based)
  6132. );
  6133. sheet.AddMergedRegion(cellRangeAddress);
  6134. var CellStyle = workbook.CreateCellStyle();
  6135. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6136. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6137. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6138. for (int i = 0; i <= clounmCount; i++)
  6139. {
  6140. if (i > 6)
  6141. {
  6142. var CellStyle1 = workbook.CreateCellStyle();
  6143. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6144. IFont Font = workbook.CreateFont(); // 创建字体
  6145. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6146. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6147. CellStyle1.SetFont(Font);
  6148. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6149. }
  6150. else
  6151. {
  6152. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6153. }
  6154. }
  6155. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6156. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6157. //超时合计
  6158. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6159. //超时数
  6160. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6161. //超时合计费用
  6162. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6163. cloneRowFn();
  6164. // 创建合并区域的实例
  6165. cellRangeAddress = new CellRangeAddress(
  6166. rowStartIndex, // 起始行索引(0-based)
  6167. rowStartIndex, // 结束行索引(0-based)
  6168. 0, // 起始列索引(0-based)
  6169. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  6170. );
  6171. // 添加合并区域
  6172. sheet.AddMergedRegion(cellRangeAddress);
  6173. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  6174. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  6175. }
  6176. }
  6177. mergeRow();
  6178. // 保存修改后的Excel文件到新文件
  6179. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  6180. // new FileStream(newFilePath, FileMode.CreateNew)
  6181. using (var stream = new MemoryStream())
  6182. {
  6183. workbook.Write(stream, true);
  6184. stream.Flush();
  6185. stream.Seek(0, SeekOrigin.Begin);
  6186. MemoryStream memoryStream = new MemoryStream();
  6187. stream.CopyTo(memoryStream);
  6188. memoryStream.Seek(0, SeekOrigin.Begin);
  6189. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  6190. }
  6191. workbook.Close();
  6192. workbook.Dispose();
  6193. }
  6194. catch (Exception ex)
  6195. {
  6196. jw.Msg = "出现异常!" + ex.Message;
  6197. return Ok(jw);
  6198. }
  6199. }
  6200. if (Zips.Count > 0)
  6201. {
  6202. IOOperatorHelper io = new IOOperatorHelper();
  6203. var byts = io.ConvertZipStream(Zips);
  6204. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  6205. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  6206. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  6207. }
  6208. else
  6209. {
  6210. jw.Msg = "暂无生成文件!";
  6211. }
  6212. return Ok(jw);
  6213. }
  6214. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  6215. {
  6216. string outStr = string.Empty;
  6217. switch (i)
  6218. {
  6219. case 0:
  6220. outStr = arr[0].SidName;
  6221. break;
  6222. case 1:
  6223. outStr = arr[0].DataPriceStr;
  6224. break;
  6225. case 2:
  6226. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  6227. break;
  6228. case 4:
  6229. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  6230. break;
  6231. case 7:
  6232. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6233. {
  6234. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  6235. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  6236. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  6237. }
  6238. break;
  6239. case 8:
  6240. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6241. {
  6242. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  6243. }
  6244. break;
  6245. case 9:
  6246. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6247. {
  6248. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  6249. }
  6250. break;
  6251. case 10:
  6252. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6253. {
  6254. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  6255. }
  6256. break;
  6257. }
  6258. return outStr;
  6259. }
  6260. #region OP行程单
  6261. /// <summary>
  6262. /// OP行程单初始化
  6263. /// </summary>
  6264. /// <param name="dto"></param>
  6265. /// <returns></returns>
  6266. [HttpPost]
  6267. public IActionResult InitOpTravel(InitOpTravelDto dto)
  6268. {
  6269. var jw = JsonView(false);
  6270. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  6271. var group = groupList.First();
  6272. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  6273. if (group == null)
  6274. {
  6275. jw.Msg = "暂无团组!";
  6276. return Ok(jw);
  6277. }
  6278. group = groupList.Find(x => x.Id == diid);
  6279. if (group == null)
  6280. {
  6281. jw.Msg = "请输入正确的团组ID!";
  6282. return Ok(jw);
  6283. }
  6284. string city = string.Empty;
  6285. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  6286. if (blackCode.Count > 0)
  6287. {
  6288. var black = blackCode.First();
  6289. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  6290. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  6291. if (blackSp.Length > 0)
  6292. {
  6293. try
  6294. {
  6295. var cityArrCode = new List<string>(20);
  6296. foreach (var item in blackSp)
  6297. {
  6298. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  6299. var IndexSelect = itemSp[2];
  6300. var cityArrCodeLength = cityArrCode.Count - 1;
  6301. var startCity = IndexSelect.Substring(0, 3);
  6302. if (cityArrCodeLength > 0)
  6303. {
  6304. var arrEndCity = cityArrCode[cityArrCodeLength];
  6305. if (arrEndCity != startCity)
  6306. {
  6307. cityArrCode.Add(startCity.ToUpper());
  6308. }
  6309. }
  6310. else
  6311. {
  6312. cityArrCode.Add(startCity.ToUpper());
  6313. }
  6314. var endCity = IndexSelect.Substring(3, 3);
  6315. cityArrCode.Add(endCity.ToUpper());
  6316. }
  6317. var cityThree = string.Empty;
  6318. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  6319. cityThree = cityThree.TrimEnd(',');
  6320. if (string.IsNullOrWhiteSpace(cityThree))
  6321. {
  6322. throw new
  6323. Exception("error");
  6324. }
  6325. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  6326. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  6327. foreach (var item in cityArrCode)
  6328. {
  6329. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  6330. if (find != null)
  6331. {
  6332. city += find.City + "/";
  6333. }
  6334. else
  6335. {
  6336. city += item + "三字码未收入/";
  6337. }
  6338. }
  6339. city = city.TrimEnd('/');
  6340. }
  6341. catch (Exception e)
  6342. {
  6343. city = "黑屏代码格式不正确!";
  6344. }
  6345. }
  6346. }
  6347. else
  6348. {
  6349. city = "未录入黑屏代码";
  6350. }
  6351. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  6352. {
  6353. Date = x.Date,
  6354. Days = x.Days,
  6355. Diffgroup = x.Diffgroup,
  6356. Diid = x.Diid,
  6357. Traffic_First = x.Traffic_First,
  6358. Traffic_Second = x.Traffic_Second,
  6359. Trip = x.Trip,
  6360. WeekDay = x.WeekDay,
  6361. Id = x.Id
  6362. }).ToList();
  6363. jw.Data = new
  6364. {
  6365. groupList = groupList.Select(x => new
  6366. {
  6367. x.Id,
  6368. x.TeamName,
  6369. x.TourCode
  6370. }).ToList(),
  6371. groupInfo = new
  6372. {
  6373. group.VisitDays,
  6374. group.TourCode,
  6375. group.VisitPNumber,
  6376. group.TeamName,
  6377. city
  6378. },
  6379. OpTravelList
  6380. };
  6381. jw.Code = 200;
  6382. jw.Msg = "操作成功!";
  6383. return Ok(jw);
  6384. }
  6385. /// <summary>
  6386. /// 删除团组行程单
  6387. /// </summary>
  6388. /// <returns></returns>
  6389. [HttpPost]
  6390. public IActionResult DelTravel(DelOpTravelDto dto)
  6391. {
  6392. var jw = JsonView(false);
  6393. if (dto.UserId <= 0 || dto.Diid <= 0)
  6394. {
  6395. jw.Msg = "请输入正确的参数!";
  6396. return Ok(jw);
  6397. }
  6398. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  6399. .SetColumns(x => new Grp_TravelList
  6400. {
  6401. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6402. DeleteUserId = dto.UserId,
  6403. IsDel = 1,
  6404. }).ExecuteCommand();
  6405. jw = JsonView(true);
  6406. return Ok(jw);
  6407. }
  6408. /// <summary>
  6409. /// 行程单保存
  6410. /// </summary>
  6411. /// <returns></returns>
  6412. [HttpPost]
  6413. public IActionResult TravelSave(TravelSaveDto dto)
  6414. {
  6415. var jw = JsonView(false);
  6416. if (dto.Arr.Count > 0)
  6417. {
  6418. try
  6419. {
  6420. _sqlSugar.BeginTran();
  6421. foreach (var item in dto.Arr)
  6422. {
  6423. if (item.Id == 0)
  6424. {
  6425. throw new Exception("请传入正确的Id");
  6426. }
  6427. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  6428. .SetColumns(x => new Grp_TravelList
  6429. {
  6430. Trip = item.Trip
  6431. }).ExecuteCommand();
  6432. }
  6433. _sqlSugar.CommitTran();
  6434. jw = JsonView(true);
  6435. }
  6436. catch (Exception ex)
  6437. {
  6438. _sqlSugar.RollbackTran();
  6439. jw.Msg = "程序异常!" + ex.Message;
  6440. }
  6441. }
  6442. else
  6443. {
  6444. jw.Msg = "请传入正确的参数!";
  6445. }
  6446. return Ok(jw);
  6447. }
  6448. /// <summary>
  6449. /// 导出行程单
  6450. /// </summary>
  6451. /// <param name="dto"></param>
  6452. /// <returns></returns>
  6453. [HttpPost]
  6454. public IActionResult ExportTravel(ExportTravelDto dto)
  6455. {
  6456. var jw = JsonView(false);
  6457. jw.Data = "";
  6458. int diid = 0;
  6459. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  6460. if (Find == null)
  6461. {
  6462. jw.Msg = "请选择正确的团组!";
  6463. return Ok(jw);
  6464. }
  6465. else
  6466. {
  6467. diid = Find.Id;
  6468. }
  6469. //数据源
  6470. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  6471. DataTable dtBlack = null;
  6472. try
  6473. {
  6474. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  6475. }
  6476. catch (Exception)
  6477. {
  6478. jw.Msg = "机票黑屏代码有误!";
  6479. return Ok(jw);
  6480. }
  6481. string CityStr = string.Empty;
  6482. if (dtBlack.Rows.Count == 0)
  6483. {
  6484. jw.Msg = "机票黑屏代码有误!";
  6485. return Ok(jw);
  6486. }
  6487. else
  6488. {
  6489. foreach (DataRow row in dtBlack.Rows)
  6490. {
  6491. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  6492. {
  6493. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  6494. return Ok(jw);
  6495. }
  6496. }
  6497. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  6498. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  6499. }
  6500. //创建数据源Table
  6501. DataTable dtSource = new DataTable();
  6502. dtSource.Columns.Add("Days", typeof(string));
  6503. dtSource.Columns.Add("Date", typeof(string));
  6504. dtSource.Columns.Add("Week", typeof(string));
  6505. dtSource.Columns.Add("Traffic", typeof(string));
  6506. dtSource.Columns.Add("Trip", typeof(string));
  6507. //获取数据,放到datatable
  6508. foreach (var item in _travelList)
  6509. {
  6510. DataRow dr = dtSource.NewRow();
  6511. dr["Days"] = item.Days;
  6512. dr["Date"] = item.Date;
  6513. dr["Week"] = item.WeekDay;
  6514. dr["Traffic"] = item.Traffic_First
  6515. + "\r\n"
  6516. + item.Traffic_Second;
  6517. dr["Trip"] = item.Trip;
  6518. dtSource.Rows.Add(dr);
  6519. }
  6520. Dictionary<string, string> dic = new Dictionary<string, string>();
  6521. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  6522. dic.Add("City", CityStr);
  6523. dic.Add("Days", Find.VisitDays.ToString());
  6524. dic.Add("DeleCode", Find.TourCode);
  6525. dic.Add("Pnum", Find.VisitPNumber.ToString());
  6526. //模板路径
  6527. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  6528. //载入模板
  6529. Document doc = null;
  6530. DocumentBuilder builder = null;
  6531. try
  6532. {
  6533. //载入模板
  6534. doc = new Document(tempPath);
  6535. builder = new DocumentBuilder(doc);
  6536. }
  6537. catch (Exception)
  6538. {
  6539. jw.Msg = "模板位置不存在!";
  6540. return Ok(jw);
  6541. }
  6542. foreach (var key in dic.Keys)
  6543. {
  6544. Bookmark bookmark = doc.Range.Bookmarks[key];
  6545. if (bookmark != null)
  6546. {
  6547. builder.MoveToBookmark(key);
  6548. builder.Write(dic[key]);
  6549. }
  6550. }
  6551. //获取word里所有表格
  6552. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6553. //获取所填表格的序数
  6554. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6555. try
  6556. {
  6557. //循环赋值
  6558. for (int i = 0; i < dtSource.Rows.Count; i++)
  6559. {
  6560. builder.MoveToCell(0, i + 1, 0, 0);
  6561. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6562. builder.MoveToCell(0, i + 1, 1, 0);
  6563. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6564. builder.MoveToCell(0, i + 1, 2, 0);
  6565. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6566. var trip = dtSource.Rows[i]["Trip"].ToString();
  6567. builder.MoveToCell(0, i + 1, 3, 0);
  6568. builder.Write(trip);
  6569. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6570. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6571. // 获取特定索引的段落
  6572. Paragraph paragraph = (Paragraph)paragraphs[0];
  6573. Run run = paragraph.Runs[0];
  6574. Aspose.Words.Font font = run.Font;
  6575. font.Name = "黑体";
  6576. //设置双休红色
  6577. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6578. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6579. paragraph = (Paragraph)paragraphs[1];
  6580. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6581. {
  6582. run = paragraph.Runs[0];
  6583. font = run.Font;
  6584. font.Color = Color.Red;
  6585. }
  6586. }
  6587. }
  6588. catch (Exception ex)
  6589. {
  6590. }
  6591. //删除多余行
  6592. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6593. {
  6594. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6595. }
  6596. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6597. if (!Directory.Exists(savePath))
  6598. {
  6599. try
  6600. {
  6601. Directory.CreateDirectory(savePath);
  6602. }
  6603. catch
  6604. {
  6605. }
  6606. }
  6607. string path = savePath + Find.TeamName + "出访日程";
  6608. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  6609. try
  6610. {
  6611. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  6612. string postfix = ".docx";
  6613. if (dto.IsPDF == 1)
  6614. {
  6615. saveFormat = Aspose.Words.SaveFormat.Pdf;
  6616. postfix = ".pdf";
  6617. }
  6618. doc.Save(path + postfix, saveFormat);
  6619. jw = JsonView(true, "导出成功", ftpPath + postfix);
  6620. }
  6621. catch (Exception)
  6622. {
  6623. jw = JsonView(false);
  6624. }
  6625. return Ok(jw);
  6626. }
  6627. /// <summary>
  6628. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6629. /// </summary>
  6630. /// <param name="num"></param>
  6631. /// <returns></returns>
  6632. string GetNum(string num)
  6633. {
  6634. string str = "";
  6635. switch (num)
  6636. {
  6637. case "1":
  6638. str = "一";
  6639. break;
  6640. case "2":
  6641. str = "二";
  6642. break;
  6643. case "3":
  6644. str = "三";
  6645. break;
  6646. case "4":
  6647. str = "四";
  6648. break;
  6649. case "5":
  6650. str = "五";
  6651. break;
  6652. case "6":
  6653. str = "六";
  6654. break;
  6655. case "7":
  6656. str = "七";
  6657. break;
  6658. case "8":
  6659. str = "八";
  6660. break;
  6661. case "9":
  6662. str = "九";
  6663. break;
  6664. case "10":
  6665. str = "十";
  6666. break;
  6667. case "11":
  6668. str = "十一";
  6669. break;
  6670. case "12":
  6671. str = "十二";
  6672. break;
  6673. case "一":
  6674. str = "1";
  6675. break;
  6676. case "二":
  6677. str = "2";
  6678. break;
  6679. case "三":
  6680. str = "3";
  6681. break;
  6682. case "四":
  6683. str = "4";
  6684. break;
  6685. case "五":
  6686. str = "5";
  6687. break;
  6688. case "六":
  6689. str = "6";
  6690. break;
  6691. case "七":
  6692. str = "7";
  6693. break;
  6694. case "八":
  6695. str = "8";
  6696. break;
  6697. case "九":
  6698. str = "9";
  6699. break;
  6700. case "十":
  6701. str = "10";
  6702. break;
  6703. case "十一":
  6704. str = "11";
  6705. break;
  6706. case "十二":
  6707. str = "12";
  6708. break;
  6709. }
  6710. return str;
  6711. }
  6712. #endregion
  6713. #endregion
  6714. #region 团组成本
  6715. /// <summary>
  6716. /// 团组成本数据初始化
  6717. /// </summary>
  6718. /// <param name="dto"></param>
  6719. /// <returns></returns>
  6720. [HttpPost]
  6721. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6722. {
  6723. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6724. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6725. WHEN COUNT(*) >= 0 THEN 'True'
  6726. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6727. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6728. ").ToList(); //团组列表
  6729. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6730. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6731. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6732. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6733. if (groupinfoValue != null)
  6734. {
  6735. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6736. var spArr = new string[1] { countryArr };
  6737. if (countryArr.Contains("|"))
  6738. {
  6739. spArr = countryArr.Split("|");
  6740. }
  6741. else if (countryArr.Contains("、"))
  6742. {
  6743. spArr = countryArr.Split("、");
  6744. }
  6745. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6746. {
  6747. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6748. if (dbQueryCountry != null)
  6749. {
  6750. visaCountryInfoArr.Add(dbQueryCountry);
  6751. }
  6752. }
  6753. }
  6754. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6755. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6756. var create = _GroupCostRepository.
  6757. CreateGroupCostByBlackCode(dto.Diid);
  6758. if (groupCost.Count == 0 && create.Code == 0)
  6759. {
  6760. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6761. }
  6762. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6763. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6764. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6765. groupCostMap = groupCostMap.Select(x =>
  6766. {
  6767. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6768. {
  6769. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6770. }
  6771. return x;
  6772. }).ToList();
  6773. //GroupCostParameter.Add(new
  6774. // Grp_GroupCostParameter());
  6775. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6776. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  6777. return Ok(JsonView(new
  6778. {
  6779. groupList,
  6780. groupInfo,
  6781. groupChecks,
  6782. groupCost = groupCostMap,
  6783. hotelNumber,
  6784. GroupCostParameter = GroupCostParameterMap,
  6785. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  6786. {
  6787. x.VisaCountry,
  6788. x.VisaPrice,
  6789. x.Id,
  6790. }).ToList(),
  6791. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  6792. blackCodeIsTrue = create.Code == 0 ? true : false,
  6793. hotelIsTrue = hotelIsTrue,
  6794. }));
  6795. }
  6796. /// <summary>
  6797. /// 团组成本信息保存
  6798. /// </summary>
  6799. /// <param name="dto"></param>
  6800. /// <returns></returns>
  6801. [HttpPost]
  6802. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  6803. {
  6804. if (dto.Diid <= 0 || dto.Userid <= 0)
  6805. {
  6806. return Ok(JsonView(false));
  6807. }
  6808. JsonView jw = null;
  6809. bool isTrue = false;
  6810. #region 复制团组成本
  6811. //if (dto.Diid == 2581)
  6812. //{
  6813. // dto.Diid = 2599;
  6814. // dto.CheckBoxs.ForEach(x =>
  6815. // {
  6816. // x.Diid = 2599;
  6817. // });
  6818. // dto.GroupCosts.ForEach(x =>
  6819. // {
  6820. // x.Diid = 2599;
  6821. // });
  6822. // dto.CostTypeHotelNumbers.ForEach(x =>
  6823. // {
  6824. // x.Diid = 2599;
  6825. // });
  6826. // dto.GroupCostParameters.ForEach(x =>
  6827. // {
  6828. // x.DiId = 2599;
  6829. // });
  6830. //}
  6831. #endregion
  6832. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  6833. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  6834. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  6835. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  6836. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  6837. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  6838. try
  6839. {
  6840. _sqlSugar.BeginTran();
  6841. isTrue = await _GroupCostRepository.
  6842. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  6843. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  6844. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  6845. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  6846. _sqlSugar.CommitTran();
  6847. jw = JsonView(true, "保存成功!", isTrue);
  6848. }
  6849. catch (Exception)
  6850. {
  6851. _sqlSugar.RollbackTran();
  6852. jw = JsonView(false);
  6853. }
  6854. return Ok(jw);
  6855. }
  6856. /// <summary>
  6857. /// 司兼导数据
  6858. /// </summary>
  6859. /// <param name="dto"></param>
  6860. /// <returns></returns>
  6861. [HttpPost]
  6862. public IActionResult GetCarGuides(CarGuidesDto dto)
  6863. {
  6864. JsonView jw = null;
  6865. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  6866. jw = JsonView(true, "获取成功!", Data);
  6867. return Ok(jw);
  6868. }
  6869. /// <summary>
  6870. /// 导游数据
  6871. /// </summary>
  6872. /// <param name="dto"></param>
  6873. /// <returns></returns>
  6874. [HttpPost]
  6875. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  6876. {
  6877. JsonView jw = null;
  6878. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  6879. // 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
  6880. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  6881. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  6882. jw = JsonView(true, "获取成功!", Data);
  6883. return Ok(jw);
  6884. }
  6885. /// <summary>
  6886. /// 成本车数据
  6887. /// </summary>
  6888. /// <param name="dto"></param>
  6889. /// <returns></returns>
  6890. [HttpPost]
  6891. public IActionResult GetCarInfo(CarGuidesDto dto)
  6892. {
  6893. JsonView jw = null;
  6894. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  6895. jw = JsonView(true, "获取成功!", Data);
  6896. return Ok(jw);
  6897. }
  6898. /// <summary>
  6899. /// 景点数据
  6900. /// </summary>
  6901. /// <param name="dto"></param>
  6902. /// <returns></returns>
  6903. [HttpPost]
  6904. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  6905. {
  6906. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  6907. return Ok(JsonView(true, "获取成功!", Data));
  6908. }
  6909. /// <summary>
  6910. /// 成本通知
  6911. /// </summary>
  6912. /// <param name="dto"></param>
  6913. /// <returns></returns>
  6914. [HttpPost]
  6915. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  6916. {
  6917. if (dto.Diid < 0)
  6918. {
  6919. return Ok(JsonView(false));
  6920. }
  6921. JsonView jw = null;
  6922. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  6923. if (GroupCostParameter != null)
  6924. {
  6925. int IsShare = 0;
  6926. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  6927. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  6928. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  6929. string msg = string.Empty;
  6930. if (isTrue)
  6931. {
  6932. if (IsShare == 0)
  6933. {
  6934. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  6935. }
  6936. else
  6937. {
  6938. #region 企微通知对应岗位用户
  6939. try
  6940. {
  6941. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  6942. }
  6943. catch (Exception ex)
  6944. {
  6945. }
  6946. #endregion
  6947. msg = "通知成功,其他模块操作人员可见此成本信息!";
  6948. }
  6949. jw = JsonView(isTrue, msg, new { IsShare });
  6950. }
  6951. else
  6952. {
  6953. msg = "修改失败!";
  6954. jw = JsonView(isTrue, msg);
  6955. }
  6956. }
  6957. else
  6958. {
  6959. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  6960. }
  6961. return Ok(jw);
  6962. }
  6963. /// <summary>
  6964. /// 导出报价单
  6965. /// </summary>
  6966. /// <param name="dto"></param>
  6967. /// <returns></returns>
  6968. [HttpPost]
  6969. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  6970. {
  6971. if (dto.Diid == 0)
  6972. {
  6973. return Ok(JsonView(false, "请传递团组id"));
  6974. }
  6975. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6976. if (deleInfo.Code != 0)
  6977. {
  6978. return Ok(JsonView(false, "团组信息查询失败!"));
  6979. }
  6980. var di = deleInfo.Data as DelegationInfoWebView;
  6981. if (di != null)
  6982. {
  6983. di.TeamName = di.TeamName.Replace("|","、");
  6984. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  6985. //文件名
  6986. string strFileName = di.TeamName + "-收款账单.doc";
  6987. //获取模板
  6988. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  6989. //载入模板
  6990. Document doc = new Document(tmppath);
  6991. decimal TotalPrice = 0.00M;
  6992. string itemStr = string.Empty;
  6993. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  6994. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6995. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6996. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  6997. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  6998. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  6999. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7000. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7001. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7002. foreach (var cost in groupCostType)
  7003. {
  7004. var List = cost.ToList();
  7005. if (cost.Key == "A")
  7006. {
  7007. foreach (var ListItem in List)
  7008. {
  7009. if (ListItem.number > 0)
  7010. {
  7011. if (ListItem.code.Contains("TBR"))
  7012. {
  7013. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7014. }
  7015. else
  7016. {
  7017. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7018. }
  7019. TotalPrice += (ListItem.number * ListItem.price);
  7020. }
  7021. }
  7022. }
  7023. else
  7024. {
  7025. itemStr = itemStr.Insert(0, "A段\r\n");
  7026. itemStr += "B段\r\n";
  7027. foreach (var ListItem in List)
  7028. {
  7029. if (ListItem.number > 0)
  7030. {
  7031. if (ListItem.code.Contains("TBR"))
  7032. {
  7033. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7034. }
  7035. else
  7036. {
  7037. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7038. }
  7039. TotalPrice += (ListItem.number * ListItem.price);
  7040. }
  7041. }
  7042. }
  7043. }
  7044. #region 替换Word模板书签内容
  7045. Dictionary<string, string> marks = new Dictionary<string, string>();
  7046. marks.Add("To", di.ClientUnit);//付款方
  7047. marks.Add("ToTel", di.TellPhone);//付款方电话
  7048. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7049. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7050. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7051. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7052. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7053. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  7054. marks.Add("PayItemContent", itemStr);//详细信息
  7055. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7056. #endregion
  7057. ////注
  7058. //if (doc.Range.Bookmarks["Attention"] != null)
  7059. //{
  7060. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7061. // mark.Text = frList[0].Attention;
  7062. //}
  7063. foreach (var item in marks.Keys)
  7064. {
  7065. if (doc.Range.Bookmarks[item] != null)
  7066. {
  7067. Bookmark mark = doc.Range.Bookmarks[item];
  7068. mark.Text = marks[item];
  7069. }
  7070. }
  7071. byte[] bytes = null;
  7072. using (MemoryStream stream = new MemoryStream())
  7073. {
  7074. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7075. bytes = stream.ToArray();
  7076. }
  7077. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7078. return Ok(JsonView(true, "", new
  7079. {
  7080. Data = bytes,
  7081. strFileName,
  7082. }));
  7083. }
  7084. else
  7085. {
  7086. return Ok(JsonView(false, "团组信息不存在!"));
  7087. }
  7088. }
  7089. /// <summary>
  7090. /// 导出团组成本
  7091. /// </summary>
  7092. /// <param name="dto"></param>
  7093. /// <returns></returns>
  7094. [HttpPost]
  7095. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7096. {
  7097. var jw = JsonView(false);
  7098. if (dto.Diid == 0)
  7099. {
  7100. return Ok(JsonView(false, "请传递团组id"));
  7101. }
  7102. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7103. if (deleInfo.Code != 0)
  7104. {
  7105. return Ok(JsonView(false, "团组信息查询失败!"));
  7106. }
  7107. var di = deleInfo.Data as DelegationInfoWebView;
  7108. if (di == null)
  7109. {
  7110. return Ok(JsonView(false, "团组信息查询失败!"));
  7111. }
  7112. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7113. WorkbookDesigner designer = new WorkbookDesigner();
  7114. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7115. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7116. for (int i = 0; i < List_GC.Count; i++)
  7117. {
  7118. GroupCost_Excel gc = new GroupCost_Excel();
  7119. gc.Id = List_GC[i].Id;
  7120. gc.Diid = List_GC[i].Diid.ToString();
  7121. gc.DAY = List_GC[i].DAY;
  7122. string week = "";
  7123. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7124. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7125. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7126. gc.ITIN = List_GC[i].ITIN;
  7127. gc.CarType = List_GC[i].CarType;
  7128. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7129. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7130. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7131. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7132. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7133. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7134. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7135. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7136. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7137. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7138. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7139. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7140. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7141. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7142. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7143. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7144. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7145. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7146. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7147. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7148. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7149. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7150. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7151. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7152. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7153. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7154. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7155. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7156. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7157. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7158. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7159. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7160. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7161. List_GC1.Add(gc);
  7162. }
  7163. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7164. dt.TableName = "TB";
  7165. //报表标题等不用dt的值
  7166. designer.SetDataSource("TeamName", dto.title.TeamName);
  7167. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7168. designer.SetDataSource("Tax", dto.title.Tax);
  7169. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7170. designer.SetDataSource("Currency", dto.title.Currency);
  7171. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7172. designer.SetDataSource("Rate", dto.title.Rate);
  7173. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7174. var Aparams = hotels.Find(x => x.Type == "Default");
  7175. if (Aparams == null)
  7176. {
  7177. return Ok(jw);
  7178. }
  7179. //酒店数量
  7180. var txtSGRNumber = Aparams.SGR.ToString();
  7181. var txtTBRNumber = Aparams.TBR.ToString();
  7182. var txtJSESNumber = Aparams.JSES.ToString();
  7183. var txtSUITENumbe = Aparams.SUITE.ToString();
  7184. if (dto.costType == "B")
  7185. {
  7186. Aparams = hotels.Find(x => x.Type == "A");
  7187. var Bparams = hotels.Find(x => x.Type == "B");
  7188. if (Aparams == null || Bparams == null)
  7189. {
  7190. return Ok(jw);
  7191. }
  7192. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7193. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7194. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7195. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7196. }
  7197. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7198. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7199. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7200. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7201. var ws = designer.Workbook.Worksheets[0];
  7202. int Row = List_GC.Count;
  7203. int startIndex = 11;
  7204. int HideRows = 0;
  7205. List<int> hideRowsList = new List<int>();
  7206. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7207. #region A段left数据
  7208. var left = dto.leftInfo.Find(x => x.Type == "A");
  7209. if (left == null)
  7210. {
  7211. return Ok(jw);
  7212. }
  7213. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7214. if (leftBindData != null)
  7215. {
  7216. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7217. designer.SetDataSource("VisaRS", leftBindData.rs);
  7218. designer.SetDataSource("VisaXS", leftBindData.xs);
  7219. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7220. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7221. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7222. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7223. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7224. }
  7225. else
  7226. {
  7227. hideRowsList.Add(Row + startIndex + HideRows);
  7228. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7229. }
  7230. HideRows += 2;
  7231. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7232. if (leftBindData != null)
  7233. {
  7234. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7235. designer.SetDataSource("BXRS", leftBindData.rs);
  7236. designer.SetDataSource("BXXS", leftBindData.xs);
  7237. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7238. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7239. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7240. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7241. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7242. }
  7243. else
  7244. {
  7245. hideRowsList.Add(Row + startIndex + HideRows);
  7246. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7247. }
  7248. HideRows += 2;
  7249. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7250. if (leftBindData != null)
  7251. {
  7252. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7253. designer.SetDataSource("HSRS", leftBindData.rs);
  7254. designer.SetDataSource("HSXS", leftBindData.xs);
  7255. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7256. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7257. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7258. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7259. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7260. }
  7261. else
  7262. {
  7263. hideRowsList.Add(Row + startIndex + HideRows);
  7264. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7265. }
  7266. HideRows += 2;
  7267. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7268. if (leftBindData != null)
  7269. {
  7270. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7271. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7272. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7273. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7274. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7275. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7276. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7277. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7278. }
  7279. else
  7280. {
  7281. hideRowsList.Add(Row + startIndex + HideRows);
  7282. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7283. }
  7284. HideRows += 2;
  7285. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7286. if (leftBindData != null)
  7287. {
  7288. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7289. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7290. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7291. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7292. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7293. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7294. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7295. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7296. }
  7297. else
  7298. {
  7299. hideRowsList.Add(Row + startIndex + HideRows);
  7300. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7301. }
  7302. HideRows += 2;
  7303. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  7304. if (leftBindData != null)
  7305. {
  7306. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  7307. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  7308. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  7309. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7310. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7311. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7312. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7313. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7314. }
  7315. else
  7316. {
  7317. hideRowsList.Add(Row + startIndex + HideRows);
  7318. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7319. }
  7320. HideRows += 2;
  7321. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7322. if (leftBindData != null)
  7323. {
  7324. ////TBR
  7325. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  7326. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  7327. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  7328. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7329. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7330. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7331. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7332. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7333. }
  7334. else
  7335. {
  7336. hideRowsList.Add(Row + startIndex + HideRows);
  7337. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7338. }
  7339. HideRows += 2;
  7340. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7341. if (leftBindData != null)
  7342. {
  7343. ////SGR
  7344. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  7345. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  7346. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  7347. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7348. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7349. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7350. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7351. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7352. }
  7353. else
  7354. {
  7355. hideRowsList.Add(Row + startIndex + HideRows);
  7356. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7357. }
  7358. HideRows += 2;
  7359. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7360. if (leftBindData != null)
  7361. {
  7362. ////JS/ES
  7363. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  7364. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  7365. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  7366. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7367. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7368. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7369. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7370. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7371. }
  7372. else
  7373. {
  7374. hideRowsList.Add(Row + startIndex + HideRows);
  7375. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7376. }
  7377. HideRows += 2;
  7378. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7379. if (leftBindData != null)
  7380. {
  7381. ////SUITE
  7382. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  7383. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  7384. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  7385. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7386. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7387. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7388. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7389. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7390. }
  7391. else
  7392. {
  7393. hideRowsList.Add(Row + startIndex + HideRows);
  7394. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7395. }
  7396. HideRows += 2;
  7397. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7398. if (leftBindData != null)
  7399. {
  7400. designer.SetDataSource("DJDRCB", leftBindData.cb);
  7401. designer.SetDataSource("DJRS", leftBindData.rs);
  7402. designer.SetDataSource("DJXS", leftBindData.xs);
  7403. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7404. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7405. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7406. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7407. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7408. }
  7409. else
  7410. {
  7411. hideRowsList.Add(Row + startIndex + HideRows);
  7412. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7413. }
  7414. HideRows += 2;
  7415. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7416. if (leftBindData != null)
  7417. {
  7418. designer.SetDataSource("HCPCB", leftBindData.cb);
  7419. designer.SetDataSource("HCPRS", leftBindData.rs);
  7420. designer.SetDataSource("HCPXS", leftBindData.xs);
  7421. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7422. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7423. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7424. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7425. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7426. }
  7427. else
  7428. {
  7429. hideRowsList.Add(Row + startIndex + HideRows);
  7430. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7431. }
  7432. HideRows += 2;
  7433. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7434. if (leftBindData != null)
  7435. {
  7436. designer.SetDataSource("CPCB", leftBindData.cb);
  7437. designer.SetDataSource("CPRS", leftBindData.rs);
  7438. designer.SetDataSource("CPXS", leftBindData.xs);
  7439. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7440. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7441. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7442. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7443. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7444. }
  7445. else
  7446. {
  7447. hideRowsList.Add(Row + startIndex + HideRows);
  7448. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7449. }
  7450. HideRows += 2;
  7451. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7452. if (leftBindData != null)
  7453. {
  7454. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7455. designer.SetDataSource("GWRS", leftBindData.rs);
  7456. designer.SetDataSource("GWXS", leftBindData.xs);
  7457. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7458. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7459. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7460. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7461. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7462. }
  7463. else
  7464. {
  7465. hideRowsList.Add(Row + startIndex + HideRows);
  7466. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7467. }
  7468. HideRows += 2;
  7469. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7470. if (leftBindData != null)
  7471. {
  7472. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7473. designer.SetDataSource("LYJRS", leftBindData.rs);
  7474. designer.SetDataSource("LYJXS", leftBindData.xs);
  7475. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7476. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7477. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7478. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7479. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7480. }
  7481. else
  7482. {
  7483. hideRowsList.Add(Row + startIndex + HideRows);
  7484. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7485. }
  7486. #endregion
  7487. #region A段Right信息
  7488. var right = dto.rightInfo.Find(x => x.Type == "A");
  7489. if (right == null)
  7490. {
  7491. return Ok(jw);
  7492. }
  7493. HideRows += 4;
  7494. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7495. if (rightBindData != null)
  7496. {
  7497. //经济舱 + 双人间 TBR
  7498. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7499. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7500. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7501. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7502. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7503. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7504. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7505. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7506. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7507. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7508. }
  7509. else
  7510. {
  7511. hideRowsList.Add(Row + startIndex + HideRows);
  7512. }
  7513. HideRows += 2;
  7514. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7515. if (rightBindData != null)
  7516. {
  7517. //经济舱 + 单人间 SGR
  7518. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7519. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7520. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7521. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7522. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7523. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7524. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7525. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7526. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7527. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7528. }
  7529. else
  7530. {
  7531. hideRowsList.Add(Row + startIndex + HideRows);
  7532. }
  7533. HideRows += 2;
  7534. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7535. if (rightBindData != null)
  7536. {
  7537. //公务舱 + 单人间 SGR
  7538. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7539. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7540. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7541. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7542. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7543. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7544. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7545. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7546. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7547. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7548. }
  7549. else
  7550. {
  7551. hideRowsList.Add(Row + startIndex + HideRows);
  7552. }
  7553. HideRows += 2;
  7554. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7555. if (rightBindData != null)
  7556. {
  7557. //公务舱 + 小套房 JSES
  7558. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7559. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7560. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7561. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7562. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7563. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7564. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7565. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7566. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7567. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7568. }
  7569. else
  7570. {
  7571. hideRowsList.Add(Row + startIndex + HideRows);
  7572. }
  7573. HideRows += 2;
  7574. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7575. if (rightBindData != null)
  7576. {
  7577. //公务舱 + 小套房 JSES
  7578. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7579. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7580. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7581. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7582. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7583. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7584. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7585. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7586. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7587. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7588. }
  7589. else
  7590. {
  7591. hideRowsList.Add(Row + startIndex + HideRows);
  7592. }
  7593. HideRows += 2;
  7594. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7595. if (rightBindData != null)
  7596. {
  7597. //经济舱 + 大套房
  7598. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7599. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7600. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7601. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7602. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7603. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7604. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7605. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7606. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7607. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7608. }
  7609. else
  7610. {
  7611. hideRowsList.Add(Row + startIndex + HideRows);
  7612. }
  7613. HideRows += 2;
  7614. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  7615. if (rightBindData != null)
  7616. {
  7617. //头等舱 + 小套房 JSES
  7618. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  7619. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  7620. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7621. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  7622. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7623. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7624. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7625. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7626. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7627. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7628. }
  7629. else
  7630. {
  7631. hideRowsList.Add(Row + startIndex + HideRows);
  7632. }
  7633. HideRows += 2;
  7634. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  7635. if (rightBindData != null)
  7636. {
  7637. //头等舱 + 大套房
  7638. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  7639. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  7640. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7641. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  7642. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7643. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7644. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7645. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7646. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7647. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7648. }
  7649. else
  7650. {
  7651. hideRowsList.Add(Row + startIndex + HideRows);
  7652. }
  7653. #endregion
  7654. #region B段标题清空
  7655. designer.SetDataSource("CostBDRCB", "");
  7656. designer.SetDataSource("CostBRS", "");
  7657. designer.SetDataSource("CostBXS", "");
  7658. designer.SetDataSource("CostBZCB", "");
  7659. designer.SetDataSource("CostBDRBJ", "");
  7660. designer.SetDataSource("CostBZBJ", "");
  7661. designer.SetDataSource("CostBDRLR", "");
  7662. designer.SetDataSource("CostBZLR", "");
  7663. designer.SetDataSource("CostBDRCBOM", "");
  7664. designer.SetDataSource("CostBRSOM", "");
  7665. designer.SetDataSource("CostBZCBOM", "");
  7666. designer.SetDataSource("CostBDRBJOM", "");
  7667. designer.SetDataSource("CostBZBJOM", "");
  7668. designer.SetDataSource("CostBDRLROM", "");
  7669. designer.SetDataSource("CostBZLROM", "");
  7670. #endregion
  7671. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7672. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7673. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7674. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7675. designer.SetDataSource("DJName", "地接(CNY)");
  7676. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7677. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7678. designer.SetDataSource("GWName", "公务(CNY)");
  7679. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7680. designer.SetDataSource("LYJName", "零用金(CNY)");
  7681. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7682. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7683. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7684. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  7685. designer.SetDataSource("BXName", "保险(CNY)");
  7686. designer.SetDataSource("VisaName", "签证(CNY)");
  7687. #region B段基本数据
  7688. if (dto.costType == "B")
  7689. {
  7690. left = dto.leftInfo.Find(x => x.Type == "B");
  7691. if (left == null)
  7692. {
  7693. return Ok(jw);
  7694. }
  7695. #region B段left数据
  7696. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7697. if (leftBindData != null)
  7698. {
  7699. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7700. designer.SetDataSource("BHSRS", leftBindData.rs);
  7701. designer.SetDataSource("BHSXS", leftBindData.xs);
  7702. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7703. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7704. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7705. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7706. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7707. }
  7708. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7709. if (leftBindData != null)
  7710. {
  7711. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7712. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7713. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7714. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7715. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7716. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7717. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7718. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7719. }
  7720. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7721. if (leftBindData != null)
  7722. {
  7723. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7724. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7725. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7726. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7727. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7728. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7729. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7730. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7731. }
  7732. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  7733. if (leftBindData != null)
  7734. {
  7735. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  7736. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  7737. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  7738. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7739. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7740. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7741. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7742. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7743. }
  7744. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7745. if (leftBindData != null)
  7746. {
  7747. designer.SetDataSource("BHCPCB", leftBindData.cb);
  7748. designer.SetDataSource("BHCPRS", leftBindData.rs);
  7749. designer.SetDataSource("BHCPXS", leftBindData.xs);
  7750. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7751. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7752. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7753. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7754. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7755. }
  7756. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7757. if (leftBindData != null)
  7758. {
  7759. designer.SetDataSource("BCPCB", leftBindData.cb);
  7760. designer.SetDataSource("BCPRS", leftBindData.rs);
  7761. designer.SetDataSource("BCPXS", leftBindData.xs);
  7762. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7763. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7764. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7765. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7766. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7767. }
  7768. //TBR
  7769. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7770. if (leftBindData != null)
  7771. {
  7772. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7773. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7774. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7775. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7776. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7777. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7778. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7779. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7780. }
  7781. //SGR
  7782. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7783. if (leftBindData != null)
  7784. {
  7785. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  7786. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  7787. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  7788. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7789. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7790. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7791. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7792. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7793. }
  7794. //JS/ES
  7795. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7796. if (leftBindData != null)
  7797. {
  7798. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  7799. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  7800. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  7801. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7802. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7803. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7804. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7805. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7806. }
  7807. //SUITE
  7808. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7809. if (leftBindData != null)
  7810. {
  7811. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  7812. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  7813. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  7814. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7815. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7816. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7817. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7818. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7819. }
  7820. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7821. if (leftBindData != null)
  7822. {
  7823. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  7824. designer.SetDataSource("BDJRS", leftBindData.rs);
  7825. designer.SetDataSource("BDJXS", leftBindData.xs);
  7826. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7827. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7828. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7829. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7830. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7831. }
  7832. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7833. if (leftBindData != null)
  7834. {
  7835. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  7836. designer.SetDataSource("BGWRS", leftBindData.rs);
  7837. designer.SetDataSource("BGWXS", leftBindData.xs);
  7838. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7839. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7840. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7841. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7842. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7843. }
  7844. #region 优化方案
  7845. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  7846. //excelBind.Add("零用金", new {
  7847. //cb="",
  7848. //rs="",
  7849. //xs ="",
  7850. //zcb = "",
  7851. //});
  7852. #endregion
  7853. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7854. if (leftBindData != null)
  7855. {
  7856. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  7857. designer.SetDataSource("BLYJRS", leftBindData.rs);
  7858. designer.SetDataSource("BLYJXS", leftBindData.xs);
  7859. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7860. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7861. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7862. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7863. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7864. }
  7865. #endregion
  7866. #region B段Right信息
  7867. right = dto.rightInfo.Find(x => x.Type == "B");
  7868. if (right == null)
  7869. {
  7870. return Ok(jw);
  7871. }
  7872. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7873. if (rightBindData != null)
  7874. {
  7875. //经济舱 + 双人间 TBR
  7876. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  7877. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  7878. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7879. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  7880. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7881. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7882. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7883. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7884. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7885. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7886. }
  7887. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7888. if (rightBindData != null)
  7889. {
  7890. //经济舱 + 单人间 SGR
  7891. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  7892. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  7893. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7894. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  7895. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7896. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7897. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7898. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7899. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7900. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7901. }
  7902. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7903. if (rightBindData != null)
  7904. {
  7905. //公务舱 + 单人间 SGR
  7906. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  7907. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  7908. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7909. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  7910. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7911. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7912. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7913. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7914. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7915. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7916. }
  7917. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7918. if (rightBindData != null)
  7919. {
  7920. //公务舱 + 小套房 JSES
  7921. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  7922. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  7923. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7924. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  7925. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7926. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7927. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7928. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7929. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7930. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7931. }
  7932. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7933. if (rightBindData != null)
  7934. {
  7935. //公务舱 + 小套房 JSES
  7936. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  7937. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  7938. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7939. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  7940. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7941. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7942. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7943. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7944. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7945. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7946. }
  7947. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7948. if (rightBindData != null)
  7949. {
  7950. //经济舱 + 大套房
  7951. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  7952. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  7953. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7954. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  7955. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7956. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7957. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7958. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7959. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7960. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7961. }
  7962. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  7963. if (rightBindData != null)
  7964. {
  7965. //头等舱 + 小套房 JSES
  7966. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  7967. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  7968. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7969. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  7970. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7971. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7972. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7973. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7974. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7975. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7976. }
  7977. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  7978. if (rightBindData != null)
  7979. {
  7980. //头等舱 + 大套房
  7981. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  7982. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  7983. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7984. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  7985. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7986. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7987. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7988. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7989. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7990. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7991. }
  7992. #endregion
  7993. #region 标题
  7994. designer.SetDataSource("CostBDRCB", "单人成本");
  7995. designer.SetDataSource("CostBRS", "人数");
  7996. designer.SetDataSource("CostBXS", "系数");
  7997. designer.SetDataSource("CostBZCB", "总成本");
  7998. designer.SetDataSource("CostBDRBJ", "单人报价");
  7999. designer.SetDataSource("CostBZBJ", "总报价");
  8000. designer.SetDataSource("CostBDRLR", "单人利润");
  8001. designer.SetDataSource("CostBZLR", "总利润");
  8002. designer.SetDataSource("CostBDRCBOM", "单人成本");
  8003. designer.SetDataSource("CostBRSOM", "人数");
  8004. designer.SetDataSource("CostBZCBOM", "总成本");
  8005. designer.SetDataSource("CostBDRBJOM", "单人报价");
  8006. designer.SetDataSource("CostBZBJOM", "总报价");
  8007. designer.SetDataSource("CostBDRLROM", "单人利润");
  8008. designer.SetDataSource("CostBZLROM", "总利润");
  8009. #endregion
  8010. }
  8011. #endregion
  8012. designer.SetDataSource("TzZCB2", TzZCB2);
  8013. designer.SetDataSource("TzZBJ2", TzZBJ2);
  8014. designer.SetDataSource("TzZLR2", TzZLR2);
  8015. string[] dataSourceKeys = new string[]
  8016. {
  8017. "VF",
  8018. "TGS",
  8019. "TGOF",
  8020. "TGM",
  8021. "TGA",
  8022. "TGTF",
  8023. "TGEF",
  8024. "CFM",
  8025. "CFOF",
  8026. "B",
  8027. "L",
  8028. "D",
  8029. "TBR",
  8030. "SGR",
  8031. "JSES",
  8032. "Suite",
  8033. "TV",
  8034. "1L",
  8035. "IF",
  8036. "EF",
  8037. "BRF",
  8038. "TE",
  8039. "TGT",
  8040. "DRVT",
  8041. "PC",
  8042. "TLF",
  8043. "ECT"
  8044. };
  8045. foreach (var item in dataSourceKeys)
  8046. {
  8047. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  8048. if (find != null)
  8049. {
  8050. designer.SetDataSource(item, find.text);
  8051. }
  8052. else
  8053. {
  8054. designer.SetDataSource(item, 0);
  8055. }
  8056. }
  8057. designer.SetDataSource(dt);
  8058. //根据数据源处理生成报表内容
  8059. designer.Process();
  8060. designer.Workbook.Worksheets[0].Name = "清单";
  8061. Worksheet sheet = designer.Workbook.Worksheets[0];
  8062. foreach (var Rowindex in hideRowsList)
  8063. {
  8064. ws.Cells.HideRows(Rowindex, 2);
  8065. }
  8066. byte[] bytes = null;
  8067. string strFileName = di.TeamName + "-团组-成本.xls";
  8068. using (MemoryStream stream = new MemoryStream())
  8069. {
  8070. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  8071. bytes = stream.ToArray();
  8072. }
  8073. return Ok(JsonView(true, "", new
  8074. {
  8075. Data = bytes,
  8076. strFileName,
  8077. }));
  8078. }
  8079. /// <summary>
  8080. /// 导出客户报表
  8081. /// </summary>
  8082. /// <returns></returns>
  8083. [HttpPost]
  8084. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  8085. {
  8086. var jw = JsonView(false);
  8087. if (dto.Diid == 0)
  8088. {
  8089. return Ok(JsonView(false, "请传递团组id"));
  8090. }
  8091. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8092. if (deleInfo.Code != 0)
  8093. {
  8094. return Ok(JsonView(false, "团组信息查询失败!"));
  8095. }
  8096. var di = deleInfo.Data as DelegationInfoWebView;
  8097. if (di == null)
  8098. {
  8099. return Ok(JsonView(false, "团组信息查询失败!"));
  8100. }
  8101. //文件名
  8102. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8103. //获取模板
  8104. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8105. //载入模板
  8106. Document doc = new Document(tmppath);
  8107. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8108. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8109. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8110. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8111. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8112. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8113. if (AParameter == null)
  8114. {
  8115. return Ok(JsonView(false, "系数不存在!"));
  8116. }
  8117. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8118. , TzAirDesc, TzZCost;
  8119. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8120. = TzAirDesc = TzZCost = string.Empty;
  8121. TzNumber = AParameter.CostTypenumber.ToString();
  8122. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8123. CarGuides1 = dto.CarGuides1;
  8124. Meal = dto.Meal;
  8125. SubsidizedMeals = dto.SubsidizedMeals;
  8126. NightRepair = dto.NightRepair;
  8127. AttractionsTickets = dto.AttractionsTickets;
  8128. MiscellaneousFees = dto.MiscellaneousFees;
  8129. ATip = dto.ATip;
  8130. TzHotelDesc = "";
  8131. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8132. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8133. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8134. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8135. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8136. TzAirDesc = "";
  8137. TzZCost = dto.TzZCost;
  8138. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8139. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8140. var index = 1;
  8141. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8142. foreach (var item in TzHotelDescArr)
  8143. {
  8144. if (AinfoArr != null)
  8145. {
  8146. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8147. if (Ainfo != null)
  8148. {
  8149. if (int.Parse(Ainfo.rs) <= 0)
  8150. {
  8151. continue;
  8152. }
  8153. var hotelText = string.Empty;
  8154. switch (item)
  8155. {
  8156. case "SGR":
  8157. hotelText = "单人间";
  8158. break;
  8159. case "JSES":
  8160. hotelText = "小套房";
  8161. break;
  8162. case "SUITE":
  8163. hotelText = "套房";
  8164. break;
  8165. case "TBR":
  8166. hotelText = "双人间";
  8167. break;
  8168. }
  8169. if (item != "TBR")
  8170. {
  8171. 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";
  8172. }
  8173. else
  8174. {
  8175. 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";
  8176. }
  8177. index++;
  8178. }
  8179. }
  8180. }
  8181. index = 1;
  8182. foreach (var item in TzAirDescArr)
  8183. {
  8184. if (AinfoArr != null)
  8185. {
  8186. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8187. if (Ainfo != null)
  8188. {
  8189. if (int.Parse(Ainfo.rs) <= 0)
  8190. {
  8191. continue;
  8192. }
  8193. 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";
  8194. index++;
  8195. }
  8196. }
  8197. }
  8198. if (dto.costType == "B")
  8199. {
  8200. if (BParameter == null)
  8201. {
  8202. return Ok(JsonView(false, "B段系数不存在!"));
  8203. }
  8204. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8205. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8206. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8207. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8208. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8209. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8210. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8211. foreach (var item in TzHotelDescArr)
  8212. {
  8213. if (AinfoArr != null)
  8214. {
  8215. TzHotelDesc += "B段信息 \r\n";
  8216. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8217. if (Ainfo != null)
  8218. {
  8219. if (int.Parse(Ainfo.rs) <= 0)
  8220. {
  8221. continue;
  8222. }
  8223. var hotelText = string.Empty;
  8224. switch (item)
  8225. {
  8226. case "SGR":
  8227. hotelText = "单人间";
  8228. break;
  8229. case "JSES":
  8230. hotelText = "小套房";
  8231. break;
  8232. case "SUITE":
  8233. hotelText = "套房";
  8234. break;
  8235. case "TBR":
  8236. hotelText = "双人间";
  8237. break;
  8238. }
  8239. if (item != "TBR")
  8240. {
  8241. 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";
  8242. }
  8243. else
  8244. {
  8245. 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";
  8246. }
  8247. index++;
  8248. }
  8249. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8250. }
  8251. }
  8252. index = 1;
  8253. foreach (var item in TzAirDescArr)
  8254. {
  8255. if (AinfoArr != null)
  8256. {
  8257. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8258. if (Ainfo != null)
  8259. {
  8260. if (int.Parse(Ainfo.rs) <= 0)
  8261. {
  8262. continue;
  8263. }
  8264. 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";
  8265. index++;
  8266. }
  8267. }
  8268. }
  8269. }
  8270. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8271. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8272. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8273. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8274. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8275. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8276. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8277. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8278. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8279. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8280. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8281. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8282. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8283. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8284. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8285. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8286. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8287. DickeyValue.Add("TzZCost", TzZCost);
  8288. foreach (var key in DickeyValue.Keys)
  8289. {
  8290. if (doc.Range.Bookmarks[key] != null)
  8291. {
  8292. Bookmark mark = doc.Range.Bookmarks[key];
  8293. mark.Text = DickeyValue[key];
  8294. }
  8295. }
  8296. byte[] bytes = null;
  8297. string strFileName = di.TeamName + "-客户报价.doc";
  8298. using (MemoryStream stream = new MemoryStream())
  8299. {
  8300. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8301. bytes = stream.ToArray();
  8302. }
  8303. return Ok(JsonView(true, "", new
  8304. {
  8305. Data = bytes,
  8306. strFileName,
  8307. }));
  8308. }
  8309. /// <summary>
  8310. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8311. /// </summary>
  8312. /// <param name="dto"></param>
  8313. /// <returns></returns>
  8314. [HttpPost]
  8315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8316. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8317. {
  8318. try
  8319. {
  8320. #region 参数验证
  8321. if (dto.DiId < 0)
  8322. {
  8323. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  8324. }
  8325. List<int> cTableIds = new List<int>() {
  8326. 76 ,//酒店预订
  8327. 77 ,//行程
  8328. 79 ,//车/导游地接
  8329. 80 ,//签证
  8330. 81 ,//邀请/公务活
  8331. 82 ,//团组客户保险
  8332. 85 ,//机票预订
  8333. 98 ,//其他款项
  8334. 285 ,//收款退还
  8335. 751 ,//酒店早餐
  8336. 1015 // 超支费用
  8337. };
  8338. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  8339. {
  8340. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  8341. }
  8342. #endregion
  8343. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  8344. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  8345. if (_GroupCostParameters.Count <= 0)
  8346. {
  8347. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  8348. }
  8349. if (_GroupCostParameters[0].IsShare == 0)
  8350. {
  8351. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  8352. }
  8353. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8354. //处理date为空问题
  8355. if (_GroupCosts.Count > 0)
  8356. {
  8357. for (int i = 0; i < _GroupCosts.Count; i++)
  8358. {
  8359. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  8360. {
  8361. if (i > 0)
  8362. {
  8363. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  8364. }
  8365. }
  8366. }
  8367. }
  8368. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  8369. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  8370. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8371. string currCode = "";
  8372. #region currCode 验证
  8373. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  8374. if (isInt)
  8375. {
  8376. var currData = currDatas.Find(it => it.Id == intCurrency);
  8377. if (currData != null)
  8378. {
  8379. currCode = currData.Name;
  8380. }
  8381. }
  8382. else
  8383. {
  8384. currCode = _GroupCostParameters[0].Currency.Trim();
  8385. }
  8386. #endregion
  8387. //op,酒店单段模式存储
  8388. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  8389. {
  8390. CurrencyCode = currCode,
  8391. Rate = _GroupCostParameters[0].Rate,
  8392. CostType = _GroupCostParameters[0].CostType,
  8393. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  8394. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  8395. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  8396. };
  8397. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  8398. if (_GroupCostParameters.Count == 2)
  8399. {
  8400. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  8401. }
  8402. foreach (var item in _GroupCostParameters)
  8403. {
  8404. decimal _rate = 1;
  8405. decimal _rate1 = item.Rate;
  8406. decimal _scale = 1;
  8407. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  8408. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  8409. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  8410. //if (userInfo != null)
  8411. //{
  8412. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  8413. // {
  8414. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  8415. // {
  8416. // _scale = 1.00M;
  8417. // }
  8418. // }
  8419. //}
  8420. #endregion
  8421. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  8422. {
  8423. CurrencyCode = currCode,
  8424. Rate = _rate1,
  8425. CostType = item.CostType,
  8426. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  8427. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  8428. CostTypeNumber = item.CostTypenumber
  8429. };
  8430. if (_GroupCostParameters.Count > 1)
  8431. {
  8432. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  8433. }
  8434. else
  8435. {
  8436. modulePromptInfo.CostTypeNumber = item.LYJRS;
  8437. }
  8438. if (dto.CTable == 79)//
  8439. {
  8440. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  8441. modulePromptInfo.TotalCost = item.DJCB;
  8442. }
  8443. List<string> costTypes = new List<string>() { "A", "B" };
  8444. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  8445. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  8446. if (_GroupCostsDuplicates.Count() == 1)
  8447. {
  8448. _GroupCostsTypeData = _GroupCosts;
  8449. }
  8450. else
  8451. {
  8452. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  8453. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  8454. }
  8455. /*
  8456. * 76 酒店预订
  8457. * 77 行程
  8458. * 79 车/导游地接
  8459. * 80 签证
  8460. * 81 邀请/公务活动
  8461. * 82 团组客户保险
  8462. * 85 机票预订
  8463. * 98 其他款项
  8464. * 285 收款退还
  8465. * 751 酒店早餐
  8466. * 1015 超支费用
  8467. */
  8468. switch (dto.CTable)
  8469. {
  8470. case 76: // 酒店预订
  8471. _ModuleSubPromptInfo.AddRange(
  8472. _GroupCostsTypeData.Select(it => new
  8473. {
  8474. it.DAY,
  8475. it.Date,
  8476. it.ACCON,
  8477. it.ITIN,
  8478. it.SGR,
  8479. it.TBR,
  8480. it.JS_ES,
  8481. it.Suite
  8482. })
  8483. );
  8484. break;
  8485. case 79: // 车/导游地接
  8486. _ModuleSubPromptInfo.AddRange(
  8487. _GroupCostsTypeData.Select(it => new
  8488. {
  8489. Date = it.Date, //日期
  8490. CarFee = it.CarCost * _rate * _scale, //车费用
  8491. CarType = it.CarType, //车型
  8492. DriverFee = it.CFS * _rate * _scale, //司机工资
  8493. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  8494. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  8495. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  8496. GuideFee = it.TGS * _rate * _scale, //导游费用
  8497. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  8498. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  8499. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  8500. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  8501. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  8502. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  8503. Breakfast = it.B * _rate * _scale, //早餐费
  8504. Lunch = it.L * _rate * _scale, //午餐费
  8505. Dinner = it.D * _rate * _scale, //晚餐费
  8506. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  8507. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  8508. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  8509. TicketFee = it.EF * _rate * _scale, //门票费
  8510. TicketRemark = it.EFR, //门票费描述
  8511. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  8512. TravelSupplies = it.TE * _rate * _scale, //出行物资
  8513. SpentCash = it.PC * _rate * _scale, //零用金
  8514. LeadersFee = it.TLF * _rate * _scale, //领队费
  8515. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  8516. })
  8517. );
  8518. break;
  8519. case 85: // 机票
  8520. List<dynamic> datas = new List<dynamic>();
  8521. datas.Add(
  8522. new
  8523. {
  8524. AirType = "经济舱",
  8525. AirNum = item.JJCRS,
  8526. AirDRCB = item.JJCCB,
  8527. AirZCB = (item.JJCRS * item.JJCCB)
  8528. }
  8529. );
  8530. datas.Add(
  8531. new
  8532. {
  8533. AirType = "公务舱",
  8534. AirNum = item.GWCRS,
  8535. AirDRCB = item.GWCCB,
  8536. AirZCB = (item.GWCRS * item.GWCCB)
  8537. }
  8538. );
  8539. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8540. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8541. modulePromptInfo.Data = new
  8542. {
  8543. airFeeData = datas,
  8544. airInitData = initDatas
  8545. };
  8546. _ModulePromptInfos.Add(modulePromptInfo);
  8547. break;
  8548. default:
  8549. break;
  8550. }
  8551. }
  8552. if (dto.CTable != 85)
  8553. {
  8554. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8555. _ModulePromptInfos.Add(_ModulePromptInfo);
  8556. }
  8557. _view.ModulePromptInfos = _ModulePromptInfos;
  8558. return Ok(JsonView(true, "操作成功!", _view));
  8559. }
  8560. catch (Exception ex)
  8561. {
  8562. return Ok(JsonView(false, ex.Message));
  8563. }
  8564. }
  8565. /// <summary>
  8566. /// 根据黑屏代码重新生成行程
  8567. /// </summary>
  8568. /// <param name="dto"></param>
  8569. /// <returns></returns>
  8570. [HttpPost]
  8571. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  8572. {
  8573. var jw = JsonView(false);
  8574. var Create = _GroupCostRepository.
  8575. CreateGroupCostByBlackCode(dto.Diid);
  8576. jw.Msg = Create.Msg;
  8577. if (Create.Code == 0)
  8578. {
  8579. jw.Code = 200;
  8580. jw.Data = new
  8581. {
  8582. groupCost = Create.Data,
  8583. blackCodeIsTrue = true
  8584. };
  8585. }
  8586. else
  8587. {
  8588. jw.Code = 400;
  8589. jw.Data = new
  8590. {
  8591. groupCost = Create.Data,
  8592. blackCodeIsTrue = false,
  8593. };
  8594. }
  8595. return Ok(jw);
  8596. }
  8597. /// <summary>
  8598. /// 成本获取OP历史车费用
  8599. /// </summary>
  8600. /// <param name="dto"></param>
  8601. /// <returns></returns>
  8602. [HttpPost]
  8603. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  8604. {
  8605. var jw = JsonView(false);
  8606. try
  8607. {
  8608. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  8609. //获取现有所有车的数据
  8610. if (!dto.Param.IsNullOrWhiteSpace())
  8611. {
  8612. string sql = $@"
  8613. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8614. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8615. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8616. 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
  8617. AND gctggr.ServiceEndTime is not NULL
  8618. ORDER by gctggrc.id DESC
  8619. ";
  8620. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8621. var numeberResult = await Task.Run(() =>
  8622. {
  8623. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8624. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8625. return numberArr;
  8626. });
  8627. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8628. foreach (var item in numeberResult)
  8629. {
  8630. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8631. {
  8632. Country = "数据异常!",
  8633. City = string.Empty,
  8634. };
  8635. item.Area = find.Country + " " + find.City;
  8636. }
  8637. dbResult.AddRange(numeberResult);
  8638. if (dto.Param.Contains("、"))
  8639. {
  8640. var sp = dto.Param.Split("、");
  8641. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8642. .Where(x =>
  8643. {
  8644. return System.Array.Exists(sp, e =>
  8645. {
  8646. bool where = false;
  8647. if (x.Area != null)
  8648. {
  8649. where = x.Area.Contains(e);
  8650. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8651. {
  8652. return false;
  8653. }
  8654. }
  8655. if (x.PriceName != null && !where)
  8656. {
  8657. where = x.PriceName.Contains(e);
  8658. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8659. {
  8660. return false;
  8661. }
  8662. }
  8663. return where;
  8664. });
  8665. }).ToList();
  8666. }
  8667. else
  8668. {
  8669. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8670. .Where(x =>
  8671. {
  8672. bool where = false;
  8673. if (x.Area != null)
  8674. {
  8675. where = x.Area.Contains(dto.Param);
  8676. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8677. {
  8678. return false;
  8679. }
  8680. }
  8681. if (x.PriceName != null && !where)
  8682. {
  8683. where = x.PriceName.Contains(dto.Param);
  8684. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8685. {
  8686. return false;
  8687. }
  8688. }
  8689. return where;
  8690. }
  8691. )
  8692. .ToList();
  8693. }
  8694. }
  8695. var view = dbResult.Select(x =>
  8696. {
  8697. decimal dp = 0.00M;
  8698. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  8699. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8700. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8701. {
  8702. if (startB && endB)
  8703. {
  8704. var timesp = endD.Subtract(startD);
  8705. if ((timesp.Days + 1) != 0)
  8706. {
  8707. dp = x.Price / (timesp.Days + 1);
  8708. }
  8709. }
  8710. }
  8711. else
  8712. {
  8713. dp = x.Price;
  8714. }
  8715. return new
  8716. {
  8717. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8718. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8719. x.Area,
  8720. x.id,
  8721. price = x.Price.ToString("F2"),
  8722. x.PriceName,
  8723. x.PriceContent,
  8724. x.TeamName,
  8725. x.DatePrice,
  8726. dayPrice = dp.ToString("F2"),
  8727. };
  8728. }).OrderByDescending(x => x.id).ToList();
  8729. jw = JsonView(true, "获取成功!", view);
  8730. }
  8731. catch (Exception e)
  8732. {
  8733. jw = JsonView(false, e.Message);
  8734. }
  8735. return Ok(jw);
  8736. }
  8737. #endregion
  8738. #region 酒店预订 新 雷怡 2023-12-28 17:45
  8739. /// <summary>
  8740. /// 酒店预订
  8741. /// 酒店费用列表 根据团组Id查询
  8742. /// </summary>
  8743. /// <param name="_dto"></param>
  8744. /// <returns></returns>
  8745. [HttpPost]
  8746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8747. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  8748. {
  8749. #region 参数验证
  8750. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8751. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8752. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8753. #region 团组操作权限验证 76 酒店预定模块
  8754. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8755. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8756. #endregion
  8757. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8758. #region 页面操作权限验证
  8759. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8760. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8761. #endregion
  8762. #endregion
  8763. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  8764. }
  8765. /// <summary>
  8766. /// 酒店预订
  8767. /// 基础数据
  8768. /// </summary>
  8769. /// <param name="_dto"></param>
  8770. /// <returns></returns>
  8771. [HttpPost]
  8772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8773. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  8774. {
  8775. #region 参数验证
  8776. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8777. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8778. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8779. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8780. #region 页面操作权限验证
  8781. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8782. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8783. #endregion
  8784. #region 团组操作权限验证 76 酒店预定模块
  8785. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8786. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8787. #endregion
  8788. #endregion
  8789. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  8790. }
  8791. /// <summary>
  8792. /// 酒店预订
  8793. /// 创建 入住卷号码
  8794. /// </summary>
  8795. /// <param name="_dto"></param>
  8796. /// <returns></returns>
  8797. [HttpPost]
  8798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8799. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  8800. {
  8801. try
  8802. {
  8803. #region 参数验证
  8804. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8805. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8806. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8807. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8808. #region 页面操作权限验证
  8809. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8810. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8811. #endregion
  8812. #region 团组操作权限验证 76 酒店预定模块
  8813. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8814. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8815. #endregion
  8816. #endregion
  8817. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  8818. if (data.Code != 0)
  8819. {
  8820. return Ok(JsonView(false, data.Msg));
  8821. }
  8822. return Ok(JsonView(true, data.Msg, data.Data));
  8823. }
  8824. catch (Exception ex)
  8825. {
  8826. return Ok(JsonView(false, ex.Message));
  8827. }
  8828. }
  8829. /// <summary>
  8830. /// 酒店预订
  8831. /// 详情
  8832. /// </summary>
  8833. /// <param name="_dto"></param>
  8834. /// <returns></returns>
  8835. [HttpPost]
  8836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8837. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  8838. {
  8839. #region 参数验证
  8840. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  8841. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8842. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  8843. #region 团组操作权限验证 76 酒店预定模块
  8844. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8845. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8846. #endregion
  8847. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8848. #region 页面操作权限验证
  8849. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8850. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8851. #endregion
  8852. #endregion
  8853. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  8854. }
  8855. /// <summary>
  8856. /// 酒店预订
  8857. /// Add Or Edit
  8858. /// </summary>
  8859. /// <param name="_dto"></param>
  8860. /// <returns></returns>
  8861. [HttpPost]
  8862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8863. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  8864. {
  8865. #region 参数验证
  8866. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8867. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8868. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8869. #region 团组操作权限验证 76 酒店预定模块
  8870. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8871. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8872. #endregion
  8873. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8874. #region 页面操作权限验证
  8875. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8876. if (_dto.Id == 0) // Add
  8877. {
  8878. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  8879. }
  8880. else if (_dto.Id > 1) // Edit
  8881. {
  8882. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  8883. }
  8884. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  8885. #endregion
  8886. #endregion
  8887. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  8888. if (_view.Code != 200)
  8889. {
  8890. return Ok(_view);
  8891. }
  8892. #region 应用推送
  8893. try
  8894. {
  8895. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  8896. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  8897. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  8898. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8899. //自动审核
  8900. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  8901. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  8902. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  8903. }
  8904. catch (Exception ex)
  8905. {
  8906. }
  8907. #endregion
  8908. return Ok(_view);
  8909. }
  8910. /// <summary>
  8911. /// 酒店自动审核测试
  8912. /// Add Or Edit
  8913. /// </summary>
  8914. /// <param name="_dto"></param>
  8915. /// <returns></returns>
  8916. [HttpPost]
  8917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8918. public async Task<IActionResult> PostHotelAutoAuditTest(int diid,int dataId)
  8919. {
  8920. #region 应用推送
  8921. try
  8922. {
  8923. //自动审核
  8924. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  8925. }
  8926. catch (Exception ex)
  8927. {
  8928. return Ok(JsonView(false, "操作失败"));
  8929. }
  8930. #endregion
  8931. return Ok(JsonView(false,"操作成功"));
  8932. }
  8933. /// <summary>
  8934. /// 酒店预订
  8935. /// Del
  8936. /// </summary>
  8937. /// <param name="_dto"></param>
  8938. /// <returns></returns>
  8939. [HttpPost]
  8940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8941. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  8942. {
  8943. #region 参数验证
  8944. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8945. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8946. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8947. #region 团组操作权限验证 76 酒店预定模块
  8948. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8949. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8950. #endregion
  8951. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8952. #region 页面操作权限验证
  8953. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8954. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  8955. #endregion
  8956. #endregion
  8957. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  8958. }
  8959. /// <summary>
  8960. /// 酒店预订
  8961. /// 生成VOUCHER
  8962. /// 2024.05.06 之前版本
  8963. /// </summary>
  8964. /// <param name="_dto"></param>
  8965. /// <returns></returns>
  8966. [HttpPost]
  8967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8968. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  8969. {
  8970. try
  8971. {
  8972. #region 参数验证
  8973. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8974. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8975. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8976. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  8977. #region 团组操作权限验证 76 酒店预定模块
  8978. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8979. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8980. #endregion
  8981. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8982. #region 页面操作权限验证
  8983. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8984. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8985. #endregion
  8986. #endregion
  8987. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  8988. //判断数据是否完整
  8989. if (hr != null)
  8990. {
  8991. if (!string.IsNullOrEmpty(hr.DetermineNo))
  8992. {
  8993. string strFileName = "HotelStatement/";
  8994. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  8995. if (dele != null)
  8996. strFileName += dele.TourCode;
  8997. //载入模板
  8998. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  8999. Document doc = new Document(sss);
  9000. DocumentBuilder builder = new DocumentBuilder(doc);
  9001. #region 替换Word模板书签内容
  9002. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  9003. //入住卷预定号码
  9004. if (doc.Range.Bookmarks["VNO"] != null)
  9005. {
  9006. Bookmark mark = doc.Range.Bookmarks["VNO"];
  9007. mark.Text = hr.CheckNumber;
  9008. }
  9009. //酒店时间
  9010. if (doc.Range.Bookmarks["Date"] != null)
  9011. {
  9012. Bookmark mark = doc.Range.Bookmarks["Date"];
  9013. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9014. }
  9015. //团号
  9016. if (doc.Range.Bookmarks["TNo"] != null)
  9017. {
  9018. Bookmark mark = doc.Range.Bookmarks["TNo"];
  9019. mark.Text = dele.TourCode;
  9020. }
  9021. //预定号码
  9022. if (doc.Range.Bookmarks["BookingId"] != null)
  9023. {
  9024. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  9025. mark.Text = hr.ReservationsNo;
  9026. }
  9027. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  9028. {
  9029. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  9030. mark.Text = hr.DetermineNo;
  9031. }
  9032. //酒店城市
  9033. if (doc.Range.Bookmarks["City"] != null)
  9034. {
  9035. Bookmark mark = doc.Range.Bookmarks["City"];
  9036. mark.Text = hr.City;
  9037. }
  9038. //酒店名称
  9039. if (doc.Range.Bookmarks["HName"] != null)
  9040. {
  9041. Bookmark mark = doc.Range.Bookmarks["HName"];
  9042. mark.Text = hr.HotelName;
  9043. }
  9044. //酒店地址
  9045. if (doc.Range.Bookmarks["Address"] != null)
  9046. {
  9047. Bookmark mark = doc.Range.Bookmarks["Address"];
  9048. mark.Text = hr.HotelAddress;
  9049. }
  9050. //酒店电话
  9051. if (doc.Range.Bookmarks["Tel"] != null)
  9052. {
  9053. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9054. mark.Text = hr.HotelTel;
  9055. }
  9056. //酒店传真
  9057. if (doc.Range.Bookmarks["Fax"] != null)
  9058. {
  9059. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9060. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9061. {
  9062. mark.Text = hr.HotelFax;
  9063. }
  9064. }
  9065. //入住时间
  9066. if (doc.Range.Bookmarks["CIn"] != null)
  9067. {
  9068. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9069. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9070. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9071. }
  9072. //退房时间
  9073. if (doc.Range.Bookmarks["COut"] != null)
  9074. {
  9075. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9076. Bookmark mark = doc.Range.Bookmarks["COut"];
  9077. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9078. }
  9079. //客户名称
  9080. if (doc.Range.Bookmarks["GName"] != null)
  9081. {
  9082. string guestName = "";
  9083. string[] clients = new string[] { };
  9084. if (hr.GuestName.Contains(","))
  9085. {
  9086. clients = hr.GuestName.Split(",");
  9087. }
  9088. else
  9089. {
  9090. clients = new string[] { hr.GuestName };
  9091. }
  9092. List<int> clientIds_int = new List<int>();
  9093. if (clients.Length > 0)
  9094. {
  9095. foreach (var item in clients)
  9096. {
  9097. if (item.IsNumeric())
  9098. {
  9099. clientIds_int.Add(int.Parse(item));
  9100. }
  9101. }
  9102. }
  9103. if (clientIds_int.Count > 0)
  9104. {
  9105. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  9106. foreach (var client in _clientDatas)
  9107. {
  9108. //男
  9109. if (client.Sex == 0) guestName += $"Mr.";
  9110. //女
  9111. else if (client.Sex == 1) guestName += $"Ms.";
  9112. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  9113. {
  9114. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  9115. }
  9116. //guestName += $"{client.Pinyin},";
  9117. }
  9118. if (guestName.Length > 0)
  9119. {
  9120. guestName = guestName.Substring(0, guestName.Length - 1);
  9121. }
  9122. }
  9123. else
  9124. {
  9125. guestName = hr.GuestName;
  9126. }
  9127. Bookmark mark = doc.Range.Bookmarks["GName"];
  9128. mark.Text = guestName;
  9129. }
  9130. //房间介绍
  9131. if (doc.Range.Bookmarks["ROOM"] != null)
  9132. {
  9133. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  9134. mark.Text = hr.RoomExplanation;
  9135. }
  9136. //报价描述
  9137. if (doc.Range.Bookmarks["NOTE"] != null)
  9138. {
  9139. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9140. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9141. if (ss != null)
  9142. mark.Text = ss.Name;
  9143. }
  9144. //入住时间
  9145. if (doc.Range.Bookmarks["CheckIn"] != null)
  9146. {
  9147. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9148. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9149. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9150. }
  9151. //退房时间
  9152. if (doc.Range.Bookmarks["CheckOut"] != null)
  9153. {
  9154. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9155. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9156. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9157. }
  9158. //日期
  9159. if (doc.Range.Bookmarks["DT"] != null)
  9160. {
  9161. Bookmark mark = doc.Range.Bookmarks["DT"];
  9162. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9163. }
  9164. //名称
  9165. if (doc.Range.Bookmarks["VName"] != null)
  9166. {
  9167. Bookmark mark = doc.Range.Bookmarks["VName"];
  9168. mark.Text = hr.HotelName;
  9169. }
  9170. //号码
  9171. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9172. {
  9173. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9174. mark.Text = hr.CheckNumber;
  9175. }
  9176. #endregion
  9177. strFileName += "VOUCHER.doc";
  9178. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9179. doc.Save(fileDir);
  9180. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9181. return Ok(JsonView(true, "操作成功!", Url));
  9182. }
  9183. else
  9184. {
  9185. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9186. }
  9187. }
  9188. else
  9189. {
  9190. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9191. }
  9192. }
  9193. catch (Exception ex)
  9194. {
  9195. return Ok(JsonView(false, ex.Message));
  9196. }
  9197. }
  9198. /// <summary>
  9199. /// 酒店预订
  9200. /// 生成VOUCHER
  9201. /// 2024.05.06 之后版本
  9202. /// </summary>
  9203. /// <param name="_dto"></param>
  9204. /// <returns></returns>
  9205. [HttpPost]
  9206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9207. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9208. {
  9209. #region 参数验证
  9210. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9211. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9212. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9213. #region 团组操作权限验证 76 酒店预定模块
  9214. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9215. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9216. #endregion
  9217. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9218. #region 页面操作权限验证
  9219. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9220. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9221. #endregion
  9222. #endregion
  9223. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9224. //判断数据是否完整
  9225. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9226. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9227. string strFileName = "HotelStatement/";
  9228. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9229. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9230. #region 数据处理
  9231. List<int> guestIds = new List<int>();
  9232. int index = 0;
  9233. foreach (var item in hrDtas)
  9234. {
  9235. if (item.GuestName.Contains(","))
  9236. {
  9237. string[] guestIdArr = item.GuestName.Split(',');
  9238. foreach (var guestIdStr in guestIdArr)
  9239. {
  9240. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9241. if (guestBool)
  9242. {
  9243. guestIds.Add(guestId);
  9244. }
  9245. }
  9246. }
  9247. else guestNames += item.GuestName;
  9248. var voucherInfo = new HotelVoucherInfoView()
  9249. {
  9250. HotelName = item.HotelName,
  9251. CheckInDate = item.CheckInDate,
  9252. CheckOutDate = item.CheckOutDate,
  9253. ConfirmationNumber = item.DetermineNo.Trim(),
  9254. RoomType = item.RoomExplanation
  9255. };
  9256. vouchers.Add(voucherInfo);
  9257. }
  9258. if (guestIds.Count > 0)
  9259. {
  9260. guestIds = guestIds.Distinct().ToList();
  9261. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9262. if (guestDatas.Count > 0)
  9263. {
  9264. guestNames = "";
  9265. foreach (var guest in guestDatas)
  9266. {
  9267. string guestName = "";
  9268. if (guest.Sex == 0) guestName += @"MR.";
  9269. else if (guest.Sex == 1) guestName += @"MS.";
  9270. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9271. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9272. guestNames += @$"{guestName.Trim()}、";
  9273. }
  9274. if (guestNames.Length > 0)
  9275. {
  9276. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9277. }
  9278. }
  9279. }
  9280. #endregion
  9281. //载入模板
  9282. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9283. Document doc = new Document(sss);
  9284. DocumentBuilder builder = new DocumentBuilder(doc);
  9285. if (doc.Range.Bookmarks["GuestName"] != null)
  9286. {
  9287. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9288. mark.Text = guestNames;
  9289. }
  9290. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9291. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9292. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9293. for (int i = 1; i <= vouchers.Count; i++)
  9294. {
  9295. HotelVoucherInfoView hviv = vouchers[i - 1];
  9296. builder.MoveToCell(0, i, 0, 0);
  9297. builder.Write(hviv.HotelName);
  9298. builder.MoveToCell(0, i, 1, 0);
  9299. builder.Write(hviv.CheckInDate);
  9300. builder.MoveToCell(0, i, 2, 0);
  9301. builder.Write(hviv.CheckOutDate);
  9302. builder.MoveToCell(0, i, 3, 0);
  9303. builder.Write(hviv.RoomType);
  9304. builder.MoveToCell(0, i, 4, 0);
  9305. builder.Write(hviv.ConfirmationNumber);
  9306. }
  9307. //删除多余行
  9308. int currRowIndex = vouchers.Count + 1;
  9309. int delRows = 21 - currRowIndex;
  9310. if (delRows > 0)
  9311. {
  9312. for (int i = 0; i < delRows; i++)
  9313. {
  9314. table.Rows.RemoveAt(currRowIndex);
  9315. //cultivateRowIndex++;
  9316. }
  9317. }
  9318. strFileName += "VOUCHER.docx";
  9319. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9320. doc.Save(fileDir);
  9321. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9322. return Ok(JsonView(true, "操作成功!", Url));
  9323. }
  9324. /// <summary>
  9325. /// 酒店预订
  9326. /// 生成VOUCHER 批量生成
  9327. /// New
  9328. /// </summary>
  9329. /// <param name="_dto"></param>
  9330. /// <returns></returns>
  9331. [HttpPost]
  9332. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9333. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  9334. {
  9335. #region 参数验证
  9336. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9337. if (_dto.PageId < 1) _dto.PageId = 28;
  9338. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9339. #region 团组操作权限验证 76 酒店预定模块
  9340. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9341. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9342. #endregion
  9343. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9344. #region 页面操作权限验证
  9345. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9346. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9347. #endregion
  9348. #endregion
  9349. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  9350. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  9351. //.Select(x => new
  9352. //{
  9353. // x.CreateTime,
  9354. // x.CheckNumber,
  9355. // x.ReservationsNo,
  9356. // x.DetermineNo,
  9357. // x.HotelName,
  9358. // x.HotelAddress,
  9359. // x.HotelTel,
  9360. // x.HotelFax,
  9361. // x.CheckInDate,
  9362. // x.CheckOutDate,
  9363. // x.GuestName,
  9364. // x.RoomExplanation,
  9365. //})
  9366. .OrderBy(x => x.CreateTime)
  9367. .ToListAsync();
  9368. //判断数据是否完整
  9369. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9370. string strFileName = "HotelStatement/";
  9371. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9372. if (dele != null)
  9373. strFileName += dele.TourCode;
  9374. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  9375. for (int i = 0; i < hrDtas.Count; i++)
  9376. {
  9377. string guestNames = string.Empty;
  9378. List<int> guestIds = new List<int>();
  9379. var item = hrDtas[i];
  9380. //处理客户姓名
  9381. if (item.GuestName.Contains(","))
  9382. {
  9383. string[] guestIdArr = item.GuestName.Split(',');
  9384. foreach (var guestIdStr in guestIdArr)
  9385. if (int.TryParse(guestIdStr, out int guestId))
  9386. guestIds.Add(guestId);
  9387. }
  9388. else guestNames += item.GuestName;
  9389. if (guestIds.Count > 0)
  9390. {
  9391. guestIds = guestIds.Distinct().ToList();
  9392. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  9393. if (guestDatas1.Count > 0)
  9394. {
  9395. guestNames = "";
  9396. foreach (var guest in guestDatas1)
  9397. {
  9398. string guestName = "";
  9399. if (guest.Sex == 0) guestName += @"MR.";
  9400. else if (guest.Sex == 1) guestName += @"MS.";
  9401. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9402. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9403. guestNames += @$"{guestName.Trim()}、";
  9404. }
  9405. if (guestNames.Length > 0)
  9406. {
  9407. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9408. }
  9409. }
  9410. }
  9411. if (!string.IsNullOrEmpty(guestNames))
  9412. {
  9413. hrDtas[i].GuestName = guestNames;
  9414. }
  9415. }
  9416. strFileName += "VOUCHER.docx";
  9417. Document doc = new Document();
  9418. DocumentBuilder builder = new DocumentBuilder(doc);
  9419. try
  9420. {
  9421. foreach (var item in hrDtas)
  9422. {
  9423. //标题
  9424. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9425. builder.Writeln("ACCOMMODATION VOUCHER");
  9426. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9427. builder.Writeln($"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  9428. //表格
  9429. builder.InsertCell(); //插入单元格
  9430. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9431. //builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9432. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐 - 靠右
  9433. }
  9434. }
  9435. catch (Exception ex)
  9436. {
  9437. throw;
  9438. }
  9439. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9440. //doc.Save(fileDir);
  9441. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9442. return Ok(JsonView(true, "操作成功!", Url));
  9443. }
  9444. /// <summary>
  9445. /// 酒店预订
  9446. /// 生成 预定成本 Excel
  9447. /// </summary>
  9448. /// <param name="_dto"></param>
  9449. /// <returns></returns>
  9450. [HttpPost]
  9451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9452. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  9453. {
  9454. #region 参数验证
  9455. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  9456. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  9457. if (!vadalitorRes.IsValid)
  9458. {
  9459. var errors = new StringBuilder();
  9460. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  9461. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  9462. }
  9463. #region 团组操作权限验证 76 酒店预定模块
  9464. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9465. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9466. #endregion
  9467. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9468. #region 页面操作权限验证
  9469. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9470. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9471. #endregion
  9472. #endregion
  9473. decimal _rate = 1.00M;
  9474. string _currency = "";
  9475. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  9476. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9477. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  9478. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  9479. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  9480. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  9481. {
  9482. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  9483. }
  9484. _currency = _GroupCostParameter.Currency;
  9485. bool isIntType = int.TryParse(_currency, out int currId);
  9486. if (isIntType)
  9487. {
  9488. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  9489. }
  9490. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  9491. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  9492. if (currInfo == null)
  9493. {
  9494. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  9495. }
  9496. if (!_currency.ToUpper().Equals("CNY"))
  9497. {
  9498. _rate = _GroupCostParameter.Rate;
  9499. }
  9500. _rate = currInfo.Rate;
  9501. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9502. string strFileName = "HotelStatement/";
  9503. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9504. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  9505. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  9506. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  9507. #region 数据处理
  9508. foreach (var item in hrDtas)
  9509. {
  9510. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  9511. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  9512. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  9513. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  9514. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  9515. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  9516. string singleRoomFeeStr = string.Empty,
  9517. doubleRoomFeeStr = string.Empty,
  9518. suiteRoomFeeStr = string.Empty,
  9519. otherRoomFeeStr = string.Empty,
  9520. payMoneyStr = string.Empty,
  9521. cardPriceStr = string.Empty;
  9522. if (roomCurr.Equals(_currency))
  9523. {
  9524. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  9525. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  9526. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  9527. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  9528. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  9529. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  9530. }
  9531. else
  9532. {
  9533. singleRoomFeeStr = $"{(item.SingleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  9534. doubleRoomFeeStr = $"{(item.DoubleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  9535. suiteRoomFeeStr = $"{(item.SuiteRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  9536. otherRoomFeeStr = $"{(item.OtherRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  9537. payMoneyStr = $"{(ccpInfo.PayMoney / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  9538. cardPriceStr = $"{(item.CardPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  9539. }
  9540. string breakfastPriceStr = string.Empty,
  9541. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  9542. governmentRentStr = string.Empty,
  9543. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  9544. cityTaxStrStr = string.Empty,
  9545. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  9546. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  9547. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  9548. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  9549. int payDId = roomInfo?.PayDId ?? 0;
  9550. pcfds.Add(new HotelReservations_PCFD_View()
  9551. {
  9552. City = item.City,
  9553. HotelName = item.HotelName,
  9554. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  9555. // SingleRoomCount = item.SingleRoomCount,
  9556. SingleRoomPrice = singleRoomFeeStr,
  9557. // DoubleRoomCount = item.DoubleRoomCount,
  9558. DoubleRoomPrice = doubleRoomFeeStr,
  9559. //SuiteRoomCount = item.SuiteRoomCount,
  9560. SuiteRoomPrice = suiteRoomFeeStr,
  9561. OtherRoomPrice = otherRoomFeeStr,
  9562. //OtherRoomCount = item.OtherRoomCount,
  9563. BreakfastPrice = breakfastPriceStr,
  9564. GovernmentRent = governmentRentStr,
  9565. CityTax = cityTaxStrStr,
  9566. RoomExplanation = item.RoomExplanation,
  9567. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  9568. PayTime = roomInfo?.ConsumptionDate,
  9569. BankNo = roomInfo?.BankNo,
  9570. PayMoney = payMoneyStr,
  9571. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  9572. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  9573. CardPrice = cardPriceStr,
  9574. Remark = ccpInfo.Remark
  9575. });
  9576. }
  9577. #endregion
  9578. //载入模板
  9579. WorkbookDesigner designer = new WorkbookDesigner();
  9580. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  9581. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  9582. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  9583. designer.SetDataSource("TourNo", groupInfo.TourCode);
  9584. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  9585. designer.SetDataSource("Opertor", userInfo.CnName);
  9586. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  9587. dt.TableName = "ViewMyHotelReservations";
  9588. designer.SetDataSource(dt);
  9589. designer.Process();
  9590. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/","").Replace(@"\", "").Trim()}_酒店预订成本_{ DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  9591. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  9592. designer.Workbook.Save(serverPath);
  9593. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  9594. #region 删除指定行
  9595. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  9596. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  9597. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  9598. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  9599. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  9600. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  9601. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  9602. cssIndex = dt.Columns["CityTax"].Ordinal,
  9603. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  9604. remarkIndex = dt.Columns["Remark"].Ordinal;
  9605. //删除指定列
  9606. foreach (DataRow item in dt.Rows)
  9607. {
  9608. string singleStr = item["SingleRoomPrice"].ToString();
  9609. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  9610. if (containsDigitButNotZero1) singleDel = false;
  9611. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  9612. string doubleStr = item["DoubleRoomPrice"].ToString();
  9613. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9614. if (containsDigitButNotZero2) doubleDel = false;
  9615. string suiteStr = item["SuiteRoomPrice"].ToString();
  9616. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9617. if (containsDigitButNotZero3) suiteDel = false;
  9618. string otherStr = item["OtherRoomPrice"].ToString();
  9619. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  9620. if (containsDigitButNotZero4) otherDel = false;
  9621. string zcStr = item["BreakfastPrice"].ToString();
  9622. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  9623. if (containsDigitButNotZero5) zcDel = false;
  9624. string dsStr = item["GovernmentRent"].ToString();
  9625. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  9626. if (containsDigitButNotZero6) dsDel = false;
  9627. string cssStr = item["CityTax"].ToString();
  9628. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  9629. if (containsDigitButNotZero7) cssDel = false;
  9630. string cpStr = item["ConsumptionPatterns"].ToString();
  9631. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  9632. string remarkStr = item["Remark"].ToString();
  9633. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  9634. }
  9635. DeleteColumn(serverPath, remarkIndex, remarkDel);
  9636. DeleteColumn(serverPath, cpIndex, cpDel);
  9637. DeleteColumn(serverPath, dsIndex, dsDel);
  9638. DeleteColumn(serverPath, cssIndex, cssDel);
  9639. DeleteColumn(serverPath, zcIndex, zcDel);
  9640. DeleteColumn(serverPath, otherIndex, otherDel);
  9641. DeleteColumn(serverPath, suiteIndex, suiteDel);
  9642. DeleteColumn(serverPath, doubleIndex, doubleDel);
  9643. DeleteColumn(serverPath, singleIndex, singleDel);
  9644. #endregion
  9645. //只保留第一个表格
  9646. DeleteSheet(serverPath);
  9647. return Ok(JsonView(true, "操作成功", url = rst));
  9648. }
  9649. /// <summary>
  9650. /// 删除指定列
  9651. /// </summary>
  9652. /// <param name="file"></param>
  9653. /// <param name="columnIndex"></param>
  9654. /// <param name="isDel"></param>
  9655. private void DeleteColumn(string file, int columnIndex, bool isDel)
  9656. {
  9657. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9658. //wb.Save(file);
  9659. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  9660. if (sheet1 != null)
  9661. {
  9662. if (isDel)
  9663. {
  9664. Cells cells = sheet1.Cells;
  9665. cells.DeleteColumn(columnIndex);
  9666. }
  9667. }
  9668. wb.Save(file);
  9669. }
  9670. /// <summary>
  9671. /// 删除sheet
  9672. /// </summary>
  9673. /// <param name="file"></param>
  9674. /// <param name="sheetName"></param>
  9675. private void DeleteSheet(string file, string sheetName = "")
  9676. {
  9677. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9678. //wb.Save(file);
  9679. List<string> sheets = new List<string>();
  9680. foreach (var item in wb.Worksheets)
  9681. {
  9682. sheets.Add(item.Name);
  9683. }
  9684. if (sheets.Count > 0)
  9685. {
  9686. sheets.RemoveAt(0);//不删除第一个sheet
  9687. foreach (var item in sheets)
  9688. {
  9689. wb.Worksheets.RemoveAt(item);
  9690. }
  9691. }
  9692. wb.Save(file);
  9693. }
  9694. /// <summary>
  9695. /// 酒店预订
  9696. /// 确认单
  9697. /// </summary>
  9698. /// <param name="_dto"></param>
  9699. /// <returns></returns>
  9700. [HttpPost]
  9701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9702. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  9703. {
  9704. try
  9705. {
  9706. #region 参数验证
  9707. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9708. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9709. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9710. #region 团组操作权限验证 76 酒店预定模块
  9711. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9712. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9713. #endregion
  9714. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9715. #region 页面操作权限验证
  9716. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9717. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9718. #endregion
  9719. #endregion
  9720. //团组信息
  9721. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  9722. //酒店数据
  9723. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  9724. if (listhoteldata.Count < 0)
  9725. {
  9726. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  9727. }
  9728. //利datatable存储
  9729. DataTable dt = new DataTable();
  9730. dt.Columns.Add("CheckInDate", typeof(string));
  9731. dt.Columns.Add("City", typeof(string));
  9732. dt.Columns.Add("Hotel", typeof(string));
  9733. dt.Columns.Add("Room", typeof(string));
  9734. for (int i = 0; i < listhoteldata.Count; i++)
  9735. {
  9736. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  9737. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  9738. while (dayStart < dayEnd)
  9739. {
  9740. string temp = "";
  9741. DataRow row = dt.NewRow();
  9742. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  9743. row["City"] = listhoteldata[i].City;
  9744. row["Hotel"] = listhoteldata[i].HotelName;
  9745. if (listhoteldata[i].SingleRoomCount > 0)
  9746. {
  9747. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  9748. }
  9749. if (listhoteldata[i].DoubleRoomCount > 0)
  9750. {
  9751. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  9752. }
  9753. if (listhoteldata[i].SuiteRoomCount > 0)
  9754. {
  9755. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  9756. }
  9757. if (listhoteldata[i].OtherRoomCount > 0)
  9758. {
  9759. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  9760. }
  9761. row["Room"] = temp;
  9762. dt.Rows.Add(row);
  9763. dayStart = dayStart.AddDays(1);
  9764. }
  9765. }
  9766. Dictionary<string, string> dic = new Dictionary<string, string>();
  9767. dic.Add("Dele", di.TeamName);
  9768. dic.Add("City", di.VisitCountry);
  9769. //模板路径
  9770. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  9771. //载入模板
  9772. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  9773. DocumentBuilder builder = new DocumentBuilder(doc);
  9774. foreach (var key in dic.Keys)
  9775. {
  9776. builder.MoveToBookmark(key);
  9777. builder.Write(dic[key]);
  9778. }
  9779. //获取word里所有表格
  9780. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9781. //获取所填表格的序数
  9782. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9783. var rowStart = tableOne.Rows[0]; //获取第1行
  9784. //循环赋值
  9785. for (int i = 0; i < dt.Rows.Count; i++)
  9786. {
  9787. builder.MoveToCell(0, i + 1, 0, 0);
  9788. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  9789. builder.MoveToCell(0, i + 1, 1, 0);
  9790. builder.Write(dt.Rows[i]["City"].ToString());
  9791. builder.MoveToCell(0, i + 1, 2, 0);
  9792. builder.Write(dt.Rows[i]["Hotel"].ToString());
  9793. builder.MoveToCell(0, i + 1, 3, 0);
  9794. builder.Write(dt.Rows[i]["Room"].ToString());
  9795. }
  9796. //删除多余行
  9797. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  9798. {
  9799. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  9800. }
  9801. string strFileName = di.TeamName + "酒店确认单.doc";
  9802. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  9803. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  9804. return Ok(JsonView(true, "成功", url));
  9805. }
  9806. catch (Exception ex)
  9807. {
  9808. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  9809. }
  9810. }
  9811. #endregion
  9812. #region 团组状态
  9813. /// <summary>
  9814. /// 团组状态列表 Page
  9815. /// </summary>
  9816. /// <param name="dto">团组列表请求dto</param>
  9817. /// <returns></returns>
  9818. [HttpPost]
  9819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9820. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  9821. {
  9822. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9823. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  9824. {
  9825. string sqlWhere = string.Empty;
  9826. if (dto.IsSure == 0) //未完成
  9827. {
  9828. sqlWhere += string.Format(@" And IsSure = 0");
  9829. }
  9830. else if (dto.IsSure == 1) //已完成
  9831. {
  9832. sqlWhere += string.Format(@" And IsSure = 1");
  9833. }
  9834. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  9835. {
  9836. string tj = dto.SearchCriteria;
  9837. 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}%')",
  9838. tj, tj, tj, tj, tj);
  9839. }
  9840. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  9841. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  9842. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  9843. From (
  9844. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  9845. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  9846. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  9847. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  9848. From Grp_DelegationInfo gdi
  9849. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  9850. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  9851. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  9852. Where gdi.IsDel = 0 {0}
  9853. ) temp ", sqlWhere);
  9854. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  9855. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  9856. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  9857. }
  9858. else
  9859. {
  9860. return Ok(JsonView(false, "查询失败"));
  9861. }
  9862. }
  9863. /// <summary>
  9864. /// 团组状态
  9865. /// 设置操作完成
  9866. /// </summary>
  9867. /// <param name="dto">团组列表请求dto</param>
  9868. /// <returns></returns>
  9869. [HttpPost]
  9870. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9871. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  9872. {
  9873. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9874. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  9875. {
  9876. Id = dto.Id,
  9877. IsSure = 1
  9878. };
  9879. var result = await _sqlSugar.Updateable(_DelegationInfo)
  9880. .UpdateColumns(it => new { it.IsSure })
  9881. .WhereColumns(it => new { it.Id })
  9882. .ExecuteCommandAsync();
  9883. if (result > 0)
  9884. {
  9885. return Ok(JsonView(true, "操作完成!"));
  9886. }
  9887. return Ok(JsonView(false, "操作失败!"));
  9888. }
  9889. #endregion
  9890. #region 保险费用录入
  9891. /// <summary>
  9892. /// 根据团组Id查询保险费用列表
  9893. /// </summary>
  9894. /// <param name="dto"></param>
  9895. /// <returns></returns>
  9896. [HttpPost]
  9897. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9898. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  9899. {
  9900. try
  9901. {
  9902. Result groupData = await _customersRep.CustomersByDiId(dto);
  9903. if (groupData.Code != 0)
  9904. {
  9905. return Ok(JsonView(false, groupData.Msg));
  9906. }
  9907. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9908. }
  9909. catch (Exception ex)
  9910. {
  9911. return Ok(JsonView(false, ex.Message));
  9912. }
  9913. }
  9914. /// <summary>
  9915. /// 根据保险费用Id查询保险费用详细
  9916. /// </summary>
  9917. /// <param name="dto"></param>
  9918. /// <returns></returns>
  9919. [HttpPost]
  9920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9921. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  9922. {
  9923. try
  9924. {
  9925. Result groupData = await _customersRep.CustomersById(dto);
  9926. if (groupData.Code != 0)
  9927. {
  9928. return Ok(JsonView(false, groupData.Msg));
  9929. }
  9930. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9931. }
  9932. catch (Exception ex)
  9933. {
  9934. return Ok(JsonView(false, ex.Message));
  9935. }
  9936. }
  9937. /// <summary>
  9938. /// 保险费用录入页面初始化绑定
  9939. /// </summary>
  9940. /// <param name="dto"></param>
  9941. /// <returns></returns>
  9942. [HttpPost]
  9943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9944. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  9945. {
  9946. try
  9947. {
  9948. Result groupData = await _customersRep.CustomersInitialize(dto);
  9949. if (groupData.Code != 0)
  9950. {
  9951. return Ok(JsonView(false, groupData.Msg));
  9952. }
  9953. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9954. }
  9955. catch (Exception ex)
  9956. {
  9957. return Ok(JsonView(false, ex.Message));
  9958. }
  9959. }
  9960. /// <summary>
  9961. /// 保险费用操作(Status:1.新增,2.修改)
  9962. /// </summary>
  9963. /// <param name="dto"></param>
  9964. /// <returns></returns>
  9965. [HttpPost]
  9966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9967. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  9968. {
  9969. try
  9970. {
  9971. Result groupData = await _customersRep.OpCustomers(dto);
  9972. if (groupData.Code != 0)
  9973. {
  9974. return Ok(JsonView(false, groupData.Msg));
  9975. }
  9976. #region 应用推送
  9977. try
  9978. {
  9979. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9980. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9981. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9982. }
  9983. catch (Exception ex)
  9984. {
  9985. }
  9986. #endregion
  9987. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9988. }
  9989. catch (Exception ex)
  9990. {
  9991. return Ok(JsonView(false, ex.Message));
  9992. }
  9993. }
  9994. /// <summary>
  9995. /// 保险文件上传
  9996. /// </summary>
  9997. /// <param name="file"></param>
  9998. /// <returns></returns>
  9999. [HttpPost]
  10000. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10001. public async Task<IActionResult> UploadCus(IFormFile file)
  10002. {
  10003. try
  10004. {
  10005. if (file != null)
  10006. {
  10007. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10008. //文件名称
  10009. string projectFileName = file.FileName;
  10010. //上传的文件的路径
  10011. string filePath = "";
  10012. if (!Directory.Exists(fileDir))
  10013. {
  10014. Directory.CreateDirectory(fileDir);
  10015. }
  10016. //上传的文件的路径
  10017. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  10018. using (FileStream fs = System.IO.File.Create(filePath))
  10019. {
  10020. file.CopyTo(fs);
  10021. fs.Flush();
  10022. }
  10023. return Ok(JsonView(true, "上传成功!", projectFileName));
  10024. }
  10025. else
  10026. {
  10027. return Ok(JsonView(false, "上传失败!"));
  10028. }
  10029. }
  10030. catch (Exception ex)
  10031. {
  10032. return Ok(JsonView(false, "程序错误!"));
  10033. throw;
  10034. }
  10035. }
  10036. /// <summary>
  10037. /// 保险删除指定文件
  10038. /// </summary>
  10039. /// <param name="dto"></param>
  10040. /// <returns></returns>
  10041. [HttpPost]
  10042. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10043. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  10044. {
  10045. try
  10046. {
  10047. string filePath = "";
  10048. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10049. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  10050. //int id = 0;
  10051. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  10052. // 删除该文件
  10053. try
  10054. {
  10055. System.IO.File.Delete(filePath);
  10056. 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()
  10057. {
  10058. Attachment = "",
  10059. }).ExecuteCommandAsync();
  10060. if (result != 0)
  10061. {
  10062. return Ok(JsonView(true, "成功!"));
  10063. }
  10064. else
  10065. {
  10066. return Ok(JsonView(false, "失败!"));
  10067. }
  10068. }
  10069. catch (Exception)
  10070. {
  10071. 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()
  10072. {
  10073. Attachment = "",
  10074. }).ExecuteCommandAsync();
  10075. if (result != 0)
  10076. {
  10077. return Ok(JsonView(true, "成功!"));
  10078. }
  10079. else
  10080. {
  10081. return Ok(JsonView(false, "失败!"));
  10082. }
  10083. }
  10084. }
  10085. catch (Exception ex)
  10086. {
  10087. return Ok(JsonView(false, "程序错误!"));
  10088. throw;
  10089. }
  10090. }
  10091. /// <summary>
  10092. /// 保险费用操作(删除)
  10093. /// </summary>
  10094. /// <param name="dto"></param>
  10095. /// <returns></returns>
  10096. [HttpPost]
  10097. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10098. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  10099. {
  10100. try
  10101. {
  10102. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  10103. if (!res)
  10104. {
  10105. return Ok(JsonView(false, "删除失败"));
  10106. }
  10107. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  10108. {
  10109. IsDel = 1,
  10110. DeleteUserId = dto.DeleteUserId,
  10111. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10112. }).ExecuteCommandAsync();
  10113. return Ok(JsonView(true, "删除成功!"));
  10114. }
  10115. catch (Exception ex)
  10116. {
  10117. return Ok(JsonView(false, "程序错误!"));
  10118. throw;
  10119. }
  10120. }
  10121. #endregion
  10122. #region 接团客户名单 PageId 104
  10123. /// <summary>
  10124. /// 接团客户名单
  10125. /// 迁移数据(慎用!)
  10126. /// </summary>
  10127. /// <param name="dto"></param>
  10128. /// <returns></returns>
  10129. [HttpPost]
  10130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10131. public async Task<IActionResult> PostTourClientListChange()
  10132. {
  10133. try
  10134. {
  10135. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  10136. //var groupClinetData1
  10137. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  10138. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  10139. int updateCount = 0;
  10140. if (oldOAClientList.Count > 0)
  10141. {
  10142. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  10143. _sqlSugar.BeginTran();
  10144. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  10145. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  10146. foreach (var item in oldOAClientList)
  10147. {
  10148. int comId = 0;
  10149. string format = "yyyy-MM-dd HH:mm:ss";
  10150. string data11 = "1990-01-01 00:00";
  10151. var data1 = IsValidDate(item.OPdate, format);
  10152. if (data1) data11 = item.OPdate;
  10153. //客户公司验证
  10154. if (!string.IsNullOrEmpty(item.Company))
  10155. {
  10156. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  10157. if (clientComInfo == null) // add
  10158. {
  10159. var addInfo = new Crm_CustomerCompany()
  10160. {
  10161. CompanyAbbreviation = "",
  10162. CompanyFullName = item.Company,
  10163. Address = "",
  10164. PostCodes = "",
  10165. LastedOpUserId = item.OPer,
  10166. LastedOpDt = Convert.ToDateTime(data11),
  10167. CreateUserId = item.OPer,
  10168. CreateTime = Convert.ToDateTime(data11),
  10169. IsDel = 0
  10170. };
  10171. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  10172. if (comId1 > 0) comId = comId1;
  10173. }
  10174. else comId = clientComInfo.Id;
  10175. }
  10176. //客户人员验证
  10177. int clientId = 0;
  10178. string name = item.LastName + item.Name;
  10179. if (!string.IsNullOrEmpty(name))
  10180. {
  10181. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  10182. if (clientInfo == null)
  10183. {
  10184. DateTime? dateTime = null;
  10185. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  10186. if (isDt) dateTime = birthDayDt;
  10187. var addInfo1 = new Crm_DeleClient()
  10188. {
  10189. CrmCompanyId = comId,
  10190. DiId = -1,
  10191. LastName = item.LastName,
  10192. FirstName = item.Name,
  10193. OldName = "",
  10194. Pinyin = item.Pinyin,
  10195. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  10196. Marriage = 0,
  10197. Phone = item.Phone,
  10198. Job = item.Job,
  10199. BirthDay = dateTime
  10200. };
  10201. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  10202. if (clientId1 > 0) clientId = clientId1;
  10203. }
  10204. else clientId = clientInfo.Id;
  10205. }
  10206. if (clientId < 1)
  10207. {
  10208. continue;
  10209. }
  10210. int airType = 0;
  10211. if (item.AirType == "超经舱") airType = 459;
  10212. else if (item.AirType == "公务舱") airType = 458;
  10213. else if (item.AirType == "经济舱") airType = 460;
  10214. else if (item.AirType == "其他") airType = 565;
  10215. else if (item.AirType == "头等舱") airType = 457;
  10216. var _TourClientListEntity = new Grp_TourClientList()
  10217. {
  10218. DiId = item.Diid,
  10219. ClientId = clientId,
  10220. CreateUserId = item.OPer,
  10221. CreateTime = Convert.ToDateTime(data11),
  10222. Remark = item.Remark,
  10223. IsDel = item.Isdel,
  10224. ShippingSpaceTypeId = airType,
  10225. ShippingSpaceSpecialNeeds = item.AirRemark,
  10226. HotelSpecialNeeds = item.RoomType
  10227. };
  10228. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  10229. if (_TourClientList > 0)
  10230. {
  10231. updateCount++;
  10232. }
  10233. }
  10234. _sqlSugar.CommitTran();
  10235. }
  10236. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  10237. }
  10238. catch (Exception ex)
  10239. {
  10240. _sqlSugar.RollbackTran();
  10241. return Ok(JsonView(false, ex.Message));
  10242. }
  10243. return Ok(JsonView(true));
  10244. }
  10245. private bool IsValidDate(string dateString, string format)
  10246. {
  10247. DateTime dateValue;
  10248. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  10249. return valid;
  10250. }
  10251. /// <summary>
  10252. /// 接团客户名单
  10253. /// 根据团组Id查询List
  10254. /// </summary>
  10255. /// <param name="dto"></param>
  10256. /// <returns></returns>
  10257. [HttpPost]
  10258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10259. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  10260. {
  10261. #region 参数验证
  10262. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  10263. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10264. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  10265. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10266. #region 页面操作权限验证
  10267. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10268. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10269. #endregion
  10270. #endregion
  10271. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  10272. if (viewData.Code != 0)
  10273. {
  10274. return Ok(JsonView(false, viewData.Msg));
  10275. }
  10276. return Ok(JsonView(viewData.Data));
  10277. }
  10278. /// <summary>
  10279. /// 接团客户名单
  10280. /// 基础数据 Init
  10281. /// </summary>
  10282. /// <param name="_dto"></param>
  10283. /// <returns></returns>
  10284. [HttpPost]
  10285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10286. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  10287. {
  10288. #region 参数验证
  10289. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10290. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10291. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10292. #region 页面操作权限验证
  10293. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10294. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10295. #endregion
  10296. #endregion
  10297. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  10298. if (viewData.Code != 0)
  10299. {
  10300. return Ok(JsonView(false, viewData.Msg));
  10301. }
  10302. return Ok(JsonView(viewData.Data));
  10303. }
  10304. /// <summary>
  10305. /// 接团客户名单
  10306. /// 根据 Id查询 Details
  10307. /// </summary>
  10308. /// <param name="_dto"></param>
  10309. /// <returns></returns>
  10310. [HttpPost]
  10311. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10312. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  10313. {
  10314. #region 参数验证
  10315. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10316. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10317. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10318. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10319. #region 页面操作权限验证
  10320. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10321. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10322. #endregion
  10323. #endregion
  10324. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  10325. if (viewData.Code != 0)
  10326. {
  10327. return Ok(JsonView(false, viewData.Msg));
  10328. }
  10329. return Ok(JsonView(viewData.Data));
  10330. }
  10331. /// <summary>
  10332. /// 接团客户名单
  10333. /// Add Or Edit
  10334. /// </summary>
  10335. /// <param name="_dto"></param>
  10336. /// <returns></returns>
  10337. [HttpPost]
  10338. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10339. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  10340. {
  10341. #region 参数验证
  10342. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10343. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10344. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10345. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10346. #region 页面操作权限验证
  10347. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10348. if (_dto.Id == 0) //添加
  10349. {
  10350. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10351. }
  10352. else if (_dto.Id >= 0) //修改
  10353. {
  10354. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10355. }
  10356. #endregion
  10357. #endregion
  10358. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  10359. if (viewData.Code != 0)
  10360. {
  10361. return Ok(JsonView(false, viewData.Msg));
  10362. }
  10363. return Ok(JsonView(true));
  10364. }
  10365. /// <summary>
  10366. /// 接团客户名单
  10367. /// AddMultiple(添加多个)
  10368. /// </summary>
  10369. /// <param name="_dto"></param>
  10370. /// <returns></returns>
  10371. [HttpPost]
  10372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10373. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  10374. {
  10375. #region 参数验证
  10376. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10377. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10378. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10379. #region 页面操作权限验证
  10380. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10381. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10382. #endregion
  10383. #endregion
  10384. var viewData = await _tourClientListRep._AddMultiple(_dto);
  10385. if (viewData.Code != 0)
  10386. {
  10387. return Ok(JsonView(false, viewData.Msg));
  10388. }
  10389. return Ok(JsonView(true));
  10390. }
  10391. /// <summary>
  10392. /// 接团客户名单
  10393. /// Del
  10394. /// </summary>
  10395. /// <param name="_dto"></param>
  10396. /// <returns></returns>
  10397. [HttpPost]
  10398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10399. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  10400. {
  10401. #region 参数验证
  10402. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10403. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10404. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10405. #region 页面操作权限验证
  10406. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10407. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  10408. #endregion
  10409. #endregion
  10410. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  10411. if (viewData.Code != 0)
  10412. {
  10413. return Ok(JsonView(false, viewData.Msg));
  10414. }
  10415. return Ok(JsonView(true));
  10416. }
  10417. /// <summary>
  10418. /// 接团客户名单
  10419. /// 文件下载 客户名单
  10420. /// </summary>
  10421. /// <param name="_dto"></param>
  10422. /// <returns></returns>
  10423. [HttpPost]
  10424. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10425. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  10426. {
  10427. #region 参数验证
  10428. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10429. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10430. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  10431. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10432. #region 页面操作权限验证
  10433. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10434. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10435. #endregion
  10436. #endregion
  10437. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  10438. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  10439. From Grp_TourClientList tcl
  10440. Left Join
  10441. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  10442. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  10443. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  10444. From Crm_DeleClient dc
  10445. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  10446. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  10447. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  10448. Where dc.IsDel = 0) temp
  10449. On temp.DcId =tcl.ClientId
  10450. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  10451. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  10452. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  10453. //载入模板
  10454. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  10455. if (_dto.Language == 1)
  10456. {
  10457. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  10458. }
  10459. //载入模板
  10460. var doc = new Document(tempPath);
  10461. DocumentBuilder builder = new DocumentBuilder(doc);
  10462. //获取word里所有表格
  10463. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10464. //获取所填表格的序数
  10465. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10466. var rowStart = tableOne.Rows[0]; //获取第1行
  10467. if (_dto.Language == 0)
  10468. {
  10469. //循环赋值
  10470. for (int i = 0; i < DcList.Count; i++)
  10471. {
  10472. builder.MoveToCell(0, i + 1, 0, 0);
  10473. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  10474. builder.MoveToCell(0, i + 1, 1, 0);
  10475. int sex = DcList[i].Sex;
  10476. string sexStr = string.Empty;
  10477. if (sex == 0) sexStr = "男";
  10478. else if (sex == 1) sexStr = "女";
  10479. else sexStr = "未设置";
  10480. builder.Write(sexStr);
  10481. builder.MoveToCell(0, i + 1, 2, 0);
  10482. string birthDay = DcList[i].BirthDay;
  10483. string birthDayStr = string.Empty;
  10484. if (!string.IsNullOrEmpty(birthDay))
  10485. {
  10486. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  10487. }
  10488. builder.Write(birthDayStr);
  10489. builder.MoveToCell(0, i + 1, 3, 0);
  10490. string company = "";
  10491. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10492. {
  10493. company = DcList[i].CompanyFullName.ToString();
  10494. }
  10495. builder.Write(company);
  10496. builder.MoveToCell(0, i + 1, 4, 0);
  10497. builder.Write(DcList[i].Job);
  10498. }
  10499. }
  10500. else if (_dto.Language == 1)
  10501. {
  10502. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  10503. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  10504. List<string> transArrayStr = new List<string>();
  10505. string transStrRes1 = "";
  10506. for (int i = 0; i < DcList.Count; i++)
  10507. {
  10508. var dc = DcList[i];
  10509. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  10510. if (dc.Job.Equals("暂无")) dc.Job = "-";
  10511. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  10512. if (DcList.Count - 1 == i) transStrRes1 += str1;
  10513. else transStrRes1 += $"{str1}|";
  10514. }
  10515. //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";
  10516. string transStrRes = "";
  10517. if (transStrRes1.Length > 0 )
  10518. {
  10519. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  10520. }
  10521. //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
  10522. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  10523. //List<string> transArray = new List<string> { };
  10524. List<TranslateInfo> transArray = new List<TranslateInfo>();
  10525. if (transStrRes.Contains("|"))
  10526. {
  10527. string[] transArray1 = transStrRes.Split('|');
  10528. if (transArray1.Length > 0)
  10529. {
  10530. foreach (var item in transArray1)
  10531. {
  10532. if (item.Contains("&"))
  10533. {
  10534. string[] transArray2 = item.Split('&');
  10535. int index = 0;
  10536. string companyName = "", job = "";
  10537. if (transArray2.Length > 0)
  10538. {
  10539. bool success = int.TryParse(transArray2[0].Trim(), out index);
  10540. if (1 < transArray2.Length) companyName = transArray2[1];
  10541. if (2 < transArray2.Length) job = transArray2[2];
  10542. }
  10543. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  10544. }
  10545. }
  10546. }
  10547. }
  10548. //循环赋值
  10549. for (int i = 0; i < DcList.Count; i++)
  10550. {
  10551. string PYName = "";
  10552. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  10553. {
  10554. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  10555. string PY_First = DcList[i].Pinyin.Split('/')[1];
  10556. PYName = PY_First + " " + PY_Last;
  10557. }
  10558. else
  10559. {
  10560. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  10561. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  10562. PYName = PY_First + " " + PY_Last;
  10563. }
  10564. builder.MoveToCell(0, i + 1, 0, 0);
  10565. builder.Write(PYName);
  10566. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  10567. builder.MoveToCell(0, i + 1, 1, 0);
  10568. builder.Write(sex);
  10569. DateTime birthDt;
  10570. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  10571. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  10572. builder.MoveToCell(0, i + 1, 2, 0);
  10573. builder.Write(birthday);
  10574. string company = string.Empty,job = string.Empty;
  10575. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  10576. if (dcTransInfo != null)
  10577. {
  10578. company = dcTransInfo.CompanyName;
  10579. job = dcTransInfo.Job;
  10580. }
  10581. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10582. {
  10583. //查询对照表
  10584. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  10585. if (tempCec != null)
  10586. {
  10587. company = tempCec.enName;
  10588. }
  10589. //翻译
  10590. else
  10591. {
  10592. }
  10593. }
  10594. builder.MoveToCell(0, i + 1, 3, 0);
  10595. builder.Write(company);
  10596. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  10597. {
  10598. //查询对照表
  10599. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  10600. if (tempPec != null)
  10601. {
  10602. job = tempPec.enName;
  10603. }
  10604. //翻译
  10605. else
  10606. {
  10607. }
  10608. }
  10609. builder.MoveToCell(0, i + 1, 4, 0);
  10610. builder.Write(job);
  10611. }
  10612. }
  10613. //删除多余行
  10614. while (tableOne.Rows.Count > DcList.Count + 1)
  10615. {
  10616. tableOne.Rows.RemoveAt(DcList.Count + 1);
  10617. }
  10618. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  10619. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  10620. doc.Save(fileDir);
  10621. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  10622. return Ok(JsonView(true, "操作成功!", Url));
  10623. }
  10624. private class TranslateInfo
  10625. {
  10626. public int Index { get; set; }
  10627. public string CompanyName { get; set; }
  10628. public string Job { get; set; }
  10629. }
  10630. #endregion
  10631. #region 团组倒推表
  10632. /// <summary>
  10633. /// 倒推表基础数据
  10634. /// Init
  10635. /// </summary>
  10636. /// <param name="dto"></param>
  10637. /// <returns></returns>
  10638. [HttpPost]
  10639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10640. public async Task<IActionResult> PostInvertedListInit()
  10641. {
  10642. var viewData = await _invertedListRep._Init();
  10643. if (viewData.Code != 0)
  10644. {
  10645. return Ok(JsonView(false, viewData.Msg));
  10646. }
  10647. return Ok(JsonView(viewData.Data));
  10648. }
  10649. /// <summary>
  10650. /// 倒推表
  10651. /// Info
  10652. /// </summary>
  10653. /// <param name="dto"></param>
  10654. /// <returns></returns>
  10655. [HttpPost]
  10656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10657. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  10658. {
  10659. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  10660. if (viewData.Code != 0)
  10661. {
  10662. return Ok(JsonView(false, viewData.Msg));
  10663. }
  10664. return Ok(JsonView(viewData.Data));
  10665. }
  10666. /// <summary>
  10667. /// 倒推表
  10668. /// Create
  10669. /// </summary>
  10670. /// <param name="dto"></param>
  10671. /// <returns></returns>
  10672. [HttpPost]
  10673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10674. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  10675. {
  10676. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  10677. if (viewData.Code != 0)
  10678. {
  10679. return Ok(JsonView(false, viewData.Msg));
  10680. }
  10681. return Ok(JsonView(viewData.Data));
  10682. }
  10683. /// <summary>
  10684. /// 倒推表
  10685. /// Update
  10686. /// </summary>
  10687. /// <param name="dto"></param>
  10688. /// <returns></returns>
  10689. [HttpPost]
  10690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10691. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  10692. {
  10693. var viewData = await _invertedListRep._Update(dto);
  10694. if (viewData.Code != 0)
  10695. {
  10696. return Ok(JsonView(false, viewData.Msg));
  10697. }
  10698. return Ok(JsonView(viewData.Data));
  10699. }
  10700. /// <summary>
  10701. /// 倒推表
  10702. /// File Download
  10703. /// </summary>
  10704. /// <param name="dto"></param>
  10705. /// <returns></returns>
  10706. [HttpPost]
  10707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10708. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  10709. {
  10710. var info2 = await _invertedListRep._Info(1, dto.DiId);
  10711. if (info2.Code != 0)
  10712. {
  10713. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  10714. }
  10715. var info1 = info2.Data as InvertedListInfoView;
  10716. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  10717. string teamName = "";
  10718. if (info != null) teamName = info.TeamName;
  10719. //载入模板
  10720. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  10721. DocumentBuilder builder = new DocumentBuilder(doc);
  10722. //利用键值对存放数据
  10723. Dictionary<string, string> dic = new Dictionary<string, string>();
  10724. dic.Add("TeamName", teamName);
  10725. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  10726. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  10727. dic.Add("BPRemark", info1.ApprovalDataRemark);
  10728. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  10729. dic.Add("SQRemark", info1.ApprovalRemark);
  10730. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  10731. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  10732. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  10733. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  10734. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  10735. dic.Add("QZRemark", info1.VisaInformationRemark);
  10736. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  10737. dic.Add("SQQZRemark", info1.SendVisaRemark);
  10738. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  10739. dic.Add("CQRemark", info1.IssueVisaRemark);
  10740. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  10741. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  10742. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  10743. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  10744. #region 填充word模板书签内容
  10745. foreach (var key in dic.Keys)
  10746. {
  10747. builder.MoveToBookmark(key);
  10748. builder.Write(dic[key]);
  10749. }
  10750. #endregion
  10751. var fileDir = AppSettingsHelper.Get("WordBasePath");
  10752. string fileName = $"{teamName}团出行准备流程表.doc";
  10753. string filePath = fileDir + $@"InvertedList/{fileName}";
  10754. doc.Save(filePath);
  10755. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  10756. return Ok(JsonView(true, "操作成功!", Url));
  10757. }
  10758. #endregion
  10759. #region 三公签证费用(签证费、代办费)
  10760. /// <summary>
  10761. /// 三公签证费用(签证费、代办费)
  10762. /// List
  10763. /// </summary>
  10764. /// <returns></returns>
  10765. [HttpPost]
  10766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10767. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  10768. {
  10769. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  10770. if (_view.Code != 0)
  10771. {
  10772. return Ok(JsonView(false, _view.Msg));
  10773. }
  10774. return Ok(JsonView(true, "操作成功!", _view.Data));
  10775. }
  10776. /// <summary>
  10777. /// 三公签证费用(签证费、代办费)
  10778. /// Add Or Update
  10779. /// </summary>
  10780. /// <returns></returns>
  10781. [HttpPost]
  10782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10783. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  10784. {
  10785. var _view = await _visaFeeInfoRep._Update(_dto);
  10786. if (_view.Code != 0)
  10787. {
  10788. return Ok(JsonView(false, _view.Msg));
  10789. }
  10790. return Ok(JsonView(true, _view.Msg));
  10791. }
  10792. #endregion
  10793. #region 酒店询价
  10794. /// <summary>
  10795. /// 酒店询价
  10796. /// Init
  10797. /// </summary>
  10798. /// <param name="dto"></param>
  10799. /// <returns></returns>
  10800. [HttpPost]
  10801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10802. public async Task<IActionResult> PostHotelInquiryInit()
  10803. {
  10804. var res = await _hotelInquiryRep._Init();
  10805. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10806. return Ok(JsonView(true, res.Msg, res.Data));
  10807. }
  10808. /// <summary>
  10809. /// 酒店询价
  10810. /// page Item
  10811. /// </summary>
  10812. /// <param name="_dto"></param>
  10813. /// <returns></returns>
  10814. [HttpPost]
  10815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10816. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  10817. {
  10818. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  10819. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10820. var view = res.Data as PageDataViewBase;
  10821. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  10822. }
  10823. /// <summary>
  10824. /// 酒店询价
  10825. /// info
  10826. /// </summary>
  10827. /// <param name="_dto"></param>
  10828. /// <returns></returns>
  10829. [HttpPost]
  10830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10831. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  10832. {
  10833. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  10834. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10835. return Ok(JsonView(true, res.Msg, res.Data));
  10836. }
  10837. /// <summary>
  10838. /// 酒店询价
  10839. /// Add Or Edit
  10840. /// </summary>
  10841. /// <param name="_dto"></param>
  10842. /// <returns></returns>
  10843. [HttpPost]
  10844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10845. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  10846. {
  10847. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  10848. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10849. return Ok(JsonView(true, res.Msg, res.Data));
  10850. }
  10851. /// <summary>
  10852. /// 酒店询价
  10853. /// Del
  10854. /// </summary>
  10855. /// <param name="_dto"></param>
  10856. /// <returns></returns>
  10857. [HttpPost]
  10858. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10859. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  10860. {
  10861. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  10862. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10863. return Ok(JsonView(true, res.Msg, res.Data));
  10864. }
  10865. #endregion
  10866. #region 下载匹配op行程单
  10867. /// <summary>
  10868. /// 匹配op行程单
  10869. /// Init
  10870. /// </summary>
  10871. /// <param name="dto">团组列表请求dto</param>
  10872. /// <returns></returns>
  10873. [HttpPost]
  10874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10875. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  10876. {
  10877. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10878. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10879. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  10880. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  10881. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  10882. .Where(it => it.IsDel == 0)
  10883. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  10884. .OrderByDescending(it => it.CreateUserId)
  10885. .ToList();
  10886. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  10887. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  10888. var diids = groupInfos.Select(it => it.Id).ToList();
  10889. List<string> countrys = new List<string>();
  10890. foreach (var item in country)
  10891. {
  10892. var data = _groupRepository.FormartTeamName(item);
  10893. var dataArray = _groupRepository.GroupSplitCountry(data);
  10894. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  10895. }
  10896. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  10897. List<string> areaArray = new List<string>(); //GetGroupCityLine
  10898. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  10899. foreach (var item in areaItem)
  10900. {
  10901. string areaStr = item.Value;
  10902. if (!string.IsNullOrEmpty(areaStr))
  10903. {
  10904. string[] str1 = areaStr.Split("-");
  10905. if (str1.Length > 0)
  10906. {
  10907. areaArray.AddRange(str1);
  10908. }
  10909. }
  10910. }
  10911. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  10912. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  10913. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  10914. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  10915. .ToList();
  10916. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  10917. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  10918. .Where(it => countriesIds.Contains(it.Id))
  10919. .Select(it => new { it.Id, Name = it.Name_CN })
  10920. .ToList();
  10921. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  10922. .Select(it => it.TeamName).ToList();
  10923. stopwatch.Stop();
  10924. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  10925. }
  10926. ///// <summary>
  10927. ///// 匹配op行程单
  10928. ///// Init 查询区域数据
  10929. ///// </summary>
  10930. ///// <param name="dto">团组列表请求dto</param>
  10931. ///// <returns></returns>
  10932. //[HttpPost]
  10933. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10934. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  10935. //{
  10936. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10937. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  10938. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  10939. // if (string.IsNullOrEmpty(countriesDataStr))
  10940. // {
  10941. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  10942. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  10943. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  10944. // }
  10945. // else
  10946. // {
  10947. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  10948. // }
  10949. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  10950. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  10951. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  10952. // List<dynamic> childList = new List<dynamic>();
  10953. // int parentId = dto.CountriesId;
  10954. // if (provinceData.Count > 1)
  10955. // {
  10956. // foreach (var item1 in provinceData)
  10957. // {
  10958. // List<dynamic> childList1 = new List<dynamic>();
  10959. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  10960. // foreach (var item2 in citiesData1)
  10961. // {
  10962. // List<dynamic> childList2 = new List<dynamic>();
  10963. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10964. // foreach (var item3 in countiesData1)
  10965. // {
  10966. // childList2.Add(new
  10967. // {
  10968. // id = item3.Id,
  10969. // parentId = item2.Id,
  10970. // level = "district",
  10971. // name = item3.Name_CN,
  10972. // });
  10973. // }
  10974. // childList1.Add(new
  10975. // {
  10976. // id = item2.Id,
  10977. // parentId = item1.Id,
  10978. // level = "city",
  10979. // name = item2.Name_CN,
  10980. // childList = childList2
  10981. // });
  10982. // }
  10983. // childList.Add(new
  10984. // {
  10985. // id = item1.Id,
  10986. // parentId = parentId,
  10987. // level = "province",
  10988. // name = item1.Name_CN,
  10989. // childList = childList1
  10990. // });
  10991. // }
  10992. // //城市
  10993. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  10994. // foreach (var item2 in citiesData2)
  10995. // {
  10996. // List<dynamic> childList22 = new List<dynamic>();
  10997. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10998. // foreach (var item3 in countiesData1)
  10999. // {
  11000. // childList22.Add(new
  11001. // {
  11002. // id = item3.Id,
  11003. // parentId = item2.Id,
  11004. // level = "district",
  11005. // name = item3.Name_CN,
  11006. // });
  11007. // }
  11008. // childList.Add(new
  11009. // {
  11010. // id = item2.Id,
  11011. // parentId = parentId,
  11012. // level = "city",
  11013. // name = item2.Name_CN,
  11014. // childList = childList22
  11015. // });
  11016. // }
  11017. // }
  11018. // else
  11019. // {
  11020. // foreach (var item2 in citiesData)
  11021. // {
  11022. // string cname = item2.Name_CN;
  11023. // List<dynamic> childList1 = new List<dynamic>();
  11024. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11025. // foreach (var item3 in countiesData1)
  11026. // {
  11027. // childList1.Add(new
  11028. // {
  11029. // Id = item3.Id,
  11030. // parentId = item2.Id,
  11031. // level = "district",
  11032. // name = item3.Name_CN
  11033. // });
  11034. // }
  11035. // childList.Add(new
  11036. // {
  11037. // id = item2.Id,
  11038. // parentId = parentId,
  11039. // level = "city",
  11040. // name = item2.Name_CN,
  11041. // childList = childList1
  11042. // });
  11043. // }
  11044. // }
  11045. // stopwatch.Stop();
  11046. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  11047. //}
  11048. /// <summary>
  11049. /// 匹配op行程单
  11050. /// 接团信息列表 Page
  11051. /// </summary>
  11052. /// <param name="dto">团组列表请求dto</param>
  11053. /// <returns></returns>
  11054. [HttpPost]
  11055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11056. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  11057. {
  11058. var swatch = new Stopwatch();
  11059. swatch.Start();
  11060. #region 参数验证
  11061. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11062. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11063. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11064. #region 页面操作权限验证
  11065. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11066. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  11067. #endregion
  11068. #endregion
  11069. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11070. {
  11071. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  11072. string sqlWhere = "";
  11073. if (!string.IsNullOrEmpty(dto.Country))
  11074. {
  11075. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  11076. }
  11077. if (!string.IsNullOrEmpty(dto.Area))
  11078. {
  11079. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  11080. }
  11081. if (!string.IsNullOrEmpty(dto.TeamName))
  11082. {
  11083. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  11084. }
  11085. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  11086. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  11087. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  11088. swatch.Stop();
  11089. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  11090. }
  11091. else
  11092. {
  11093. return Ok(JsonView(false, "查询失败"));
  11094. }
  11095. }
  11096. /// <summary>
  11097. /// 匹配op行程单
  11098. /// 行程单下载
  11099. /// </summary>
  11100. /// <param name="dto">团组列表请求dto</param>
  11101. /// <returns></returns>
  11102. [HttpPost]
  11103. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11104. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  11105. {
  11106. #region 参数验证
  11107. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11108. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11109. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11110. #region 页面操作权限验证
  11111. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11112. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  11113. #endregion
  11114. #endregion
  11115. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11116. {
  11117. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  11118. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  11119. }
  11120. else
  11121. {
  11122. return Ok(JsonView(false, "下载失败!"));
  11123. }
  11124. }
  11125. #endregion
  11126. #region 国家信息 数据 注释
  11127. //[HttpPost]
  11128. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  11129. //{
  11130. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  11131. // foreach (var item in dto)
  11132. // {
  11133. // infos.Add(new Grp_GroupsTaskAssignment()
  11134. // {
  11135. // DIId = item,
  11136. // CTId = 82,
  11137. // UId = 248,
  11138. // IsEnable = 1,
  11139. // CreateUserId = 233,
  11140. // CreateTime = DateTime.Now,
  11141. // IsDel = 0
  11142. // });
  11143. // infos.Add(new Grp_GroupsTaskAssignment()
  11144. // {
  11145. // DIId = item,
  11146. // CTId = 82,
  11147. // UId = 286,
  11148. // IsEnable = 1,
  11149. // CreateUserId = 233,
  11150. // CreateTime = DateTime.Now,
  11151. // IsDel = 0
  11152. // });
  11153. // }
  11154. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  11155. // return Ok("操作成功");
  11156. //}
  11157. //public class paramJsonDto
  11158. //{
  11159. // public List<CountriesInfo> str { get; set; }
  11160. //}
  11161. //[HttpPost]
  11162. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  11163. //{
  11164. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  11165. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  11166. // List<Sys_Cities> cities = new List<Sys_Cities>();
  11167. // List<Sys_Cities> districts = new List<Sys_Cities>();
  11168. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11169. // _sqlSugar.BeginTran();
  11170. // int countitiesIndex = 0;
  11171. // foreach (var item in dto.str)
  11172. // {
  11173. // dynamic data = item.c;
  11174. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  11175. // if (data != null)
  11176. // {
  11177. // countitiesIndex++;
  11178. // foreach (var item1 in data)
  11179. // {
  11180. // string cnname = item1.cn;
  11181. // string enname = item1.en;
  11182. // Sys_Cities provinceInfo = new Sys_Cities()
  11183. // {
  11184. // CountriesId = countriesId,
  11185. // Name_CN = cnname,
  11186. // Name_EN = enname,
  11187. // ParentId = 0,
  11188. // IsCapital = 1,
  11189. // CreateUserId = 208,
  11190. // CreateTime = DateTime.Now,
  11191. // IsDel = 0
  11192. // };
  11193. // if (item1.lv == "province") //省份
  11194. // {
  11195. // provinceInfo.Level = 1;
  11196. // int provinceId = 0;
  11197. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  11198. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  11199. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  11200. // var data1 = item1.c;
  11201. // foreach (var item2 in data1)
  11202. // {
  11203. // if (item2.lv == "city")
  11204. // {
  11205. // string citycnname = item2.cn;
  11206. // string cityenname = item2.en;
  11207. // Sys_Cities cityInfo = new Sys_Cities()
  11208. // {
  11209. // CountriesId = countriesId,
  11210. // ParentId = provinceId,
  11211. // Level = 2,
  11212. // Name_CN = citycnname,
  11213. // Name_EN = cityenname,
  11214. // IsCapital = 1,
  11215. // CreateUserId = 208,
  11216. // CreateTime = DateTime.Now,
  11217. // IsDel = 0
  11218. // };
  11219. // if (item2.c != null)
  11220. // {
  11221. // int cityId = 0;
  11222. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  11223. // if (citiesInfo != null) cityId = citiesInfo.Id;
  11224. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  11225. // foreach (var item3 in item2.c)
  11226. // {
  11227. // if (item3.lv == "district")
  11228. // {
  11229. // var districtInfo = new Sys_Cities()
  11230. // {
  11231. // CountriesId = countriesId,
  11232. // Name_CN = item3.cn,
  11233. // Name_EN = item3.en,
  11234. // Level = 3,
  11235. // ParentId = cityId,
  11236. // IsCapital = 1,
  11237. // CreateUserId = 208,
  11238. // CreateTime = DateTime.Now,
  11239. // IsDel = 0
  11240. // };
  11241. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  11242. // //{
  11243. // districts.Add(districtInfo);
  11244. // //}
  11245. // }
  11246. // }
  11247. // }
  11248. // else
  11249. // {
  11250. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  11251. // //{
  11252. // cities.Add(cityInfo);
  11253. // //}
  11254. // }
  11255. // }
  11256. // }
  11257. // }
  11258. // else if (item1.lv == "city")//城市
  11259. // {
  11260. // provinceInfo.Level = 2;
  11261. // if (item1.c != null)
  11262. // {
  11263. // int cityId = 0;
  11264. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  11265. // if (citiesInfo != null) cityId = citiesInfo.Id;
  11266. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  11267. // foreach (var item3 in item1.c)
  11268. // {
  11269. // if (item3.lv == "district")
  11270. // {
  11271. // var districtInfo = new Sys_Cities()
  11272. // {
  11273. // CountriesId = countriesId,
  11274. // Name_CN = item3.cn,
  11275. // Name_EN = item3.en,
  11276. // Level = 3,
  11277. // ParentId = cityId,
  11278. // IsCapital = 1,
  11279. // CreateUserId = 208,
  11280. // CreateTime = DateTime.Now,
  11281. // IsDel = 0
  11282. // };
  11283. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  11284. // //{
  11285. // districts.Add(districtInfo);
  11286. // //}
  11287. // }
  11288. // }
  11289. // }
  11290. // else
  11291. // {
  11292. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  11293. // //{
  11294. // cities.Add(provinceInfo);
  11295. // //}
  11296. // }
  11297. // }
  11298. // }
  11299. // }
  11300. // }
  11301. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  11302. // cities = cities.Distinct().ToList();
  11303. // districts = districts.Distinct().ToList();
  11304. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  11305. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  11306. // cities.AddRange(districts);
  11307. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  11308. // //_sqlSugar.RollbackTran();
  11309. // _sqlSugar.CommitTran();
  11310. // return Ok(JsonView(false, "操作成功!"));
  11311. //}
  11312. //[HttpPost]
  11313. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  11314. //{
  11315. // List<CountitiesInfo> infos = dto.MyProperty;
  11316. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  11317. // _sqlSugar.BeginTran();
  11318. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11319. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  11320. // foreach (var item in infos)
  11321. // {
  11322. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  11323. // if (countryInfo != null)
  11324. // {
  11325. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  11326. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  11327. // if (cityInfo1 != null)
  11328. // {
  11329. // cityInfo1.IsCapital = 0;
  11330. // cityInfos.Add(cityInfo1);
  11331. // }
  11332. // }
  11333. // }
  11334. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  11335. // .UpdateColumns(it => it.IsCapital)
  11336. // .WhereColumns(it => it.Id)
  11337. // .ExecuteCommand();
  11338. // //_sqlSugar.RollbackTran();
  11339. // _sqlSugar.CommitTran();
  11340. // return Ok(JsonView(false, "操作成功!"));
  11341. //}
  11342. //public class CounrtiesDto
  11343. //{
  11344. // public List<CountitiesInfo> MyProperty { get; set; }
  11345. //}
  11346. //public class CountitiesInfo
  11347. //{
  11348. // /// <summary>
  11349. // /// 圣约翰
  11350. // /// </summary>
  11351. // public string capital_name_chinese { get; set; }
  11352. // /// <summary>
  11353. // ///
  11354. // /// </summary>
  11355. // public string capital_name { get; set; }
  11356. // /// <summary>
  11357. // ///
  11358. // /// </summary>
  11359. // public string country_type { get; set; }
  11360. // /// <summary>
  11361. // /// 安提瓜和巴布达
  11362. // /// </summary>
  11363. // public string country_name_chinese { get; set; }
  11364. // /// <summary>
  11365. // /// 安提瓜和巴布达
  11366. // /// </summary>
  11367. // public string country_name_chinese_short { get; set; }
  11368. // /// <summary>
  11369. // /// 安提瓜和巴布达
  11370. // /// </summary>
  11371. // public string country_name_chinese_UN { get; set; }
  11372. // /// <summary>
  11373. // ///
  11374. // /// </summary>
  11375. // public string country_name_english_abbreviation { get; set; }
  11376. // /// <summary>
  11377. // ///
  11378. // /// </summary>
  11379. // public string country_name_english_formal { get; set; }
  11380. // /// <summary>
  11381. // ///
  11382. // /// </summary>
  11383. // public string country_name_english_UN { get; set; }
  11384. // /// <summary>
  11385. // ///
  11386. // /// </summary>
  11387. // public string continent_name { get; set; }
  11388. // /// <summary>
  11389. // ///
  11390. // /// </summary>
  11391. // public string subregion_name { get; set; }
  11392. // /// <summary>
  11393. // ///
  11394. // /// </summary>
  11395. // public string country_code2 { get; set; }
  11396. // /// <summary>
  11397. // ///
  11398. // /// </summary>
  11399. // public string country_code3 { get; set; }
  11400. // /// <summary>
  11401. // ///
  11402. // /// </summary>
  11403. // public string phone_code { get; set; }
  11404. //}
  11405. //public class CountriesInfo : BasicInfo
  11406. //{
  11407. // public List<CitiesInfo> c { get; set; }
  11408. //}
  11409. //public class CitiesInfo : BasicInfo
  11410. //{
  11411. // public List<AreaInfo> c { get; set; }
  11412. //}
  11413. //public class AreaInfo : BasicInfo
  11414. //{
  11415. // public List<AreaInfo> c { get; set; }
  11416. //}
  11417. //public class BasicInfo
  11418. //{
  11419. // public string code { get; set; }
  11420. // public string cn { get; set; }
  11421. // public string lv { get; set; }
  11422. // public string en { get; set; }
  11423. //}
  11424. #endregion
  11425. #region 查看邀请方
  11426. /// <summary>
  11427. /// 查看邀请方
  11428. /// 邀请方信息 Init
  11429. /// </summary>
  11430. /// <param name="dto"></param>
  11431. /// <returns></returns>
  11432. [HttpPost]
  11433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11434. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  11435. {
  11436. string sqlWhere = string.Empty;
  11437. if (!string.IsNullOrEmpty(dto.Search))
  11438. {
  11439. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  11440. }
  11441. string sql = string.Format($@"Select
  11442. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  11443. Id,
  11444. UnitName
  11445. From Res_InvitationOfficialActivityData
  11446. Where IsDel = 0
  11447. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  11448. RefAsync<int> total = 0;
  11449. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11450. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  11451. }
  11452. /// <summary>
  11453. /// 查看邀请方
  11454. /// 国家信息 Init
  11455. /// </summary>
  11456. /// <param name="dto"></param>
  11457. /// <returns></returns>
  11458. [HttpPost]
  11459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11460. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  11461. {
  11462. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  11463. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  11464. var diids = groupInfos.Select(it => it.Id).ToList();
  11465. List<string> countrys = new List<string>();
  11466. foreach (var item in country)
  11467. {
  11468. var data = _groupRepository.FormartTeamName(item);
  11469. var dataArray = _groupRepository.GroupSplitCountry(data);
  11470. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  11471. }
  11472. countrys = countrys.Distinct().ToList();
  11473. for (int i = 0; i < countrys.Count; i++)
  11474. {
  11475. string item = countrys[i];
  11476. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  11477. {
  11478. countrys.Remove(item);
  11479. i--;
  11480. }
  11481. }
  11482. RefAsync<int> total = 0;
  11483. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  11484. .Where(it => countrys.Contains(it.Name_CN))
  11485. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  11486. .Select(it => new { id = it.Id, name = it.Name_CN })
  11487. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11488. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  11489. }
  11490. /// <summary>
  11491. /// 查看邀请方
  11492. /// 城市信息 Init
  11493. /// </summary>
  11494. /// <param name="dto"></param>
  11495. /// <returns></returns>
  11496. [HttpPost]
  11497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11498. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  11499. {
  11500. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  11501. RefAsync<int> total = 0;
  11502. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  11503. .Where(it => it.CountriesId == dto.CountiesId)
  11504. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  11505. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  11506. .Select(it => new { id = it.Id, name = it.Name_CN })
  11507. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11508. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  11509. }
  11510. /// <summary>
  11511. /// 查看邀请方
  11512. /// 团组名称 Init
  11513. /// </summary>
  11514. /// <param name="dto"></param>
  11515. /// <returns></returns>
  11516. [HttpPost]
  11517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11518. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  11519. {
  11520. var watch = new Stopwatch();
  11521. watch.Start();
  11522. RefAsync<int> total = 0;
  11523. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  11524. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  11525. .Where((oa, di) => oa.IsDel == 0)
  11526. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  11527. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  11528. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  11529. .Distinct()
  11530. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11531. watch.Stop();
  11532. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  11533. }
  11534. /// <summary>
  11535. /// 查看邀请方
  11536. /// 团组 & 邀请方信息
  11537. /// </summary>
  11538. /// <param name="dto"></param>
  11539. /// <returns></returns>
  11540. [HttpPost]
  11541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11542. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  11543. {
  11544. var watch = new Stopwatch();
  11545. watch.Start();
  11546. RefAsync<int> total = 0;
  11547. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  11548. .AS("Grp_DelegationInfo")
  11549. .Includes(x => x.InvitingInfos)
  11550. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  11551. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  11552. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  11553. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  11554. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  11555. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  11556. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11557. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  11558. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  11559. infos.ForEach(x =>
  11560. {
  11561. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  11562. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  11563. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  11564. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  11565. });
  11566. watch.Stop();
  11567. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  11568. }
  11569. #endregion
  11570. #region 报批行程
  11571. /// <summary>
  11572. /// 报批行程初始化
  11573. /// </summary>
  11574. /// <param name="dto"></param>
  11575. /// <returns></returns>
  11576. [HttpPost]
  11577. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  11578. {
  11579. const int chiNumber = 5;
  11580. var jw = JsonView(false);
  11581. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  11582. var group = groupList.First();
  11583. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11584. group = groupList.First(x => x.Id == diid);
  11585. if (group == null)
  11586. {
  11587. jw.Msg = "暂无团组!";
  11588. return Ok(jw);
  11589. }
  11590. var data = new
  11591. {
  11592. groupList = groupList.Select(x => new
  11593. {
  11594. x.TeamName,
  11595. x.Id
  11596. }),
  11597. content = new ArrayList(),
  11598. groupInfo = new
  11599. {
  11600. group.VisitDays,
  11601. group.TourCode,
  11602. group.VisitPNumber,
  11603. group.TeamName,
  11604. group.Id,
  11605. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  11606. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  11607. },
  11608. };
  11609. var resultArr = new ArrayList();
  11610. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  11611. if (content.Count == 0)
  11612. {
  11613. var stay = "-";
  11614. var cityPath = "-";
  11615. //添加城市路径以及住宿地
  11616. //黑屏代码数据
  11617. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  11618. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  11619. {
  11620. jw = JsonView(true, "黑屏代码有误!", data);
  11621. return Ok(jw);
  11622. }
  11623. foreach (DataRow row in dtBlack.Rows)
  11624. {
  11625. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11626. {
  11627. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  11628. return Ok(jw);
  11629. }
  11630. }
  11631. //黑屏代码获取时间区间
  11632. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  11633. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11634. _sqlSugar.BeginTran();
  11635. for (int i = 0; i < timeArr.Count; i++)
  11636. {
  11637. stay = "-";
  11638. cityPath = "-";
  11639. DateTime NewData = DateTime.Parse(timeArr[i]);
  11640. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  11641. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  11642. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  11643. if (tbSelect.Length > 0)
  11644. {
  11645. List<string> threeCodeStr = new List<string>();
  11646. foreach (var item in tbSelect)
  11647. {
  11648. var threeCode = item["Three"].ToString() ?? "";
  11649. if (threeCode.Length == 6)
  11650. {
  11651. var start = threeCode.Substring(0, 3);
  11652. var end = threeCode.Substring(3, 3);
  11653. if (threeCodeStr.Count == 0)
  11654. {
  11655. threeCodeStr.Add(start);
  11656. threeCodeStr.Add(end);
  11657. }
  11658. else
  11659. {
  11660. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  11661. {
  11662. threeCodeStr.Add(end);
  11663. }
  11664. else
  11665. {
  11666. threeCodeStr.Add(start);
  11667. threeCodeStr.Add(end);
  11668. }
  11669. }
  11670. }
  11671. }
  11672. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  11673. var last = threeCodeStr.Last();
  11674. foreach (var item in threeCodeStr)
  11675. {
  11676. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  11677. if (item.Equals(last))
  11678. {
  11679. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  11680. }
  11681. }
  11682. cityPath = cityPath.Trim('-');
  11683. }
  11684. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  11685. appro.Diid = diid ?? -1;
  11686. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  11687. appro.Id = thisId;
  11688. appro.CreateUserId = dto.UserId;
  11689. appro.CreateTime = DateTime.Now;
  11690. content.Add(appro);
  11691. }
  11692. _sqlSugar.CommitTran();
  11693. }
  11694. foreach (var x in content)
  11695. {
  11696. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  11697. if (chiList.Count < chiNumber)
  11698. {
  11699. for (int i = chiList.Count; i < chiNumber; i++)
  11700. {
  11701. chiList.Add(new Grp_ApprovalTravelDetails());
  11702. }
  11703. }
  11704. resultArr.Add(new
  11705. {
  11706. x.Id,
  11707. x.Date,
  11708. x.Diid,
  11709. chiList = chiList.Select(x1 => new
  11710. {
  11711. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  11712. x1.Details,
  11713. x1.ParentId,
  11714. x1.Id
  11715. })
  11716. });
  11717. }
  11718. data = data with
  11719. {
  11720. content = resultArr,
  11721. };
  11722. jw = JsonView(true, "获取成功!", data);
  11723. return Ok(jw);
  11724. }
  11725. /// <summary>
  11726. /// 报批行程删除
  11727. /// </summary>
  11728. /// <param name="dto"></param>
  11729. /// <returns></returns>
  11730. [HttpPost]
  11731. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  11732. {
  11733. var jw = JsonView(false);
  11734. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11735. if (group == null)
  11736. {
  11737. jw.Msg = "团组参数有误!";
  11738. return Ok(jw);
  11739. }
  11740. try
  11741. {
  11742. _sqlSugar.BeginTran();
  11743. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  11744. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  11745. {
  11746. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11747. DeleteUserId = dto.uesrId,
  11748. IsDel = 1
  11749. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  11750. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  11751. {
  11752. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11753. DeleteUserId = dto.uesrId,
  11754. IsDel = 1
  11755. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  11756. _sqlSugar.CommitTran();
  11757. jw = JsonView(true, "删除成功");
  11758. }
  11759. catch (Exception ex)
  11760. {
  11761. jw = JsonView(false, ex.Message);
  11762. }
  11763. return Ok(jw);
  11764. }
  11765. /// <summary>
  11766. /// 报批行程保存
  11767. /// </summary>
  11768. /// <param name="dto"></param>
  11769. /// <returns></returns>
  11770. [HttpPost]
  11771. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  11772. {
  11773. var jw = JsonView(false);
  11774. var Find = dto.Arr.Find(x => x.id == 0);
  11775. if (Find != null)
  11776. {
  11777. jw.Msg = "生成的ID为0!";
  11778. return Ok(jw);
  11779. }
  11780. foreach (var item in dto.Arr)
  11781. {
  11782. foreach (var chi in item.chiList)
  11783. {
  11784. if (chi.parentId == 0)
  11785. {
  11786. chi.parentId = item.id;
  11787. }
  11788. }
  11789. }
  11790. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  11791. _sqlSugar.BeginTran();
  11792. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  11793. {
  11794. var parentIds = dto.Arr.Select(x => x.id).ToList();
  11795. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  11796. {
  11797. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11798. DeleteUserId = dto.UserId,
  11799. IsDel = 1
  11800. }).ExecuteCommand();
  11801. }
  11802. try
  11803. {
  11804. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  11805. {
  11806. CreateTime = DateTime.Now,
  11807. CreateUserId = dto.UserId,
  11808. Details = x.details,
  11809. ParentId = x.parentId,
  11810. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11811. Remark = "",
  11812. IsDel = 0
  11813. }).ToList()).ExecuteCommand();
  11814. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  11815. {
  11816. Id = x.id,
  11817. Details = x.details,
  11818. ParentId = x.parentId,
  11819. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11820. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  11821. {
  11822. Details = x.Details,
  11823. ParentId = x.ParentId,
  11824. Time = x.Time
  11825. }).ExecuteCommand();
  11826. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  11827. {
  11828. Id = x.id,
  11829. Date = x.date,
  11830. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  11831. {
  11832. Date = x.Date
  11833. }).ExecuteCommand();
  11834. _sqlSugar.CommitTran();
  11835. jw = JsonView(true, "保存成功!");
  11836. }
  11837. catch (Exception ex)
  11838. {
  11839. _sqlSugar.RollbackTran();
  11840. jw = JsonView(false, "保存失败!" + ex.Message);
  11841. }
  11842. return Ok(jw);
  11843. }
  11844. /// <summary>
  11845. /// 报批行程生成
  11846. /// </summary>
  11847. /// <param name="dto"></param>
  11848. /// <returns></returns>
  11849. [HttpPost]
  11850. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  11851. {
  11852. var jw = JsonView(false);
  11853. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11854. if (group == null)
  11855. {
  11856. jw.Msg = "暂无该团组!";
  11857. return Ok(jw);
  11858. }
  11859. //黑屏代码数据
  11860. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  11861. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  11862. {
  11863. jw.Msg = "黑屏代码有误!";
  11864. return Ok(jw);
  11865. }
  11866. foreach (DataRow row in dtBlack.Rows)
  11867. {
  11868. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11869. {
  11870. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  11871. return Ok(jw);
  11872. }
  11873. }
  11874. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11875. var resultArr = new ArrayList();
  11876. if (officialActivitiesArr.Count == 0)
  11877. {
  11878. jw.Msg = "暂无公务出访信息!";
  11879. return Ok(jw);
  11880. }
  11881. try
  11882. {
  11883. _sqlSugar.BeginTran();
  11884. DeleteApprovalJourney(new
  11885. Domain.Dtos.Groups.DeleteApprovalJourney
  11886. {
  11887. Diid = dto.Diid,
  11888. uesrId = dto.Userid
  11889. });
  11890. var stay = "-";
  11891. var cityPath = "-";
  11892. //添加城市路径以及住宿地
  11893. //黑屏代码获取时间区间
  11894. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  11895. var empty = "【未收入该三字码!请机票同事录入】";
  11896. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11897. for (int i = 0; i < timeArr.Count; i++)
  11898. {
  11899. stay = "-";
  11900. cityPath = "-";
  11901. var chiarr = new List<Grp_ApprovalTravelDetails>();
  11902. DateTime NewData = DateTime.Parse(timeArr[i]);
  11903. 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();
  11904. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  11905. if (tbSelect.Length > 0)
  11906. {
  11907. List<string> threeCodeStr = new List<string>();
  11908. bool isTrade = false;
  11909. string trip = string.Empty;
  11910. var rowLast = tbSelect.Last();
  11911. var rowFirst = tbSelect.First();
  11912. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  11913. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  11914. var takeOffTime = DateTime.Parse(timeArr[i]);
  11915. var fallToTime = DateTime.Parse(timeArr[i]);
  11916. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  11917. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  11918. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  11919. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  11920. foreach (var item in tbSelect)
  11921. {
  11922. var start = string.Empty;
  11923. var end = string.Empty;
  11924. var threeCode = item["Three"].ToString() ?? "";
  11925. if (threeCode.Length == 6)
  11926. {
  11927. start = threeCode.Substring(0, 3);
  11928. end = threeCode.Substring(3, 3);
  11929. if (threeCodeStr.Count == 0)
  11930. {
  11931. threeCodeStr.Add(start);
  11932. threeCodeStr.Add(end);
  11933. }
  11934. else
  11935. {
  11936. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  11937. {
  11938. threeCodeStr.Add(end);
  11939. }
  11940. else
  11941. {
  11942. threeCodeStr.Add(start);
  11943. threeCodeStr.Add(end);
  11944. }
  11945. }
  11946. }
  11947. //处理机票信息
  11948. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  11949. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  11950. if (start_Object == null)
  11951. {
  11952. start_Object = new Res_ThreeCode()
  11953. {
  11954. AirPort = empty,
  11955. AirPort_En = empty,
  11956. City = empty,
  11957. Country = empty,
  11958. Four = empty,
  11959. Three = empty,
  11960. };
  11961. }
  11962. if (end_Object == null)
  11963. {
  11964. end_Object = new Res_ThreeCode()
  11965. {
  11966. AirPort = empty,
  11967. AirPort_En = empty,
  11968. City = empty,
  11969. Country = empty,
  11970. Four = empty,
  11971. Three = empty,
  11972. };
  11973. }
  11974. //机型判断
  11975. string airModel = item["AirModel"].ToString();
  11976. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  11977. string flightTime = item["FlightTime"].ToString();
  11978. if (flightTime!.Contains(":"))
  11979. {
  11980. flightTime = flightTime.Replace(":", "小时");
  11981. flightTime += "分钟";
  11982. }
  11983. if (flightTime.Contains("H"))
  11984. {
  11985. flightTime = flightTime.Replace("H", "小时");
  11986. }
  11987. if (flightTime.Contains("M"))
  11988. {
  11989. flightTime = flightTime.Replace("M", "分钟");
  11990. }
  11991. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  11992. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  11993. {
  11994. flightTime = flightDataTime.Hour > 0
  11995. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  11996. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  11997. ? flightDataTime.Minute.ToString() + "分钟" : "";
  11998. }
  11999. //航班号
  12000. string flightcode = item["Fliagtcode"].ToString();
  12001. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  12002. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  12003. if (aircompany == null)
  12004. {
  12005. aircompany = new Res_AirCompany
  12006. {
  12007. CnName = hsEmpty,
  12008. EnName = hsEmpty,
  12009. ShortCode = hsEmpty,
  12010. };
  12011. }
  12012. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  12013. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  12014. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  12015. if (isTrade)
  12016. {
  12017. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  12018. }
  12019. else
  12020. {
  12021. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  12022. }
  12023. }
  12024. chiarr.Add(new Grp_ApprovalTravelDetails
  12025. {
  12026. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  12027. CreateTime = DateTime.Now,
  12028. CreateUserId = dto.Userid,
  12029. ParentId = 0,
  12030. Details = trip
  12031. });
  12032. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12033. var last = threeCodeStr.Last();
  12034. foreach (var item in threeCodeStr)
  12035. {
  12036. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12037. if (item.Equals(last))
  12038. {
  12039. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12040. }
  12041. }
  12042. cityPath = cityPath.Trim('-');
  12043. }
  12044. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12045. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12046. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12047. appro.Diid = dto.Diid;
  12048. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12049. appro.Id = thisId;
  12050. appro.CreateUserId = dto.Userid;
  12051. appro.CreateTime = DateTime.Now;
  12052. foreach (var item in gwinfo)
  12053. {
  12054. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  12055. chi.Details = "拜访" + item.Client;
  12056. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  12057. {
  12058. chi.Details += "," + item.ReqSample;
  12059. }
  12060. chi.ParentId = thisId;
  12061. chi.Time = item.Time;
  12062. chiarr.Add(chi);
  12063. }
  12064. if (chiarr.Count < 5)
  12065. {
  12066. for (int j = chiarr.Count; j < 5; j++)
  12067. {
  12068. chiarr.Add(new
  12069. Grp_ApprovalTravelDetails());
  12070. }
  12071. }
  12072. resultArr.Add(new
  12073. {
  12074. appro.Id,
  12075. appro.Date,
  12076. appro.Diid,
  12077. chiList = chiarr.Select(x1 => new
  12078. {
  12079. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12080. x1.Details,
  12081. x1.ParentId,
  12082. x1.Id
  12083. })
  12084. });
  12085. }
  12086. _sqlSugar.CommitTran();
  12087. jw = JsonView(true, "生成成功!", resultArr);
  12088. }
  12089. catch (Exception ex)
  12090. {
  12091. jw.Code = 400;
  12092. jw.Msg = "生成失败!" + ex.Message;
  12093. }
  12094. return Ok(jw);
  12095. }
  12096. /// <summary>
  12097. /// 报批行程word导出
  12098. /// </summary>
  12099. /// <param name="dto"></param>
  12100. /// <returns></returns>
  12101. [HttpPost]
  12102. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  12103. {
  12104. var jw = JsonView(false);
  12105. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12106. if (group == null)
  12107. {
  12108. jw.Msg = "暂无该团组!";
  12109. return Ok(jw);
  12110. }
  12111. //模板路径
  12112. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  12113. //载入模板
  12114. Document doc = new Document(tempPath);
  12115. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12116. //获取所填表格的序数
  12117. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12118. Aspose.Words.Tables.Row titleRowClone = null;
  12119. Aspose.Words.Tables.Row CenterRowClone = null;
  12120. int index = 0;
  12121. int indexChi = 0;
  12122. int SetIndex = 0;
  12123. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  12124. //获取数据,放到datatable
  12125. foreach (var item in ApprovalTravelArr)
  12126. {
  12127. if (index > 0)
  12128. {
  12129. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  12130. tableOne.AppendChild(titleRowClone);
  12131. }
  12132. var textTime = item.Date;
  12133. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  12134. SetCells(tableOne, doc, SetIndex, 0, textTime);
  12135. SetIndex++;
  12136. if (ChiRep.Count > 0)
  12137. {
  12138. foreach (var itemChi in ChiRep)
  12139. {
  12140. var txtTime = itemChi.Time;
  12141. var txtDetail = itemChi.Details;
  12142. if (indexChi > 0)
  12143. {
  12144. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12145. tableOne.AppendChild(CenterRowClone);
  12146. }
  12147. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  12148. {
  12149. SetCells(tableOne, doc, SetIndex, 0, "");
  12150. SetCells(tableOne, doc, SetIndex, 1, "");
  12151. indexChi++;
  12152. SetIndex++;
  12153. break;
  12154. }
  12155. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  12156. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  12157. indexChi++;
  12158. SetIndex++;
  12159. }
  12160. }
  12161. else
  12162. {
  12163. if (indexChi > 0)
  12164. {
  12165. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12166. tableOne.AppendChild(CenterRowClone);
  12167. }
  12168. SetCells(tableOne, doc, SetIndex, 0, "");
  12169. SetCells(tableOne, doc, SetIndex, 1, "");
  12170. indexChi++;
  12171. SetIndex++;
  12172. }
  12173. index++;
  12174. }
  12175. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  12176. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12177. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12178. jw.Code = 200;
  12179. jw.Msg = "";
  12180. return Ok(jw);
  12181. }
  12182. private string intToString(int numberVal)
  12183. {
  12184. string numberval = numberVal.ToString();
  12185. Dictionary<char, string> Number = new Dictionary<char, string>();
  12186. Number.Add('1', "一");
  12187. Number.Add('2', "二");
  12188. Number.Add('3', "三");
  12189. Number.Add('4', "四");
  12190. Number.Add('5', "五");
  12191. Number.Add('6', "六");
  12192. Number.Add('7', "七");
  12193. Number.Add('8', "八");
  12194. Number.Add('9', "九");
  12195. string stringNumberVal = string.Empty;
  12196. for (int i = 0; i < numberval.Length; i++)
  12197. {
  12198. if (i == 0)
  12199. {
  12200. stringNumberVal += Number[numberval[i]];
  12201. }
  12202. else if (i >= 1)
  12203. {
  12204. if (numberval[i] == '0')
  12205. {
  12206. stringNumberVal = "十";
  12207. }
  12208. else
  12209. {
  12210. stringNumberVal += "十" + Number[numberval[i]];
  12211. }
  12212. }
  12213. }
  12214. return stringNumberVal;
  12215. }
  12216. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  12217. {
  12218. //获取table中的某个单元格,从0开始
  12219. Cell lshCell = table.Rows[rows].Cells[cells];
  12220. //将单元格中段落移除
  12221. foreach (Node item in lshCell.Paragraphs)
  12222. {
  12223. lshCell.Paragraphs.Remove(item);
  12224. }
  12225. if (val.Contains("\r\n"))
  12226. {
  12227. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  12228. foreach (var item in spArr)
  12229. {
  12230. //新建一个段落
  12231. Paragraph p = new Paragraph(doc);
  12232. var r = new Run(doc, item);
  12233. //把设置的值赋给之前新建的段落
  12234. p.AppendChild(r);
  12235. //将此段落加到单元格内
  12236. lshCell.AppendChild(p);
  12237. }
  12238. }
  12239. else
  12240. {
  12241. //新建一个段落
  12242. Paragraph p = new Paragraph(doc);
  12243. var r = new Run(doc, val);
  12244. //把设置的值赋给之前新建的段落
  12245. p.AppendChild(r);
  12246. //将此段落加到单元格内
  12247. lshCell.AppendChild(p);
  12248. }
  12249. }
  12250. [HttpPost]
  12251. public async Task<IActionResult> ServerHttp(string paramStr)
  12252. {
  12253. paramStr = paramStr.TrimEnd('\'');
  12254. paramStr = paramStr.TrimStart('\'');
  12255. JsonView jw = JsonView(false);
  12256. JObject param = JObject.Parse(paramStr);
  12257. if (!param.ContainsKey("url"))
  12258. {
  12259. jw.Msg = "url null";
  12260. return Ok(jw);
  12261. }
  12262. string url = param["url"]!.ToString();
  12263. var methon = "get";
  12264. Dictionary<string, string> bodyValues = null;
  12265. Dictionary<string, string> headValues = null;
  12266. if (param.ContainsKey("methon"))
  12267. {
  12268. methon = param["methon"]!.ToString();
  12269. }
  12270. if (param.ContainsKey("header"))
  12271. {
  12272. var header = param["header"]!.ToString();
  12273. JObject headerJobject = JObject.Parse(header);
  12274. headValues = new Dictionary<string, string>();
  12275. foreach (JProperty item in headerJobject.Properties())
  12276. {
  12277. var value = item.Value.ToString();
  12278. var head = item.Path;
  12279. headValues.Add(head, value);
  12280. }
  12281. }
  12282. if (param.ContainsKey("body"))
  12283. {
  12284. var body = param["body"]!.ToString();
  12285. bodyValues = new Dictionary<string, string>();
  12286. JObject bodyJobject = JObject.Parse(body);
  12287. foreach (JProperty item in bodyJobject.Properties())
  12288. {
  12289. var value = item.Value.ToString();
  12290. var head = item.Path;
  12291. bodyValues.Add(head, value);
  12292. }
  12293. }
  12294. HttpClient client = new HttpClient();
  12295. string responseString = string.Empty;
  12296. if (param.ContainsKey("isJson"))
  12297. {
  12298. }
  12299. if (headValues != null)
  12300. {
  12301. foreach (var item in headValues.Keys)
  12302. {
  12303. client.DefaultRequestHeaders.Add(item, headValues[item]);
  12304. }
  12305. }
  12306. try
  12307. {
  12308. if (methon == "get")
  12309. {
  12310. responseString = await client.GetStringAsync(url);
  12311. }
  12312. else if (methon == "post")
  12313. {
  12314. if (bodyValues == null)
  12315. {
  12316. jw.Msg = "methon post body null";
  12317. return Ok(jw);
  12318. }
  12319. // 数据转化为 key=val 格式
  12320. var content = new FormUrlEncodedContent(bodyValues);
  12321. var response = await client.PostAsync(url, content);
  12322. // 获取数据
  12323. responseString = await response.Content.ReadAsStringAsync();
  12324. }
  12325. else
  12326. {
  12327. jw.Msg = "methon error";
  12328. }
  12329. jw = JsonView(true, "success", responseString);
  12330. }
  12331. catch (Exception ex)
  12332. {
  12333. jw.Msg = "error " + ex.Message;
  12334. jw.Data = ex.StackTrace;
  12335. }
  12336. finally
  12337. {
  12338. client.Dispose();
  12339. }
  12340. return Ok(jw);
  12341. }
  12342. #endregion
  12343. // /// <summary>
  12344. // ///
  12345. // /// </summary>
  12346. // /// <param name="_dto"></param>
  12347. // /// <returns></returns>
  12348. // [HttpPost]
  12349. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12350. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  12351. // {
  12352. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  12353. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  12354. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  12355. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  12356. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  12357. // dic_psg.Add("客人", 974);
  12358. // dic_psg.Add("司机", 975);
  12359. // dic_psg.Add("导游", 976);
  12360. // dic_psg.Add("公司内部人员", 977);
  12361. // dic_psg.Add("司机/导游/公司内部人员", 978);
  12362. // foreach (var item in list_visa)
  12363. // {
  12364. // Grp_VisaInfo temp = new Grp_VisaInfo();
  12365. // temp.Id = item.Id;
  12366. // temp.DIId = item.DIId;
  12367. // temp.VisaClient = item.VisaClient;
  12368. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  12369. // temp.VisaCurrency = item.VisaCurrency;
  12370. // temp.IsThird = item.IsThird;
  12371. // if (dic_psg.ContainsKey(item.PassengerType))
  12372. // {
  12373. // temp.PassengerType = dic_psg[item.PassengerType];
  12374. // }
  12375. // else {
  12376. // temp.PassengerType = -1;
  12377. // }
  12378. // temp.VisaNumber = item.VisaNumber;
  12379. // temp.VisaFreeNumber = item.VisaFreeNumber;
  12380. // temp.CreateUserId = item.Operators;
  12381. // DateTime dt_ct;
  12382. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  12383. // if (b_ct)
  12384. // {
  12385. // temp.CreateTime = dt_ct;
  12386. // }
  12387. // else
  12388. // {
  12389. // temp.CreateTime = DateTime.Now;
  12390. // }
  12391. // temp.DeleteTime = "";
  12392. // temp.DeleteUserId = 0;
  12393. // temp.Remark = item.Remark;
  12394. // if (string.IsNullOrEmpty(temp.Remark)) {
  12395. // temp.Remark = "";
  12396. // }
  12397. // temp.IsDel = item.IsDel;
  12398. // temp.VisaDescription = item.VisaAttachment;
  12399. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  12400. //([Id]
  12401. // ,[DIId]
  12402. // ,[VisaClient]
  12403. // ,[VisaPrice]
  12404. // ,[VisaCurrency]
  12405. // ,[IsThird]
  12406. // ,[PassengerType]
  12407. // ,[VisaNumber]
  12408. // ,[VisaFreeNumber]
  12409. // ,[CreateUserId]
  12410. // ,[CreateTime]
  12411. // ,[DeleteTime]
  12412. // ,[DeleteUserId]
  12413. // ,[Remark]
  12414. // ,[IsDel]
  12415. // ,[visaDescription])
  12416. // VALUES
  12417. // ({0},{1},'{2}',{3},{4}
  12418. //,{5},{6},{7},{8},{9}
  12419. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  12420. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  12421. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  12422. //);
  12423. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  12424. // }
  12425. // return Ok(JsonView(true, "操作成功!"));
  12426. // }
  12427. /// <summary>
  12428. /// 123132123
  12429. /// </summary>
  12430. /// <param name="_dto"></param>
  12431. /// <returns></returns>
  12432. [HttpPost]
  12433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12434. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  12435. {
  12436. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  12437. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  12438. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  12439. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  12440. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  12441. dicDetail.Add(789, 1034);
  12442. dicDetail.Add(790, 1035);
  12443. dicDetail.Add(791, 1036);
  12444. dicDetail.Add(792, 1037);
  12445. dicDetail.Add(793, 1038);
  12446. dicDetail.Add(794, 1039);
  12447. dicDetail.Add(795, 1040);
  12448. dicDetail.Add(796, 1041);
  12449. dicDetail.Add(797, 1042);
  12450. dicDetail.Add(798, 1043);
  12451. dicDetail.Add(801, 1044);
  12452. dicDetail.Add(802, 1045);
  12453. dicDetail.Add(803, 1046);
  12454. Dictionary<int, int> dic = new Dictionary<int, int>();
  12455. dic.Add(806, 1027);
  12456. dic.Add(807, 1028);
  12457. dic.Add(808, 1029);
  12458. dic.Add(809, 1030);
  12459. dic.Add(810, 1031);
  12460. dic.Add(811, 1032);
  12461. dic.Add(812, 1033);
  12462. foreach (var item in list_visa)
  12463. {
  12464. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  12465. temp.Coefficient = item.coefficient;
  12466. DateTime dtCrt;
  12467. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  12468. if (b1)
  12469. {
  12470. temp.CreateTime = dtCrt;
  12471. }
  12472. else
  12473. {
  12474. temp.CreateTime = DateTime.Now;
  12475. }
  12476. temp.CreateUserId = item.Operators;
  12477. temp.DeleteTime = "";
  12478. temp.DeleteUserId = 0;
  12479. temp.DiId = int.Parse(item.DIID);
  12480. temp.FilePath = item.FilePath;
  12481. temp.IsDel = item.IsDel;
  12482. temp.Price = item.Price;
  12483. temp.PriceCount = 1;
  12484. temp.PriceCurrency = item.Currency;
  12485. int detailId = 0;
  12486. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  12487. {
  12488. detailId = dicDetail[item.PriceTypeDetail];
  12489. }
  12490. temp.PriceDetailType = detailId;
  12491. temp.PriceDt = DateTime.Now;
  12492. temp.PriceName = item.PriceName;
  12493. temp.PriceSum = item.Price;
  12494. int tid = 0;
  12495. if (dic.ContainsKey(item.PriceType))
  12496. {
  12497. tid = dic[item.PriceType];
  12498. }
  12499. temp.PriceType = tid;
  12500. temp.Remark = item.Remark;
  12501. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  12502. }
  12503. return Ok(JsonView(true, "操作成功!"));
  12504. }
  12505. }
  12506. }