GroupsController.cs 660 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401
  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. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  5635. if (!res)
  5636. {
  5637. return Ok(JsonView(false, "删除失败"));
  5638. }
  5639. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  5640. {
  5641. IsDel = 1,
  5642. DeleteUserId = dto.DeleteUserId,
  5643. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5644. }).ExecuteCommandAsync();
  5645. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  5646. {
  5647. IsDel = 1,
  5648. DeleteUserId = dto.DeleteUserId,
  5649. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5650. }).ExecuteCommandAsync();
  5651. return Ok(JsonView(true, "删除成功!"));
  5652. }
  5653. catch (Exception ex)
  5654. {
  5655. return Ok(JsonView(false, "程序错误!"));
  5656. throw;
  5657. }
  5658. }
  5659. /// <summary>
  5660. /// op费用录入操作(Status:1.新增,2.修改)
  5661. /// </summary>
  5662. /// <param name="dto"></param>
  5663. /// <returns></returns>
  5664. [HttpPost]
  5665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5666. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5667. {
  5668. try
  5669. {
  5670. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5671. if (groupData.Code != 0)
  5672. {
  5673. return Ok(JsonView(false, groupData.Msg));
  5674. }
  5675. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5676. }
  5677. catch (Exception ex)
  5678. {
  5679. return Ok(JsonView(false, ex.Message));
  5680. }
  5681. }
  5682. /// <summary>
  5683. /// 填写费用详细页面初始化绑定
  5684. /// </summary>
  5685. /// <param name="dto"></param>
  5686. /// <returns></returns>
  5687. [HttpPost]
  5688. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5689. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  5690. {
  5691. try
  5692. {
  5693. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  5694. if (groupData.Code != 0)
  5695. {
  5696. return Ok(JsonView(false, groupData.Msg));
  5697. }
  5698. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5699. }
  5700. catch (Exception ex)
  5701. {
  5702. return Ok(JsonView(false, ex.Message));
  5703. }
  5704. }
  5705. /// <summary>
  5706. /// 根据op费用Id查询详细数据
  5707. /// </summary>
  5708. /// <param name="dto"></param>
  5709. /// <returns></returns>
  5710. [HttpPost]
  5711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5712. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  5713. {
  5714. try
  5715. {
  5716. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  5717. if (groupData.Code != 0)
  5718. {
  5719. return Ok(JsonView(false, groupData.Msg));
  5720. }
  5721. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5722. }
  5723. catch (Exception ex)
  5724. {
  5725. return Ok(JsonView(false, ex.Message));
  5726. }
  5727. }
  5728. /// <summary>
  5729. /// OP费用录入填写详情
  5730. /// </summary>
  5731. /// <param name="dto"></param>
  5732. /// <returns></returns>
  5733. [HttpPost]
  5734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5735. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  5736. {
  5737. try
  5738. {
  5739. #region 参数校验
  5740. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  5741. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  5742. if (di == null) return Ok(JsonView(false, "团组错误!"));
  5743. #endregion
  5744. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5745. if (groupData.Code != 0)
  5746. {
  5747. return Ok(JsonView(false, groupData.Msg));
  5748. }
  5749. //自动审核
  5750. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  5751. #region 应用推送
  5752. try
  5753. {
  5754. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5755. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5756. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5757. }
  5758. catch (Exception ex)
  5759. {
  5760. }
  5761. #endregion
  5762. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5763. }
  5764. catch (Exception ex)
  5765. {
  5766. return Ok(JsonView(false, ex.Message));
  5767. }
  5768. }
  5769. /// <summary>
  5770. /// 获取三公详细所有城市
  5771. /// </summary>
  5772. /// <returns></returns>
  5773. [HttpGet]
  5774. public IActionResult OpCarCityResult()
  5775. {
  5776. var jw = JsonView(false);
  5777. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  5778. {
  5779. x.Id,
  5780. x.Country,
  5781. x.City,
  5782. }).ToList();
  5783. if (data.Count > 0)
  5784. {
  5785. jw = JsonView(true, "获取成功!", data);
  5786. }
  5787. else
  5788. {
  5789. jw.Msg = "城市数据为空!";
  5790. jw.Data = new string[0];
  5791. }
  5792. return Ok(jw);
  5793. }
  5794. /// <summary>
  5795. /// 导出地接费用明细
  5796. /// </summary>
  5797. /// <param name="dto"></param>
  5798. /// <returns></returns>
  5799. [HttpPost]
  5800. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  5801. {
  5802. var jw = JsonView(false);
  5803. if (dto.Diid < 1)
  5804. {
  5805. jw.Msg = "请输入正确的diid!";
  5806. return Ok(jw);
  5807. }
  5808. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5809. if (group == null)
  5810. {
  5811. jw.Msg = "未找到团组信息!";
  5812. return Ok(jw);
  5813. }
  5814. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  5815. if (localGuideArr.Count == 0)
  5816. {
  5817. jw.Msg = "该团组暂无地接信息!";
  5818. return Ok(jw);
  5819. }
  5820. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  5821. var overspendSoure = new Dictionary<int, int>
  5822. {
  5823. { 91, 982 }, //车
  5824. { 92 , 1059} ,//导游
  5825. { 994 , 1073}, //翻译
  5826. { 988 , 1074 }, //早餐
  5827. { 93 , 1075 }, //午餐
  5828. { 989 , 1076 }, //晚餐
  5829. };
  5830. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5831. foreach (var groupArr in localGroup)
  5832. {
  5833. var keyValue = groupArr.Key;
  5834. if (int.TryParse(keyValue, out int cityid))
  5835. {
  5836. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  5837. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  5838. }
  5839. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  5840. foreach (var item in groupArr)
  5841. {
  5842. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  5843. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  5844. new Grp_CarTouristGuideGroundReservationsContentExtend
  5845. {
  5846. Count = a.Count,
  5847. CreateTime = a.CreateTime,
  5848. CreateUserId = a.CreateUserId,
  5849. CTGGRId = a.CTGGRId,
  5850. Currency = a.Currency,
  5851. DatePrice = a.DatePrice,
  5852. DeleteTime = a.DeleteTime,
  5853. DeleteUserId = a.DeleteUserId,
  5854. DiId = a.DiId,
  5855. Id = a.Id,
  5856. IsDel = a.IsDel,
  5857. Price = a.Price,
  5858. PriceContent = a.PriceContent,
  5859. Remark = a.Remark,
  5860. SId = a.SId,
  5861. SidName = b.Name,
  5862. Units = a.Units,
  5863. }
  5864. ).ToList();
  5865. if (content.Count > 0)
  5866. {
  5867. contentArr.Add(content);
  5868. }
  5869. }
  5870. //open excel
  5871. //set excel
  5872. //save excel
  5873. try
  5874. {
  5875. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  5876. IWorkbook workbook;
  5877. if (Path.GetExtension(filePath).ToLower() == ".xls")
  5878. {
  5879. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5880. }
  5881. else
  5882. {
  5883. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5884. }
  5885. ISheet sheet = workbook.GetSheetAt(0);
  5886. var rowStartIndex = 2;
  5887. var clounmCount = 10;
  5888. var initStyleRow = sheet.GetRow(2);
  5889. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  5890. //var overspendArrDetail =
  5891. var existsId = new List<CarCompare>();
  5892. var lastElem = arr.Last();
  5893. var thisSid = -1;
  5894. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  5895. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  5896. {
  5897. Name = "未知币种!",
  5898. Remark = "未知币种!",
  5899. };
  5900. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  5901. Action cloneRowFn = () =>
  5902. {
  5903. rowStartIndex++;
  5904. var cloneRow = sheet.CreateRow(rowStartIndex);
  5905. // 复制样式
  5906. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  5907. {
  5908. ICell sourceCell = initStyleRow.GetCell(i);
  5909. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  5910. // 确保单元格存在样式
  5911. if (sourceCell.CellStyle != null)
  5912. {
  5913. targetCell.CellStyle = sourceCell.CellStyle;
  5914. }
  5915. }
  5916. };
  5917. var mergeRow = () =>
  5918. {
  5919. for (int i = 2; i < sheet.LastRowNum; i++)
  5920. {
  5921. var row = sheet.GetRow(i);
  5922. var cellFirst = row.GetCell(0);
  5923. var thisIndex = i + 1;
  5924. while (thisIndex < sheet.LastRowNum)
  5925. {
  5926. var nextRow = sheet.GetRow(thisIndex);
  5927. var nextCellFirst = nextRow.GetCell(0);
  5928. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  5929. {
  5930. thisIndex++;
  5931. }
  5932. else
  5933. {
  5934. break;
  5935. }
  5936. }
  5937. thisIndex--;
  5938. if (thisIndex != i)
  5939. {
  5940. //合并row
  5941. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5942. i, // 起始行索引(0-based)
  5943. thisIndex, // 结束行索引(0-based)
  5944. 0, // 起始列索引(0-based)
  5945. 0 // 结束列索引(0-based)
  5946. );
  5947. sheet.AddMergedRegion(cellRangeAddress);
  5948. i = thisIndex;
  5949. }
  5950. }
  5951. };
  5952. var chaoshiNumber = 0;
  5953. var totalNumber = 0.00M;
  5954. string lastStr = "";
  5955. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  5956. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  5957. {
  5958. b.IsAuditGM,
  5959. x.Id,
  5960. x.Area,
  5961. b.PayPercentage,
  5962. b.PayMoney,
  5963. }).ToList();
  5964. string yesPayment = "", noPayment = "";
  5965. foreach (var item in queryCarArrByCityAndDiid)
  5966. {
  5967. if (item.IsAuditGM == 1)
  5968. {
  5969. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5970. }
  5971. else
  5972. {
  5973. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5974. }
  5975. }
  5976. lastStr = yesPayment + noPayment;
  5977. foreach (var item in arr)
  5978. {
  5979. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  5980. {
  5981. if (thisSid != item.SId)
  5982. {
  5983. if (thisSid == -1)
  5984. {
  5985. thisSid = item.SId;
  5986. }
  5987. else
  5988. {
  5989. //合并小计行
  5990. //创建合并区域的实例
  5991. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5992. rowStartIndex, // 起始行索引(0-based)
  5993. rowStartIndex, // 结束行索引(0-based)
  5994. 0, // 起始列索引(0-based)
  5995. 3 // 结束列索引(0-based)
  5996. );
  5997. sheet.AddMergedRegion(cellRangeAddress);
  5998. var CellStyle = workbook.CreateCellStyle();
  5999. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6000. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6001. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6002. for (int i = 0; i <= clounmCount; i++)
  6003. {
  6004. if (i > 6)
  6005. {
  6006. var CellStyle1 = workbook.CreateCellStyle();
  6007. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6008. IFont Font = workbook.CreateFont(); // 创建字体
  6009. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6010. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6011. CellStyle1.SetFont(Font);
  6012. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6013. }
  6014. else
  6015. {
  6016. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6017. }
  6018. }
  6019. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6020. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6021. //超时合计
  6022. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6023. //超时数
  6024. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6025. //超时合计费用
  6026. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6027. thisSid = item.SId;
  6028. cloneRowFn();
  6029. chaoshiNumber = 0;
  6030. totalNumber = 0;
  6031. }
  6032. }
  6033. IRow row = sheet.GetRow(rowStartIndex);
  6034. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6035. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  6036. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  6037. if (isOpenOverspendSoure)
  6038. {
  6039. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6040. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  6041. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  6042. }
  6043. for (int i = 0; i <= clounmCount; i++)
  6044. {
  6045. var cell = row.GetCell(i);
  6046. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  6047. if (cell == null)
  6048. {
  6049. cell = row.CreateCell(i);
  6050. }
  6051. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  6052. fontRed.CloneStyleFrom(cell.CellStyle);
  6053. IFont Font = workbook.CreateFont(); // 创建字体
  6054. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  6055. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6056. fontRed.SetFont(Font);
  6057. byte[] rgb = new byte[3] { 255, 242, 204 };
  6058. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  6059. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  6060. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  6061. if (workbook is XSSFWorkbook)
  6062. {
  6063. BackgroundColor255_242_204.FillForegroundColor = 0;
  6064. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  6065. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  6066. }
  6067. else
  6068. {
  6069. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  6070. }
  6071. if (i == 1 || i > 6)
  6072. {
  6073. if (i > 6)
  6074. {
  6075. fontRed.FillForegroundColor = 0;
  6076. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  6077. fontRed.FillPattern = FillPattern.SolidForeground;
  6078. }
  6079. cell.CellStyle = fontRed;
  6080. }
  6081. if (i > 2 && i < 7)
  6082. {
  6083. cell.CellStyle = BackgroundColor255_242_204;
  6084. }
  6085. cell.SetCellValue(setCellValue); //写入单元格
  6086. }
  6087. if (overspendSoure.ContainsKey(thisSid))
  6088. {
  6089. var overspendId = overspendSoure[thisSid];
  6090. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6091. }
  6092. cloneRowFn();
  6093. existsId.Add(new CarCompare
  6094. {
  6095. DataPrice = item.DatePrice.ObjToDate(),
  6096. Sid = item.SId
  6097. });
  6098. }
  6099. if (item.Equals(lastElem))
  6100. {
  6101. //合并小计行
  6102. //创建合并区域的实例
  6103. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6104. rowStartIndex, // 起始行索引(0-based)
  6105. rowStartIndex, // 结束行索引(0-based)
  6106. 0, // 起始列索引(0-based)
  6107. 3 // 结束列索引(0-based)
  6108. );
  6109. sheet.AddMergedRegion(cellRangeAddress);
  6110. var CellStyle = workbook.CreateCellStyle();
  6111. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6112. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6113. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6114. for (int i = 0; i <= clounmCount; i++)
  6115. {
  6116. if (i > 6)
  6117. {
  6118. var CellStyle1 = workbook.CreateCellStyle();
  6119. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6120. IFont Font = workbook.CreateFont(); // 创建字体
  6121. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6122. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6123. CellStyle1.SetFont(Font);
  6124. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6125. }
  6126. else
  6127. {
  6128. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6129. }
  6130. }
  6131. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6132. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6133. //超时合计
  6134. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6135. //超时数
  6136. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6137. //超时合计费用
  6138. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6139. cloneRowFn();
  6140. // 创建合并区域的实例
  6141. cellRangeAddress = new CellRangeAddress(
  6142. rowStartIndex, // 起始行索引(0-based)
  6143. rowStartIndex, // 结束行索引(0-based)
  6144. 0, // 起始列索引(0-based)
  6145. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  6146. );
  6147. // 添加合并区域
  6148. sheet.AddMergedRegion(cellRangeAddress);
  6149. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  6150. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  6151. }
  6152. }
  6153. mergeRow();
  6154. // 保存修改后的Excel文件到新文件
  6155. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  6156. // new FileStream(newFilePath, FileMode.CreateNew)
  6157. using (var stream = new MemoryStream())
  6158. {
  6159. workbook.Write(stream, true);
  6160. stream.Flush();
  6161. stream.Seek(0, SeekOrigin.Begin);
  6162. MemoryStream memoryStream = new MemoryStream();
  6163. stream.CopyTo(memoryStream);
  6164. memoryStream.Seek(0, SeekOrigin.Begin);
  6165. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  6166. }
  6167. workbook.Close();
  6168. workbook.Dispose();
  6169. }
  6170. catch (Exception ex)
  6171. {
  6172. jw.Msg = "出现异常!" + ex.Message;
  6173. return Ok(jw);
  6174. }
  6175. }
  6176. if (Zips.Count > 0)
  6177. {
  6178. IOOperatorHelper io = new IOOperatorHelper();
  6179. var byts = io.ConvertZipStream(Zips);
  6180. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  6181. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  6182. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  6183. }
  6184. else
  6185. {
  6186. jw.Msg = "暂无生成文件!";
  6187. }
  6188. return Ok(jw);
  6189. }
  6190. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  6191. {
  6192. string outStr = string.Empty;
  6193. switch (i)
  6194. {
  6195. case 0:
  6196. outStr = arr[0].SidName;
  6197. break;
  6198. case 1:
  6199. outStr = arr[0].DataPriceStr;
  6200. break;
  6201. case 2:
  6202. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  6203. break;
  6204. case 4:
  6205. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  6206. break;
  6207. case 7:
  6208. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6209. {
  6210. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  6211. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  6212. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  6213. }
  6214. break;
  6215. case 8:
  6216. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6217. {
  6218. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  6219. }
  6220. break;
  6221. case 9:
  6222. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6223. {
  6224. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  6225. }
  6226. break;
  6227. case 10:
  6228. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6229. {
  6230. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  6231. }
  6232. break;
  6233. }
  6234. return outStr;
  6235. }
  6236. #region OP行程单
  6237. /// <summary>
  6238. /// OP行程单初始化
  6239. /// </summary>
  6240. /// <param name="dto"></param>
  6241. /// <returns></returns>
  6242. [HttpPost]
  6243. public IActionResult InitOpTravel(InitOpTravelDto dto)
  6244. {
  6245. var jw = JsonView(false);
  6246. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  6247. var group = groupList.First();
  6248. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  6249. if (group == null)
  6250. {
  6251. jw.Msg = "暂无团组!";
  6252. return Ok(jw);
  6253. }
  6254. group = groupList.Find(x => x.Id == diid);
  6255. if (group == null)
  6256. {
  6257. jw.Msg = "请输入正确的团组ID!";
  6258. return Ok(jw);
  6259. }
  6260. string city = string.Empty;
  6261. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  6262. if (blackCode.Count > 0)
  6263. {
  6264. var black = blackCode.First();
  6265. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  6266. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  6267. if (blackSp.Length > 0)
  6268. {
  6269. try
  6270. {
  6271. var cityArrCode = new List<string>(20);
  6272. foreach (var item in blackSp)
  6273. {
  6274. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  6275. var IndexSelect = itemSp[2];
  6276. var cityArrCodeLength = cityArrCode.Count - 1;
  6277. var startCity = IndexSelect.Substring(0, 3);
  6278. if (cityArrCodeLength > 0)
  6279. {
  6280. var arrEndCity = cityArrCode[cityArrCodeLength];
  6281. if (arrEndCity != startCity)
  6282. {
  6283. cityArrCode.Add(startCity.ToUpper());
  6284. }
  6285. }
  6286. else
  6287. {
  6288. cityArrCode.Add(startCity.ToUpper());
  6289. }
  6290. var endCity = IndexSelect.Substring(3, 3);
  6291. cityArrCode.Add(endCity.ToUpper());
  6292. }
  6293. var cityThree = string.Empty;
  6294. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  6295. cityThree = cityThree.TrimEnd(',');
  6296. if (string.IsNullOrWhiteSpace(cityThree))
  6297. {
  6298. throw new
  6299. Exception("error");
  6300. }
  6301. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  6302. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  6303. foreach (var item in cityArrCode)
  6304. {
  6305. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  6306. if (find != null)
  6307. {
  6308. city += find.City + "/";
  6309. }
  6310. else
  6311. {
  6312. city += item + "三字码未收入/";
  6313. }
  6314. }
  6315. city = city.TrimEnd('/');
  6316. }
  6317. catch (Exception e)
  6318. {
  6319. city = "黑屏代码格式不正确!";
  6320. }
  6321. }
  6322. }
  6323. else
  6324. {
  6325. city = "未录入黑屏代码";
  6326. }
  6327. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  6328. {
  6329. Date = x.Date,
  6330. Days = x.Days,
  6331. Diffgroup = x.Diffgroup,
  6332. Diid = x.Diid,
  6333. Traffic_First = x.Traffic_First,
  6334. Traffic_Second = x.Traffic_Second,
  6335. Trip = x.Trip,
  6336. WeekDay = x.WeekDay,
  6337. Id = x.Id
  6338. }).ToList();
  6339. jw.Data = new
  6340. {
  6341. groupList = groupList.Select(x => new
  6342. {
  6343. x.Id,
  6344. x.TeamName,
  6345. x.TourCode
  6346. }).ToList(),
  6347. groupInfo = new
  6348. {
  6349. group.VisitDays,
  6350. group.TourCode,
  6351. group.VisitPNumber,
  6352. group.TeamName,
  6353. city
  6354. },
  6355. OpTravelList
  6356. };
  6357. jw.Code = 200;
  6358. jw.Msg = "操作成功!";
  6359. return Ok(jw);
  6360. }
  6361. /// <summary>
  6362. /// 删除团组行程单
  6363. /// </summary>
  6364. /// <returns></returns>
  6365. [HttpPost]
  6366. public IActionResult DelTravel(DelOpTravelDto dto)
  6367. {
  6368. var jw = JsonView(false);
  6369. if (dto.UserId <= 0 || dto.Diid <= 0)
  6370. {
  6371. jw.Msg = "请输入正确的参数!";
  6372. return Ok(jw);
  6373. }
  6374. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  6375. .SetColumns(x => new Grp_TravelList
  6376. {
  6377. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6378. DeleteUserId = dto.UserId,
  6379. IsDel = 1,
  6380. }).ExecuteCommand();
  6381. jw = JsonView(true);
  6382. return Ok(jw);
  6383. }
  6384. /// <summary>
  6385. /// 行程单保存
  6386. /// </summary>
  6387. /// <returns></returns>
  6388. [HttpPost]
  6389. public IActionResult TravelSave(TravelSaveDto dto)
  6390. {
  6391. var jw = JsonView(false);
  6392. if (dto.Arr.Count > 0)
  6393. {
  6394. try
  6395. {
  6396. _sqlSugar.BeginTran();
  6397. foreach (var item in dto.Arr)
  6398. {
  6399. if (item.Id == 0)
  6400. {
  6401. throw new Exception("请传入正确的Id");
  6402. }
  6403. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  6404. .SetColumns(x => new Grp_TravelList
  6405. {
  6406. Trip = item.Trip
  6407. }).ExecuteCommand();
  6408. }
  6409. _sqlSugar.CommitTran();
  6410. jw = JsonView(true);
  6411. }
  6412. catch (Exception ex)
  6413. {
  6414. _sqlSugar.RollbackTran();
  6415. jw.Msg = "程序异常!" + ex.Message;
  6416. }
  6417. }
  6418. else
  6419. {
  6420. jw.Msg = "请传入正确的参数!";
  6421. }
  6422. return Ok(jw);
  6423. }
  6424. /// <summary>
  6425. /// 导出行程单
  6426. /// </summary>
  6427. /// <param name="dto"></param>
  6428. /// <returns></returns>
  6429. [HttpPost]
  6430. public IActionResult ExportTravel(ExportTravelDto dto)
  6431. {
  6432. var jw = JsonView(false);
  6433. jw.Data = "";
  6434. int diid = 0;
  6435. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  6436. if (Find == null)
  6437. {
  6438. jw.Msg = "请选择正确的团组!";
  6439. return Ok(jw);
  6440. }
  6441. else
  6442. {
  6443. diid = Find.Id;
  6444. }
  6445. //数据源
  6446. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  6447. DataTable dtBlack = null;
  6448. try
  6449. {
  6450. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  6451. }
  6452. catch (Exception)
  6453. {
  6454. jw.Msg = "机票黑屏代码有误!";
  6455. return Ok(jw);
  6456. }
  6457. string CityStr = string.Empty;
  6458. if (dtBlack.Rows.Count == 0)
  6459. {
  6460. jw.Msg = "机票黑屏代码有误!";
  6461. return Ok(jw);
  6462. }
  6463. else
  6464. {
  6465. foreach (DataRow row in dtBlack.Rows)
  6466. {
  6467. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  6468. {
  6469. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  6470. return Ok(jw);
  6471. }
  6472. }
  6473. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  6474. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  6475. }
  6476. //创建数据源Table
  6477. DataTable dtSource = new DataTable();
  6478. dtSource.Columns.Add("Days", typeof(string));
  6479. dtSource.Columns.Add("Date", typeof(string));
  6480. dtSource.Columns.Add("Week", typeof(string));
  6481. dtSource.Columns.Add("Traffic", typeof(string));
  6482. dtSource.Columns.Add("Trip", typeof(string));
  6483. //获取数据,放到datatable
  6484. foreach (var item in _travelList)
  6485. {
  6486. DataRow dr = dtSource.NewRow();
  6487. dr["Days"] = item.Days;
  6488. dr["Date"] = item.Date;
  6489. dr["Week"] = item.WeekDay;
  6490. dr["Traffic"] = item.Traffic_First
  6491. + "\r\n"
  6492. + item.Traffic_Second;
  6493. dr["Trip"] = item.Trip;
  6494. dtSource.Rows.Add(dr);
  6495. }
  6496. Dictionary<string, string> dic = new Dictionary<string, string>();
  6497. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  6498. dic.Add("City", CityStr);
  6499. dic.Add("Days", Find.VisitDays.ToString());
  6500. dic.Add("DeleCode", Find.TourCode);
  6501. dic.Add("Pnum", Find.VisitPNumber.ToString());
  6502. //模板路径
  6503. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  6504. //载入模板
  6505. Document doc = null;
  6506. DocumentBuilder builder = null;
  6507. try
  6508. {
  6509. //载入模板
  6510. doc = new Document(tempPath);
  6511. builder = new DocumentBuilder(doc);
  6512. }
  6513. catch (Exception)
  6514. {
  6515. jw.Msg = "模板位置不存在!";
  6516. return Ok(jw);
  6517. }
  6518. foreach (var key in dic.Keys)
  6519. {
  6520. Bookmark bookmark = doc.Range.Bookmarks[key];
  6521. if (bookmark != null)
  6522. {
  6523. builder.MoveToBookmark(key);
  6524. builder.Write(dic[key]);
  6525. }
  6526. }
  6527. //获取word里所有表格
  6528. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6529. //获取所填表格的序数
  6530. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6531. try
  6532. {
  6533. //循环赋值
  6534. for (int i = 0; i < dtSource.Rows.Count; i++)
  6535. {
  6536. builder.MoveToCell(0, i + 1, 0, 0);
  6537. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6538. builder.MoveToCell(0, i + 1, 1, 0);
  6539. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6540. builder.MoveToCell(0, i + 1, 2, 0);
  6541. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6542. var trip = dtSource.Rows[i]["Trip"].ToString();
  6543. builder.MoveToCell(0, i + 1, 3, 0);
  6544. builder.Write(trip);
  6545. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6546. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6547. // 获取特定索引的段落
  6548. Paragraph paragraph = (Paragraph)paragraphs[0];
  6549. Run run = paragraph.Runs[0];
  6550. Aspose.Words.Font font = run.Font;
  6551. font.Name = "黑体";
  6552. //设置双休红色
  6553. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6554. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6555. paragraph = (Paragraph)paragraphs[1];
  6556. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6557. {
  6558. run = paragraph.Runs[0];
  6559. font = run.Font;
  6560. font.Color = Color.Red;
  6561. }
  6562. }
  6563. }
  6564. catch (Exception ex)
  6565. {
  6566. }
  6567. //删除多余行
  6568. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6569. {
  6570. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6571. }
  6572. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6573. if (!Directory.Exists(savePath))
  6574. {
  6575. try
  6576. {
  6577. Directory.CreateDirectory(savePath);
  6578. }
  6579. catch
  6580. {
  6581. }
  6582. }
  6583. string path = savePath + Find.TeamName + "出访日程";
  6584. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  6585. try
  6586. {
  6587. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  6588. string postfix = ".docx";
  6589. if (dto.IsPDF == 1)
  6590. {
  6591. saveFormat = Aspose.Words.SaveFormat.Pdf;
  6592. postfix = ".pdf";
  6593. }
  6594. doc.Save(path + postfix, saveFormat);
  6595. jw = JsonView(true, "导出成功", ftpPath + postfix);
  6596. }
  6597. catch (Exception)
  6598. {
  6599. jw = JsonView(false);
  6600. }
  6601. return Ok(jw);
  6602. }
  6603. /// <summary>
  6604. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6605. /// </summary>
  6606. /// <param name="num"></param>
  6607. /// <returns></returns>
  6608. string GetNum(string num)
  6609. {
  6610. string str = "";
  6611. switch (num)
  6612. {
  6613. case "1":
  6614. str = "一";
  6615. break;
  6616. case "2":
  6617. str = "二";
  6618. break;
  6619. case "3":
  6620. str = "三";
  6621. break;
  6622. case "4":
  6623. str = "四";
  6624. break;
  6625. case "5":
  6626. str = "五";
  6627. break;
  6628. case "6":
  6629. str = "六";
  6630. break;
  6631. case "7":
  6632. str = "七";
  6633. break;
  6634. case "8":
  6635. str = "八";
  6636. break;
  6637. case "9":
  6638. str = "九";
  6639. break;
  6640. case "10":
  6641. str = "十";
  6642. break;
  6643. case "11":
  6644. str = "十一";
  6645. break;
  6646. case "12":
  6647. str = "十二";
  6648. break;
  6649. case "一":
  6650. str = "1";
  6651. break;
  6652. case "二":
  6653. str = "2";
  6654. break;
  6655. case "三":
  6656. str = "3";
  6657. break;
  6658. case "四":
  6659. str = "4";
  6660. break;
  6661. case "五":
  6662. str = "5";
  6663. break;
  6664. case "六":
  6665. str = "6";
  6666. break;
  6667. case "七":
  6668. str = "7";
  6669. break;
  6670. case "八":
  6671. str = "8";
  6672. break;
  6673. case "九":
  6674. str = "9";
  6675. break;
  6676. case "十":
  6677. str = "10";
  6678. break;
  6679. case "十一":
  6680. str = "11";
  6681. break;
  6682. case "十二":
  6683. str = "12";
  6684. break;
  6685. }
  6686. return str;
  6687. }
  6688. #endregion
  6689. #endregion
  6690. #region 团组成本
  6691. /// <summary>
  6692. /// 团组成本数据初始化
  6693. /// </summary>
  6694. /// <param name="dto"></param>
  6695. /// <returns></returns>
  6696. [HttpPost]
  6697. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6698. {
  6699. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6700. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6701. WHEN COUNT(*) >= 0 THEN 'True'
  6702. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6703. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6704. ").ToList(); //团组列表
  6705. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6706. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6707. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6708. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6709. if (groupinfoValue != null)
  6710. {
  6711. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6712. var spArr = new string[1] { countryArr };
  6713. if (countryArr.Contains("|"))
  6714. {
  6715. spArr = countryArr.Split("|");
  6716. }
  6717. else if (countryArr.Contains("、"))
  6718. {
  6719. spArr = countryArr.Split("、");
  6720. }
  6721. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6722. {
  6723. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6724. if (dbQueryCountry != null)
  6725. {
  6726. visaCountryInfoArr.Add(dbQueryCountry);
  6727. }
  6728. }
  6729. }
  6730. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6731. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6732. var create = _GroupCostRepository.
  6733. CreateGroupCostByBlackCode(dto.Diid);
  6734. if (groupCost.Count == 0 && create.Code == 0)
  6735. {
  6736. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6737. }
  6738. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6739. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6740. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6741. groupCostMap = groupCostMap.Select(x =>
  6742. {
  6743. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6744. {
  6745. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6746. }
  6747. return x;
  6748. }).ToList();
  6749. //GroupCostParameter.Add(new
  6750. // Grp_GroupCostParameter());
  6751. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6752. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  6753. return Ok(JsonView(new
  6754. {
  6755. groupList,
  6756. groupInfo,
  6757. groupChecks,
  6758. groupCost = groupCostMap,
  6759. hotelNumber,
  6760. GroupCostParameter = GroupCostParameterMap,
  6761. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  6762. {
  6763. x.VisaCountry,
  6764. x.VisaPrice,
  6765. x.Id,
  6766. }).ToList(),
  6767. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  6768. blackCodeIsTrue = create.Code == 0 ? true : false,
  6769. hotelIsTrue = hotelIsTrue,
  6770. }));
  6771. }
  6772. /// <summary>
  6773. /// 团组成本信息保存
  6774. /// </summary>
  6775. /// <param name="dto"></param>
  6776. /// <returns></returns>
  6777. [HttpPost]
  6778. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  6779. {
  6780. if (dto.Diid <= 0 || dto.Userid <= 0)
  6781. {
  6782. return Ok(JsonView(false));
  6783. }
  6784. JsonView jw = null;
  6785. bool isTrue = false;
  6786. #region 复制团组成本
  6787. //if (dto.Diid == 2581)
  6788. //{
  6789. // dto.Diid = 2599;
  6790. // dto.CheckBoxs.ForEach(x =>
  6791. // {
  6792. // x.Diid = 2599;
  6793. // });
  6794. // dto.GroupCosts.ForEach(x =>
  6795. // {
  6796. // x.Diid = 2599;
  6797. // });
  6798. // dto.CostTypeHotelNumbers.ForEach(x =>
  6799. // {
  6800. // x.Diid = 2599;
  6801. // });
  6802. // dto.GroupCostParameters.ForEach(x =>
  6803. // {
  6804. // x.DiId = 2599;
  6805. // });
  6806. //}
  6807. #endregion
  6808. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  6809. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  6810. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  6811. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  6812. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  6813. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  6814. try
  6815. {
  6816. _sqlSugar.BeginTran();
  6817. isTrue = await _GroupCostRepository.
  6818. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  6819. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  6820. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  6821. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  6822. _sqlSugar.CommitTran();
  6823. jw = JsonView(true, "保存成功!", isTrue);
  6824. }
  6825. catch (Exception)
  6826. {
  6827. _sqlSugar.RollbackTran();
  6828. jw = JsonView(false);
  6829. }
  6830. return Ok(jw);
  6831. }
  6832. /// <summary>
  6833. /// 司兼导数据
  6834. /// </summary>
  6835. /// <param name="dto"></param>
  6836. /// <returns></returns>
  6837. [HttpPost]
  6838. public IActionResult GetCarGuides(CarGuidesDto dto)
  6839. {
  6840. JsonView jw = null;
  6841. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  6842. jw = JsonView(true, "获取成功!", Data);
  6843. return Ok(jw);
  6844. }
  6845. /// <summary>
  6846. /// 导游数据
  6847. /// </summary>
  6848. /// <param name="dto"></param>
  6849. /// <returns></returns>
  6850. [HttpPost]
  6851. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  6852. {
  6853. JsonView jw = null;
  6854. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  6855. // 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
  6856. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  6857. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  6858. jw = JsonView(true, "获取成功!", Data);
  6859. return Ok(jw);
  6860. }
  6861. /// <summary>
  6862. /// 成本车数据
  6863. /// </summary>
  6864. /// <param name="dto"></param>
  6865. /// <returns></returns>
  6866. [HttpPost]
  6867. public IActionResult GetCarInfo(CarGuidesDto dto)
  6868. {
  6869. JsonView jw = null;
  6870. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  6871. jw = JsonView(true, "获取成功!", Data);
  6872. return Ok(jw);
  6873. }
  6874. /// <summary>
  6875. /// 景点数据
  6876. /// </summary>
  6877. /// <param name="dto"></param>
  6878. /// <returns></returns>
  6879. [HttpPost]
  6880. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  6881. {
  6882. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  6883. return Ok(JsonView(true, "获取成功!", Data));
  6884. }
  6885. /// <summary>
  6886. /// 成本通知
  6887. /// </summary>
  6888. /// <param name="dto"></param>
  6889. /// <returns></returns>
  6890. [HttpPost]
  6891. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  6892. {
  6893. if (dto.Diid < 0)
  6894. {
  6895. return Ok(JsonView(false));
  6896. }
  6897. JsonView jw = null;
  6898. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  6899. if (GroupCostParameter != null)
  6900. {
  6901. int IsShare = 0;
  6902. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  6903. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  6904. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  6905. string msg = string.Empty;
  6906. if (isTrue)
  6907. {
  6908. if (IsShare == 0)
  6909. {
  6910. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  6911. }
  6912. else
  6913. {
  6914. #region 企微通知对应岗位用户
  6915. try
  6916. {
  6917. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  6918. }
  6919. catch (Exception ex)
  6920. {
  6921. }
  6922. #endregion
  6923. msg = "通知成功,其他模块操作人员可见此成本信息!";
  6924. }
  6925. jw = JsonView(isTrue, msg, new { IsShare });
  6926. }
  6927. else
  6928. {
  6929. msg = "修改失败!";
  6930. jw = JsonView(isTrue, msg);
  6931. }
  6932. }
  6933. else
  6934. {
  6935. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  6936. }
  6937. return Ok(jw);
  6938. }
  6939. /// <summary>
  6940. /// 导出报价单
  6941. /// </summary>
  6942. /// <param name="dto"></param>
  6943. /// <returns></returns>
  6944. [HttpPost]
  6945. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  6946. {
  6947. if (dto.Diid == 0)
  6948. {
  6949. return Ok(JsonView(false, "请传递团组id"));
  6950. }
  6951. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6952. if (deleInfo.Code != 0)
  6953. {
  6954. return Ok(JsonView(false, "团组信息查询失败!"));
  6955. }
  6956. var di = deleInfo.Data as DelegationInfoWebView;
  6957. if (di != null)
  6958. {
  6959. di.TeamName = di.TeamName.Replace("|","、");
  6960. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  6961. //文件名
  6962. string strFileName = di.TeamName + "-收款账单.doc";
  6963. //获取模板
  6964. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  6965. //载入模板
  6966. Document doc = new Document(tmppath);
  6967. decimal TotalPrice = 0.00M;
  6968. string itemStr = string.Empty;
  6969. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  6970. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6971. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6972. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  6973. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  6974. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  6975. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  6976. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  6977. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  6978. foreach (var cost in groupCostType)
  6979. {
  6980. var List = cost.ToList();
  6981. if (cost.Key == "A")
  6982. {
  6983. foreach (var ListItem in List)
  6984. {
  6985. if (ListItem.number > 0)
  6986. {
  6987. if (ListItem.code.Contains("TBR"))
  6988. {
  6989. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6990. }
  6991. else
  6992. {
  6993. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6994. }
  6995. TotalPrice += (ListItem.number * ListItem.price);
  6996. }
  6997. }
  6998. }
  6999. else
  7000. {
  7001. itemStr = itemStr.Insert(0, "A段\r\n");
  7002. itemStr += "B段\r\n";
  7003. foreach (var ListItem in List)
  7004. {
  7005. if (ListItem.number > 0)
  7006. {
  7007. if (ListItem.code.Contains("TBR"))
  7008. {
  7009. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7010. }
  7011. else
  7012. {
  7013. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7014. }
  7015. TotalPrice += (ListItem.number * ListItem.price);
  7016. }
  7017. }
  7018. }
  7019. }
  7020. #region 替换Word模板书签内容
  7021. Dictionary<string, string> marks = new Dictionary<string, string>();
  7022. marks.Add("To", di.ClientUnit);//付款方
  7023. marks.Add("ToTel", di.TellPhone);//付款方电话
  7024. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7025. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7026. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7027. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7028. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7029. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  7030. marks.Add("PayItemContent", itemStr);//详细信息
  7031. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7032. #endregion
  7033. ////注
  7034. //if (doc.Range.Bookmarks["Attention"] != null)
  7035. //{
  7036. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7037. // mark.Text = frList[0].Attention;
  7038. //}
  7039. foreach (var item in marks.Keys)
  7040. {
  7041. if (doc.Range.Bookmarks[item] != null)
  7042. {
  7043. Bookmark mark = doc.Range.Bookmarks[item];
  7044. mark.Text = marks[item];
  7045. }
  7046. }
  7047. byte[] bytes = null;
  7048. using (MemoryStream stream = new MemoryStream())
  7049. {
  7050. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7051. bytes = stream.ToArray();
  7052. }
  7053. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7054. return Ok(JsonView(true, "", new
  7055. {
  7056. Data = bytes,
  7057. strFileName,
  7058. }));
  7059. }
  7060. else
  7061. {
  7062. return Ok(JsonView(false, "团组信息不存在!"));
  7063. }
  7064. }
  7065. /// <summary>
  7066. /// 导出团组成本
  7067. /// </summary>
  7068. /// <param name="dto"></param>
  7069. /// <returns></returns>
  7070. [HttpPost]
  7071. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7072. {
  7073. var jw = JsonView(false);
  7074. if (dto.Diid == 0)
  7075. {
  7076. return Ok(JsonView(false, "请传递团组id"));
  7077. }
  7078. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7079. if (deleInfo.Code != 0)
  7080. {
  7081. return Ok(JsonView(false, "团组信息查询失败!"));
  7082. }
  7083. var di = deleInfo.Data as DelegationInfoWebView;
  7084. if (di == null)
  7085. {
  7086. return Ok(JsonView(false, "团组信息查询失败!"));
  7087. }
  7088. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7089. WorkbookDesigner designer = new WorkbookDesigner();
  7090. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7091. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7092. for (int i = 0; i < List_GC.Count; i++)
  7093. {
  7094. GroupCost_Excel gc = new GroupCost_Excel();
  7095. gc.Id = List_GC[i].Id;
  7096. gc.Diid = List_GC[i].Diid.ToString();
  7097. gc.DAY = List_GC[i].DAY;
  7098. string week = "";
  7099. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7100. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7101. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7102. gc.ITIN = List_GC[i].ITIN;
  7103. gc.CarType = List_GC[i].CarType;
  7104. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7105. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7106. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7107. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7108. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7109. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7110. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7111. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7112. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7113. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7114. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7115. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7116. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7117. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7118. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7119. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7120. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7121. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7122. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7123. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7124. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7125. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7126. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7127. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7128. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7129. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7130. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7131. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7132. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7133. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7134. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7135. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7136. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7137. List_GC1.Add(gc);
  7138. }
  7139. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7140. dt.TableName = "TB";
  7141. //报表标题等不用dt的值
  7142. designer.SetDataSource("TeamName", dto.title.TeamName);
  7143. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7144. designer.SetDataSource("Tax", dto.title.Tax);
  7145. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7146. designer.SetDataSource("Currency", dto.title.Currency);
  7147. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7148. designer.SetDataSource("Rate", dto.title.Rate);
  7149. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7150. var Aparams = hotels.Find(x => x.Type == "Default");
  7151. if (Aparams == null)
  7152. {
  7153. return Ok(jw);
  7154. }
  7155. //酒店数量
  7156. var txtSGRNumber = Aparams.SGR.ToString();
  7157. var txtTBRNumber = Aparams.TBR.ToString();
  7158. var txtJSESNumber = Aparams.JSES.ToString();
  7159. var txtSUITENumbe = Aparams.SUITE.ToString();
  7160. if (dto.costType == "B")
  7161. {
  7162. Aparams = hotels.Find(x => x.Type == "A");
  7163. var Bparams = hotels.Find(x => x.Type == "B");
  7164. if (Aparams == null || Bparams == null)
  7165. {
  7166. return Ok(jw);
  7167. }
  7168. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7169. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7170. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7171. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7172. }
  7173. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7174. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7175. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7176. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7177. var ws = designer.Workbook.Worksheets[0];
  7178. int Row = List_GC.Count;
  7179. int startIndex = 11;
  7180. int HideRows = 0;
  7181. List<int> hideRowsList = new List<int>();
  7182. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7183. #region A段left数据
  7184. var left = dto.leftInfo.Find(x => x.Type == "A");
  7185. if (left == null)
  7186. {
  7187. return Ok(jw);
  7188. }
  7189. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7190. if (leftBindData != null)
  7191. {
  7192. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7193. designer.SetDataSource("VisaRS", leftBindData.rs);
  7194. designer.SetDataSource("VisaXS", leftBindData.xs);
  7195. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7196. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7197. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7198. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7199. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7200. }
  7201. else
  7202. {
  7203. hideRowsList.Add(Row + startIndex + HideRows);
  7204. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7205. }
  7206. HideRows += 2;
  7207. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7208. if (leftBindData != null)
  7209. {
  7210. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7211. designer.SetDataSource("BXRS", leftBindData.rs);
  7212. designer.SetDataSource("BXXS", leftBindData.xs);
  7213. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7214. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7215. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7216. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7217. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7218. }
  7219. else
  7220. {
  7221. hideRowsList.Add(Row + startIndex + HideRows);
  7222. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7223. }
  7224. HideRows += 2;
  7225. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7226. if (leftBindData != null)
  7227. {
  7228. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7229. designer.SetDataSource("HSRS", leftBindData.rs);
  7230. designer.SetDataSource("HSXS", leftBindData.xs);
  7231. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7232. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7233. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7234. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7235. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7236. }
  7237. else
  7238. {
  7239. hideRowsList.Add(Row + startIndex + HideRows);
  7240. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7241. }
  7242. HideRows += 2;
  7243. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7244. if (leftBindData != null)
  7245. {
  7246. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7247. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7248. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7249. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7250. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7251. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7252. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7253. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7254. }
  7255. else
  7256. {
  7257. hideRowsList.Add(Row + startIndex + HideRows);
  7258. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7259. }
  7260. HideRows += 2;
  7261. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7262. if (leftBindData != null)
  7263. {
  7264. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7265. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7266. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7267. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7268. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7269. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7270. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7271. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7272. }
  7273. else
  7274. {
  7275. hideRowsList.Add(Row + startIndex + HideRows);
  7276. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7277. }
  7278. HideRows += 2;
  7279. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  7280. if (leftBindData != null)
  7281. {
  7282. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  7283. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  7284. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  7285. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7286. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7287. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7288. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7289. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7290. }
  7291. else
  7292. {
  7293. hideRowsList.Add(Row + startIndex + HideRows);
  7294. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7295. }
  7296. HideRows += 2;
  7297. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7298. if (leftBindData != null)
  7299. {
  7300. ////TBR
  7301. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  7302. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  7303. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  7304. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7305. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7306. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7307. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7308. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7309. }
  7310. else
  7311. {
  7312. hideRowsList.Add(Row + startIndex + HideRows);
  7313. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7314. }
  7315. HideRows += 2;
  7316. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7317. if (leftBindData != null)
  7318. {
  7319. ////SGR
  7320. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  7321. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  7322. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  7323. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7324. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7325. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7326. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7327. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7328. }
  7329. else
  7330. {
  7331. hideRowsList.Add(Row + startIndex + HideRows);
  7332. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7333. }
  7334. HideRows += 2;
  7335. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7336. if (leftBindData != null)
  7337. {
  7338. ////JS/ES
  7339. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  7340. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  7341. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  7342. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7343. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7344. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7345. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7346. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7347. }
  7348. else
  7349. {
  7350. hideRowsList.Add(Row + startIndex + HideRows);
  7351. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7352. }
  7353. HideRows += 2;
  7354. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7355. if (leftBindData != null)
  7356. {
  7357. ////SUITE
  7358. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  7359. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  7360. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  7361. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7362. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7363. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7364. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7365. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7366. }
  7367. else
  7368. {
  7369. hideRowsList.Add(Row + startIndex + HideRows);
  7370. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7371. }
  7372. HideRows += 2;
  7373. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7374. if (leftBindData != null)
  7375. {
  7376. designer.SetDataSource("DJDRCB", leftBindData.cb);
  7377. designer.SetDataSource("DJRS", leftBindData.rs);
  7378. designer.SetDataSource("DJXS", leftBindData.xs);
  7379. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7380. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7381. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7382. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7383. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7384. }
  7385. else
  7386. {
  7387. hideRowsList.Add(Row + startIndex + HideRows);
  7388. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7389. }
  7390. HideRows += 2;
  7391. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7392. if (leftBindData != null)
  7393. {
  7394. designer.SetDataSource("HCPCB", leftBindData.cb);
  7395. designer.SetDataSource("HCPRS", leftBindData.rs);
  7396. designer.SetDataSource("HCPXS", leftBindData.xs);
  7397. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7398. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7399. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7400. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7401. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7402. }
  7403. else
  7404. {
  7405. hideRowsList.Add(Row + startIndex + HideRows);
  7406. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7407. }
  7408. HideRows += 2;
  7409. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7410. if (leftBindData != null)
  7411. {
  7412. designer.SetDataSource("CPCB", leftBindData.cb);
  7413. designer.SetDataSource("CPRS", leftBindData.rs);
  7414. designer.SetDataSource("CPXS", leftBindData.xs);
  7415. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7416. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7417. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7418. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7419. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7420. }
  7421. else
  7422. {
  7423. hideRowsList.Add(Row + startIndex + HideRows);
  7424. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7425. }
  7426. HideRows += 2;
  7427. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7428. if (leftBindData != null)
  7429. {
  7430. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7431. designer.SetDataSource("GWRS", leftBindData.rs);
  7432. designer.SetDataSource("GWXS", leftBindData.xs);
  7433. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7434. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7435. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7436. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7437. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7438. }
  7439. else
  7440. {
  7441. hideRowsList.Add(Row + startIndex + HideRows);
  7442. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7443. }
  7444. HideRows += 2;
  7445. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7446. if (leftBindData != null)
  7447. {
  7448. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7449. designer.SetDataSource("LYJRS", leftBindData.rs);
  7450. designer.SetDataSource("LYJXS", leftBindData.xs);
  7451. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7452. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7453. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7454. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7455. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7456. }
  7457. else
  7458. {
  7459. hideRowsList.Add(Row + startIndex + HideRows);
  7460. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7461. }
  7462. #endregion
  7463. #region A段Right信息
  7464. var right = dto.rightInfo.Find(x => x.Type == "A");
  7465. if (right == null)
  7466. {
  7467. return Ok(jw);
  7468. }
  7469. HideRows += 4;
  7470. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7471. if (rightBindData != null)
  7472. {
  7473. //经济舱 + 双人间 TBR
  7474. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7475. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7476. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7477. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7478. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7479. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7480. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7481. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7482. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7483. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7484. }
  7485. else
  7486. {
  7487. hideRowsList.Add(Row + startIndex + HideRows);
  7488. }
  7489. HideRows += 2;
  7490. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7491. if (rightBindData != null)
  7492. {
  7493. //经济舱 + 单人间 SGR
  7494. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7495. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7496. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7497. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7498. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7499. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7500. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7501. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7502. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7503. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7504. }
  7505. else
  7506. {
  7507. hideRowsList.Add(Row + startIndex + HideRows);
  7508. }
  7509. HideRows += 2;
  7510. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7511. if (rightBindData != null)
  7512. {
  7513. //公务舱 + 单人间 SGR
  7514. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7515. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7516. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7517. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7518. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7519. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7520. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7521. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7522. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7523. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7524. }
  7525. else
  7526. {
  7527. hideRowsList.Add(Row + startIndex + HideRows);
  7528. }
  7529. HideRows += 2;
  7530. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7531. if (rightBindData != null)
  7532. {
  7533. //公务舱 + 小套房 JSES
  7534. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7535. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7536. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7537. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7538. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7539. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7540. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7541. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7542. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7543. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7544. }
  7545. else
  7546. {
  7547. hideRowsList.Add(Row + startIndex + HideRows);
  7548. }
  7549. HideRows += 2;
  7550. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7551. if (rightBindData != null)
  7552. {
  7553. //公务舱 + 小套房 JSES
  7554. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7555. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7556. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7557. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7558. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7559. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7560. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7561. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7562. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7563. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7564. }
  7565. else
  7566. {
  7567. hideRowsList.Add(Row + startIndex + HideRows);
  7568. }
  7569. HideRows += 2;
  7570. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7571. if (rightBindData != null)
  7572. {
  7573. //经济舱 + 大套房
  7574. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7575. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7576. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7577. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7578. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7579. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7580. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7581. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7582. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7583. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7584. }
  7585. else
  7586. {
  7587. hideRowsList.Add(Row + startIndex + HideRows);
  7588. }
  7589. HideRows += 2;
  7590. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  7591. if (rightBindData != null)
  7592. {
  7593. //头等舱 + 小套房 JSES
  7594. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  7595. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  7596. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7597. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  7598. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7599. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7600. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7601. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7602. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7603. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7604. }
  7605. else
  7606. {
  7607. hideRowsList.Add(Row + startIndex + HideRows);
  7608. }
  7609. HideRows += 2;
  7610. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  7611. if (rightBindData != null)
  7612. {
  7613. //头等舱 + 大套房
  7614. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  7615. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  7616. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7617. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  7618. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7619. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7620. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7621. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7622. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7623. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7624. }
  7625. else
  7626. {
  7627. hideRowsList.Add(Row + startIndex + HideRows);
  7628. }
  7629. #endregion
  7630. #region B段标题清空
  7631. designer.SetDataSource("CostBDRCB", "");
  7632. designer.SetDataSource("CostBRS", "");
  7633. designer.SetDataSource("CostBXS", "");
  7634. designer.SetDataSource("CostBZCB", "");
  7635. designer.SetDataSource("CostBDRBJ", "");
  7636. designer.SetDataSource("CostBZBJ", "");
  7637. designer.SetDataSource("CostBDRLR", "");
  7638. designer.SetDataSource("CostBZLR", "");
  7639. designer.SetDataSource("CostBDRCBOM", "");
  7640. designer.SetDataSource("CostBRSOM", "");
  7641. designer.SetDataSource("CostBZCBOM", "");
  7642. designer.SetDataSource("CostBDRBJOM", "");
  7643. designer.SetDataSource("CostBZBJOM", "");
  7644. designer.SetDataSource("CostBDRLROM", "");
  7645. designer.SetDataSource("CostBZLROM", "");
  7646. #endregion
  7647. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7648. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7649. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7650. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7651. designer.SetDataSource("DJName", "地接(CNY)");
  7652. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7653. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7654. designer.SetDataSource("GWName", "公务(CNY)");
  7655. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7656. designer.SetDataSource("LYJName", "零用金(CNY)");
  7657. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7658. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7659. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7660. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  7661. designer.SetDataSource("BXName", "保险(CNY)");
  7662. designer.SetDataSource("VisaName", "签证(CNY)");
  7663. #region B段基本数据
  7664. if (dto.costType == "B")
  7665. {
  7666. left = dto.leftInfo.Find(x => x.Type == "B");
  7667. if (left == null)
  7668. {
  7669. return Ok(jw);
  7670. }
  7671. #region B段left数据
  7672. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7673. if (leftBindData != null)
  7674. {
  7675. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7676. designer.SetDataSource("BHSRS", leftBindData.rs);
  7677. designer.SetDataSource("BHSXS", leftBindData.xs);
  7678. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7679. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7680. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7681. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7682. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7683. }
  7684. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7685. if (leftBindData != null)
  7686. {
  7687. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7688. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7689. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7690. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7691. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7692. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7693. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7694. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7695. }
  7696. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7697. if (leftBindData != null)
  7698. {
  7699. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7700. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7701. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7702. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7703. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7704. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7705. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7706. designer.SetDataSource("BJPGWCZLR", ((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("BJPTDCCB", leftBindData.cb);
  7712. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  7713. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  7714. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7715. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7716. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7717. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7718. designer.SetDataSource("BJPTDCZLR", ((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("BHCPCB", leftBindData.cb);
  7724. designer.SetDataSource("BHCPRS", leftBindData.rs);
  7725. designer.SetDataSource("BHCPXS", leftBindData.xs);
  7726. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7727. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7728. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7729. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7730. designer.SetDataSource("BHCPZLR", ((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("BCPCB", leftBindData.cb);
  7736. designer.SetDataSource("BCPRS", leftBindData.rs);
  7737. designer.SetDataSource("BCPXS", leftBindData.xs);
  7738. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7739. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7740. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7741. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7742. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7743. }
  7744. //TBR
  7745. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7746. if (leftBindData != null)
  7747. {
  7748. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7749. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7750. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7751. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7752. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7753. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7754. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7755. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7756. }
  7757. //SGR
  7758. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7759. if (leftBindData != null)
  7760. {
  7761. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  7762. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  7763. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  7764. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7765. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7766. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7767. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7768. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7769. }
  7770. //JS/ES
  7771. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7772. if (leftBindData != null)
  7773. {
  7774. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  7775. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  7776. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  7777. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7778. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7779. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7780. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7781. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7782. }
  7783. //SUITE
  7784. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7785. if (leftBindData != null)
  7786. {
  7787. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  7788. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  7789. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  7790. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7791. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7792. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7793. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7794. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7795. }
  7796. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7797. if (leftBindData != null)
  7798. {
  7799. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  7800. designer.SetDataSource("BDJRS", leftBindData.rs);
  7801. designer.SetDataSource("BDJXS", leftBindData.xs);
  7802. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7803. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7804. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7805. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7806. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7807. }
  7808. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7809. if (leftBindData != null)
  7810. {
  7811. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  7812. designer.SetDataSource("BGWRS", leftBindData.rs);
  7813. designer.SetDataSource("BGWXS", leftBindData.xs);
  7814. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7815. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7816. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7817. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7818. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7819. }
  7820. #region 优化方案
  7821. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  7822. //excelBind.Add("零用金", new {
  7823. //cb="",
  7824. //rs="",
  7825. //xs ="",
  7826. //zcb = "",
  7827. //});
  7828. #endregion
  7829. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7830. if (leftBindData != null)
  7831. {
  7832. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  7833. designer.SetDataSource("BLYJRS", leftBindData.rs);
  7834. designer.SetDataSource("BLYJXS", leftBindData.xs);
  7835. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7836. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7837. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7838. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7839. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7840. }
  7841. #endregion
  7842. #region B段Right信息
  7843. right = dto.rightInfo.Find(x => x.Type == "B");
  7844. if (right == null)
  7845. {
  7846. return Ok(jw);
  7847. }
  7848. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7849. if (rightBindData != null)
  7850. {
  7851. //经济舱 + 双人间 TBR
  7852. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  7853. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  7854. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7855. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  7856. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7857. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7858. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7859. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7860. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7861. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7862. }
  7863. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7864. if (rightBindData != null)
  7865. {
  7866. //经济舱 + 单人间 SGR
  7867. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  7868. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  7869. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7870. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  7871. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7872. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7873. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7874. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7875. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7876. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7877. }
  7878. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7879. if (rightBindData != null)
  7880. {
  7881. //公务舱 + 单人间 SGR
  7882. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  7883. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  7884. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7885. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  7886. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7887. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7888. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7889. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7890. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7891. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7892. }
  7893. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7894. if (rightBindData != null)
  7895. {
  7896. //公务舱 + 小套房 JSES
  7897. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  7898. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  7899. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7900. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  7901. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7902. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7903. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7904. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7905. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7906. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7907. }
  7908. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7909. if (rightBindData != null)
  7910. {
  7911. //公务舱 + 小套房 JSES
  7912. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  7913. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  7914. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7915. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  7916. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7917. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7918. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7919. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7920. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7921. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7922. }
  7923. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7924. if (rightBindData != null)
  7925. {
  7926. //经济舱 + 大套房
  7927. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  7928. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  7929. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7930. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  7931. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7932. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7933. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7934. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7935. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7936. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7937. }
  7938. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  7939. if (rightBindData != null)
  7940. {
  7941. //头等舱 + 小套房 JSES
  7942. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  7943. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  7944. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7945. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  7946. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7947. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7948. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7949. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7950. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7951. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7952. }
  7953. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  7954. if (rightBindData != null)
  7955. {
  7956. //头等舱 + 大套房
  7957. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  7958. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  7959. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7960. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  7961. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7962. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7963. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7964. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7965. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7966. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7967. }
  7968. #endregion
  7969. #region 标题
  7970. designer.SetDataSource("CostBDRCB", "单人成本");
  7971. designer.SetDataSource("CostBRS", "人数");
  7972. designer.SetDataSource("CostBXS", "系数");
  7973. designer.SetDataSource("CostBZCB", "总成本");
  7974. designer.SetDataSource("CostBDRBJ", "单人报价");
  7975. designer.SetDataSource("CostBZBJ", "总报价");
  7976. designer.SetDataSource("CostBDRLR", "单人利润");
  7977. designer.SetDataSource("CostBZLR", "总利润");
  7978. designer.SetDataSource("CostBDRCBOM", "单人成本");
  7979. designer.SetDataSource("CostBRSOM", "人数");
  7980. designer.SetDataSource("CostBZCBOM", "总成本");
  7981. designer.SetDataSource("CostBDRBJOM", "单人报价");
  7982. designer.SetDataSource("CostBZBJOM", "总报价");
  7983. designer.SetDataSource("CostBDRLROM", "单人利润");
  7984. designer.SetDataSource("CostBZLROM", "总利润");
  7985. #endregion
  7986. }
  7987. #endregion
  7988. designer.SetDataSource("TzZCB2", TzZCB2);
  7989. designer.SetDataSource("TzZBJ2", TzZBJ2);
  7990. designer.SetDataSource("TzZLR2", TzZLR2);
  7991. string[] dataSourceKeys = new string[]
  7992. {
  7993. "VF",
  7994. "TGS",
  7995. "TGOF",
  7996. "TGM",
  7997. "TGA",
  7998. "TGTF",
  7999. "TGEF",
  8000. "CFM",
  8001. "CFOF",
  8002. "B",
  8003. "L",
  8004. "D",
  8005. "TBR",
  8006. "SGR",
  8007. "JSES",
  8008. "Suite",
  8009. "TV",
  8010. "1L",
  8011. "IF",
  8012. "EF",
  8013. "BRF",
  8014. "TE",
  8015. "TGT",
  8016. "DRVT",
  8017. "PC",
  8018. "TLF",
  8019. "ECT"
  8020. };
  8021. foreach (var item in dataSourceKeys)
  8022. {
  8023. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  8024. if (find != null)
  8025. {
  8026. designer.SetDataSource(item, find.text);
  8027. }
  8028. else
  8029. {
  8030. designer.SetDataSource(item, 0);
  8031. }
  8032. }
  8033. designer.SetDataSource(dt);
  8034. //根据数据源处理生成报表内容
  8035. designer.Process();
  8036. designer.Workbook.Worksheets[0].Name = "清单";
  8037. Worksheet sheet = designer.Workbook.Worksheets[0];
  8038. foreach (var Rowindex in hideRowsList)
  8039. {
  8040. ws.Cells.HideRows(Rowindex, 2);
  8041. }
  8042. byte[] bytes = null;
  8043. string strFileName = di.TeamName + "-团组-成本.xls";
  8044. using (MemoryStream stream = new MemoryStream())
  8045. {
  8046. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  8047. bytes = stream.ToArray();
  8048. }
  8049. return Ok(JsonView(true, "", new
  8050. {
  8051. Data = bytes,
  8052. strFileName,
  8053. }));
  8054. }
  8055. /// <summary>
  8056. /// 导出客户报表
  8057. /// </summary>
  8058. /// <returns></returns>
  8059. [HttpPost]
  8060. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  8061. {
  8062. var jw = JsonView(false);
  8063. if (dto.Diid == 0)
  8064. {
  8065. return Ok(JsonView(false, "请传递团组id"));
  8066. }
  8067. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8068. if (deleInfo.Code != 0)
  8069. {
  8070. return Ok(JsonView(false, "团组信息查询失败!"));
  8071. }
  8072. var di = deleInfo.Data as DelegationInfoWebView;
  8073. if (di == null)
  8074. {
  8075. return Ok(JsonView(false, "团组信息查询失败!"));
  8076. }
  8077. //文件名
  8078. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8079. //获取模板
  8080. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8081. //载入模板
  8082. Document doc = new Document(tmppath);
  8083. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8084. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8085. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8086. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8087. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8088. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8089. if (AParameter == null)
  8090. {
  8091. return Ok(JsonView(false, "系数不存在!"));
  8092. }
  8093. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8094. , TzAirDesc, TzZCost;
  8095. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8096. = TzAirDesc = TzZCost = string.Empty;
  8097. TzNumber = AParameter.CostTypenumber.ToString();
  8098. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8099. CarGuides1 = dto.CarGuides1;
  8100. Meal = dto.Meal;
  8101. SubsidizedMeals = dto.SubsidizedMeals;
  8102. NightRepair = dto.NightRepair;
  8103. AttractionsTickets = dto.AttractionsTickets;
  8104. MiscellaneousFees = dto.MiscellaneousFees;
  8105. ATip = dto.ATip;
  8106. TzHotelDesc = "";
  8107. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8108. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8109. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8110. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8111. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8112. TzAirDesc = "";
  8113. TzZCost = dto.TzZCost;
  8114. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8115. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8116. var index = 1;
  8117. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8118. foreach (var item in TzHotelDescArr)
  8119. {
  8120. if (AinfoArr != null)
  8121. {
  8122. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8123. if (Ainfo != null)
  8124. {
  8125. if (int.Parse(Ainfo.rs) <= 0)
  8126. {
  8127. continue;
  8128. }
  8129. var hotelText = string.Empty;
  8130. switch (item)
  8131. {
  8132. case "SGR":
  8133. hotelText = "单人间";
  8134. break;
  8135. case "JSES":
  8136. hotelText = "小套房";
  8137. break;
  8138. case "SUITE":
  8139. hotelText = "套房";
  8140. break;
  8141. case "TBR":
  8142. hotelText = "双人间";
  8143. break;
  8144. }
  8145. if (item != "TBR")
  8146. {
  8147. 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";
  8148. }
  8149. else
  8150. {
  8151. 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";
  8152. }
  8153. index++;
  8154. }
  8155. }
  8156. }
  8157. index = 1;
  8158. foreach (var item in TzAirDescArr)
  8159. {
  8160. if (AinfoArr != null)
  8161. {
  8162. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8163. if (Ainfo != null)
  8164. {
  8165. if (int.Parse(Ainfo.rs) <= 0)
  8166. {
  8167. continue;
  8168. }
  8169. 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";
  8170. index++;
  8171. }
  8172. }
  8173. }
  8174. if (dto.costType == "B")
  8175. {
  8176. if (BParameter == null)
  8177. {
  8178. return Ok(JsonView(false, "B段系数不存在!"));
  8179. }
  8180. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8181. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8182. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8183. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8184. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8185. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8186. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8187. foreach (var item in TzHotelDescArr)
  8188. {
  8189. if (AinfoArr != null)
  8190. {
  8191. TzHotelDesc += "B段信息 \r\n";
  8192. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8193. if (Ainfo != null)
  8194. {
  8195. if (int.Parse(Ainfo.rs) <= 0)
  8196. {
  8197. continue;
  8198. }
  8199. var hotelText = string.Empty;
  8200. switch (item)
  8201. {
  8202. case "SGR":
  8203. hotelText = "单人间";
  8204. break;
  8205. case "JSES":
  8206. hotelText = "小套房";
  8207. break;
  8208. case "SUITE":
  8209. hotelText = "套房";
  8210. break;
  8211. case "TBR":
  8212. hotelText = "双人间";
  8213. break;
  8214. }
  8215. if (item != "TBR")
  8216. {
  8217. 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";
  8218. }
  8219. else
  8220. {
  8221. 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";
  8222. }
  8223. index++;
  8224. }
  8225. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8226. }
  8227. }
  8228. index = 1;
  8229. foreach (var item in TzAirDescArr)
  8230. {
  8231. if (AinfoArr != null)
  8232. {
  8233. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8234. if (Ainfo != null)
  8235. {
  8236. if (int.Parse(Ainfo.rs) <= 0)
  8237. {
  8238. continue;
  8239. }
  8240. 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";
  8241. index++;
  8242. }
  8243. }
  8244. }
  8245. }
  8246. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8247. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8248. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8249. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8250. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8251. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8252. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8253. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8254. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8255. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8256. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8257. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8258. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8259. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8260. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8261. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8262. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8263. DickeyValue.Add("TzZCost", TzZCost);
  8264. foreach (var key in DickeyValue.Keys)
  8265. {
  8266. if (doc.Range.Bookmarks[key] != null)
  8267. {
  8268. Bookmark mark = doc.Range.Bookmarks[key];
  8269. mark.Text = DickeyValue[key];
  8270. }
  8271. }
  8272. byte[] bytes = null;
  8273. string strFileName = di.TeamName + "-客户报价.doc";
  8274. using (MemoryStream stream = new MemoryStream())
  8275. {
  8276. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8277. bytes = stream.ToArray();
  8278. }
  8279. return Ok(JsonView(true, "", new
  8280. {
  8281. Data = bytes,
  8282. strFileName,
  8283. }));
  8284. }
  8285. /// <summary>
  8286. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8287. /// </summary>
  8288. /// <param name="dto"></param>
  8289. /// <returns></returns>
  8290. [HttpPost]
  8291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8292. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8293. {
  8294. try
  8295. {
  8296. #region 参数验证
  8297. if (dto.DiId < 0)
  8298. {
  8299. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  8300. }
  8301. List<int> cTableIds = new List<int>() {
  8302. 76 ,//酒店预订
  8303. 77 ,//行程
  8304. 79 ,//车/导游地接
  8305. 80 ,//签证
  8306. 81 ,//邀请/公务活
  8307. 82 ,//团组客户保险
  8308. 85 ,//机票预订
  8309. 98 ,//其他款项
  8310. 285 ,//收款退还
  8311. 751 ,//酒店早餐
  8312. 1015 // 超支费用
  8313. };
  8314. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  8315. {
  8316. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  8317. }
  8318. #endregion
  8319. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  8320. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  8321. if (_GroupCostParameters.Count <= 0)
  8322. {
  8323. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  8324. }
  8325. if (_GroupCostParameters[0].IsShare == 0)
  8326. {
  8327. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  8328. }
  8329. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8330. //处理date为空问题
  8331. if (_GroupCosts.Count > 0)
  8332. {
  8333. for (int i = 0; i < _GroupCosts.Count; i++)
  8334. {
  8335. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  8336. {
  8337. if (i > 0)
  8338. {
  8339. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  8340. }
  8341. }
  8342. }
  8343. }
  8344. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  8345. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  8346. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8347. string currCode = "";
  8348. #region currCode 验证
  8349. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  8350. if (isInt)
  8351. {
  8352. var currData = currDatas.Find(it => it.Id == intCurrency);
  8353. if (currData != null)
  8354. {
  8355. currCode = currData.Name;
  8356. }
  8357. }
  8358. else
  8359. {
  8360. currCode = _GroupCostParameters[0].Currency.Trim();
  8361. }
  8362. #endregion
  8363. //op,酒店单段模式存储
  8364. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  8365. {
  8366. CurrencyCode = currCode,
  8367. Rate = _GroupCostParameters[0].Rate,
  8368. CostType = _GroupCostParameters[0].CostType,
  8369. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  8370. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  8371. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  8372. };
  8373. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  8374. if (_GroupCostParameters.Count == 2)
  8375. {
  8376. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  8377. }
  8378. foreach (var item in _GroupCostParameters)
  8379. {
  8380. decimal _rate = 1;
  8381. decimal _rate1 = item.Rate;
  8382. decimal _scale = 1;
  8383. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  8384. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  8385. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  8386. //if (userInfo != null)
  8387. //{
  8388. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  8389. // {
  8390. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  8391. // {
  8392. // _scale = 1.00M;
  8393. // }
  8394. // }
  8395. //}
  8396. #endregion
  8397. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  8398. {
  8399. CurrencyCode = currCode,
  8400. Rate = _rate1,
  8401. CostType = item.CostType,
  8402. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  8403. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  8404. CostTypeNumber = item.CostTypenumber
  8405. };
  8406. if (_GroupCostParameters.Count > 1)
  8407. {
  8408. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  8409. }
  8410. else
  8411. {
  8412. modulePromptInfo.CostTypeNumber = item.LYJRS;
  8413. }
  8414. if (dto.CTable == 79)//
  8415. {
  8416. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  8417. modulePromptInfo.TotalCost = item.DJCB;
  8418. }
  8419. List<string> costTypes = new List<string>() { "A", "B" };
  8420. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  8421. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  8422. if (_GroupCostsDuplicates.Count() == 1)
  8423. {
  8424. _GroupCostsTypeData = _GroupCosts;
  8425. }
  8426. else
  8427. {
  8428. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  8429. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  8430. }
  8431. /*
  8432. * 76 酒店预订
  8433. * 77 行程
  8434. * 79 车/导游地接
  8435. * 80 签证
  8436. * 81 邀请/公务活动
  8437. * 82 团组客户保险
  8438. * 85 机票预订
  8439. * 98 其他款项
  8440. * 285 收款退还
  8441. * 751 酒店早餐
  8442. * 1015 超支费用
  8443. */
  8444. switch (dto.CTable)
  8445. {
  8446. case 76: // 酒店预订
  8447. _ModuleSubPromptInfo.AddRange(
  8448. _GroupCostsTypeData.Select(it => new
  8449. {
  8450. it.DAY,
  8451. it.Date,
  8452. it.ACCON,
  8453. it.ITIN,
  8454. it.SGR,
  8455. it.TBR,
  8456. it.JS_ES,
  8457. it.Suite
  8458. })
  8459. );
  8460. break;
  8461. case 79: // 车/导游地接
  8462. _ModuleSubPromptInfo.AddRange(
  8463. _GroupCostsTypeData.Select(it => new
  8464. {
  8465. Date = it.Date, //日期
  8466. CarFee = it.CarCost * _rate * _scale, //车费用
  8467. CarType = it.CarType, //车型
  8468. DriverFee = it.CFS * _rate * _scale, //司机工资
  8469. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  8470. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  8471. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  8472. GuideFee = it.TGS * _rate * _scale, //导游费用
  8473. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  8474. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  8475. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  8476. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  8477. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  8478. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  8479. Breakfast = it.B * _rate * _scale, //早餐费
  8480. Lunch = it.L * _rate * _scale, //午餐费
  8481. Dinner = it.D * _rate * _scale, //晚餐费
  8482. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  8483. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  8484. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  8485. TicketFee = it.EF * _rate * _scale, //门票费
  8486. TicketRemark = it.EFR, //门票费描述
  8487. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  8488. TravelSupplies = it.TE * _rate * _scale, //出行物资
  8489. SpentCash = it.PC * _rate * _scale, //零用金
  8490. LeadersFee = it.TLF * _rate * _scale, //领队费
  8491. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  8492. })
  8493. );
  8494. break;
  8495. case 85: // 机票
  8496. List<dynamic> datas = new List<dynamic>();
  8497. datas.Add(
  8498. new
  8499. {
  8500. AirType = "经济舱",
  8501. AirNum = item.JJCRS,
  8502. AirDRCB = item.JJCCB,
  8503. AirZCB = (item.JJCRS * item.JJCCB)
  8504. }
  8505. );
  8506. datas.Add(
  8507. new
  8508. {
  8509. AirType = "公务舱",
  8510. AirNum = item.GWCRS,
  8511. AirDRCB = item.GWCCB,
  8512. AirZCB = (item.GWCRS * item.GWCCB)
  8513. }
  8514. );
  8515. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8516. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8517. modulePromptInfo.Data = new
  8518. {
  8519. airFeeData = datas,
  8520. airInitData = initDatas
  8521. };
  8522. _ModulePromptInfos.Add(modulePromptInfo);
  8523. break;
  8524. default:
  8525. break;
  8526. }
  8527. }
  8528. if (dto.CTable != 85)
  8529. {
  8530. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8531. _ModulePromptInfos.Add(_ModulePromptInfo);
  8532. }
  8533. _view.ModulePromptInfos = _ModulePromptInfos;
  8534. return Ok(JsonView(true, "操作成功!", _view));
  8535. }
  8536. catch (Exception ex)
  8537. {
  8538. return Ok(JsonView(false, ex.Message));
  8539. }
  8540. }
  8541. /// <summary>
  8542. /// 根据黑屏代码重新生成行程
  8543. /// </summary>
  8544. /// <param name="dto"></param>
  8545. /// <returns></returns>
  8546. [HttpPost]
  8547. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  8548. {
  8549. var jw = JsonView(false);
  8550. var Create = _GroupCostRepository.
  8551. CreateGroupCostByBlackCode(dto.Diid);
  8552. jw.Msg = Create.Msg;
  8553. if (Create.Code == 0)
  8554. {
  8555. jw.Code = 200;
  8556. jw.Data = new
  8557. {
  8558. groupCost = Create.Data,
  8559. blackCodeIsTrue = true
  8560. };
  8561. }
  8562. else
  8563. {
  8564. jw.Code = 400;
  8565. jw.Data = new
  8566. {
  8567. groupCost = Create.Data,
  8568. blackCodeIsTrue = false,
  8569. };
  8570. }
  8571. return Ok(jw);
  8572. }
  8573. /// <summary>
  8574. /// 成本获取OP历史车费用
  8575. /// </summary>
  8576. /// <param name="dto"></param>
  8577. /// <returns></returns>
  8578. [HttpPost]
  8579. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  8580. {
  8581. var jw = JsonView(false);
  8582. try
  8583. {
  8584. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  8585. //获取现有所有车的数据
  8586. if (!dto.Param.IsNullOrWhiteSpace())
  8587. {
  8588. string sql = $@"
  8589. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8590. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8591. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8592. 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
  8593. AND gctggr.ServiceEndTime is not NULL
  8594. ORDER by gctggrc.id DESC
  8595. ";
  8596. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8597. var numeberResult = await Task.Run(() =>
  8598. {
  8599. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8600. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8601. return numberArr;
  8602. });
  8603. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8604. foreach (var item in numeberResult)
  8605. {
  8606. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8607. {
  8608. Country = "数据异常!",
  8609. City = string.Empty,
  8610. };
  8611. item.Area = find.Country + " " + find.City;
  8612. }
  8613. dbResult.AddRange(numeberResult);
  8614. if (dto.Param.Contains("、"))
  8615. {
  8616. var sp = dto.Param.Split("、");
  8617. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8618. .Where(x =>
  8619. {
  8620. return System.Array.Exists(sp, e =>
  8621. {
  8622. bool where = false;
  8623. if (x.Area != null)
  8624. {
  8625. where = x.Area.Contains(e);
  8626. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8627. {
  8628. return false;
  8629. }
  8630. }
  8631. if (x.PriceName != null && !where)
  8632. {
  8633. where = x.PriceName.Contains(e);
  8634. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8635. {
  8636. return false;
  8637. }
  8638. }
  8639. return where;
  8640. });
  8641. }).ToList();
  8642. }
  8643. else
  8644. {
  8645. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8646. .Where(x =>
  8647. {
  8648. bool where = false;
  8649. if (x.Area != null)
  8650. {
  8651. where = x.Area.Contains(dto.Param);
  8652. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8653. {
  8654. return false;
  8655. }
  8656. }
  8657. if (x.PriceName != null && !where)
  8658. {
  8659. where = x.PriceName.Contains(dto.Param);
  8660. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8661. {
  8662. return false;
  8663. }
  8664. }
  8665. return where;
  8666. }
  8667. )
  8668. .ToList();
  8669. }
  8670. }
  8671. var view = dbResult.Select(x =>
  8672. {
  8673. decimal dp = 0.00M;
  8674. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  8675. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8676. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8677. {
  8678. if (startB && endB)
  8679. {
  8680. var timesp = endD.Subtract(startD);
  8681. if ((timesp.Days + 1) != 0)
  8682. {
  8683. dp = x.Price / (timesp.Days + 1);
  8684. }
  8685. }
  8686. }
  8687. else
  8688. {
  8689. dp = x.Price;
  8690. }
  8691. return new
  8692. {
  8693. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8694. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8695. x.Area,
  8696. x.id,
  8697. price = x.Price.ToString("F2"),
  8698. x.PriceName,
  8699. x.PriceContent,
  8700. x.TeamName,
  8701. x.DatePrice,
  8702. dayPrice = dp.ToString("F2"),
  8703. };
  8704. }).OrderByDescending(x => x.id).ToList();
  8705. jw = JsonView(true, "获取成功!", view);
  8706. }
  8707. catch (Exception e)
  8708. {
  8709. jw = JsonView(false, e.Message);
  8710. }
  8711. return Ok(jw);
  8712. }
  8713. #endregion
  8714. #region 酒店预订 新 雷怡 2023-12-28 17:45
  8715. /// <summary>
  8716. /// 酒店预订
  8717. /// 酒店费用列表 根据团组Id查询
  8718. /// </summary>
  8719. /// <param name="_dto"></param>
  8720. /// <returns></returns>
  8721. [HttpPost]
  8722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8723. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  8724. {
  8725. #region 参数验证
  8726. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8727. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8728. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8729. #region 团组操作权限验证 76 酒店预定模块
  8730. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8731. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8732. #endregion
  8733. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8734. #region 页面操作权限验证
  8735. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8736. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8737. #endregion
  8738. #endregion
  8739. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  8740. }
  8741. /// <summary>
  8742. /// 酒店预订
  8743. /// 基础数据
  8744. /// </summary>
  8745. /// <param name="_dto"></param>
  8746. /// <returns></returns>
  8747. [HttpPost]
  8748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8749. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  8750. {
  8751. #region 参数验证
  8752. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8753. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8754. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8755. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8756. #region 页面操作权限验证
  8757. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8758. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8759. #endregion
  8760. #region 团组操作权限验证 76 酒店预定模块
  8761. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8762. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8763. #endregion
  8764. #endregion
  8765. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  8766. }
  8767. /// <summary>
  8768. /// 酒店预订
  8769. /// 创建 入住卷号码
  8770. /// </summary>
  8771. /// <param name="_dto"></param>
  8772. /// <returns></returns>
  8773. [HttpPost]
  8774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8775. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  8776. {
  8777. try
  8778. {
  8779. #region 参数验证
  8780. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8781. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8782. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8783. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8784. #region 页面操作权限验证
  8785. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8786. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8787. #endregion
  8788. #region 团组操作权限验证 76 酒店预定模块
  8789. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8790. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8791. #endregion
  8792. #endregion
  8793. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  8794. if (data.Code != 0)
  8795. {
  8796. return Ok(JsonView(false, data.Msg));
  8797. }
  8798. return Ok(JsonView(true, data.Msg, data.Data));
  8799. }
  8800. catch (Exception ex)
  8801. {
  8802. return Ok(JsonView(false, ex.Message));
  8803. }
  8804. }
  8805. /// <summary>
  8806. /// 酒店预订
  8807. /// 详情
  8808. /// </summary>
  8809. /// <param name="_dto"></param>
  8810. /// <returns></returns>
  8811. [HttpPost]
  8812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8813. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  8814. {
  8815. #region 参数验证
  8816. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  8817. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8818. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  8819. #region 团组操作权限验证 76 酒店预定模块
  8820. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8821. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8822. #endregion
  8823. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8824. #region 页面操作权限验证
  8825. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8826. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8827. #endregion
  8828. #endregion
  8829. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  8830. }
  8831. /// <summary>
  8832. /// 酒店预订
  8833. /// Add Or Edit
  8834. /// </summary>
  8835. /// <param name="_dto"></param>
  8836. /// <returns></returns>
  8837. [HttpPost]
  8838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8839. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  8840. {
  8841. #region 参数验证
  8842. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8843. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8844. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8845. #region 团组操作权限验证 76 酒店预定模块
  8846. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8847. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8848. #endregion
  8849. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8850. #region 页面操作权限验证
  8851. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8852. if (_dto.Id == 0) // Add
  8853. {
  8854. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  8855. }
  8856. else if (_dto.Id > 1) // Edit
  8857. {
  8858. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  8859. }
  8860. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  8861. #endregion
  8862. #endregion
  8863. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  8864. if (_view.Code != 200)
  8865. {
  8866. return Ok(_view);
  8867. }
  8868. #region 应用推送
  8869. try
  8870. {
  8871. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  8872. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  8873. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  8874. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8875. //自动审核
  8876. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  8877. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  8878. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  8879. }
  8880. catch (Exception ex)
  8881. {
  8882. }
  8883. #endregion
  8884. return Ok(_view);
  8885. }
  8886. /// <summary>
  8887. /// 酒店自动审核测试
  8888. /// Add Or Edit
  8889. /// </summary>
  8890. /// <param name="_dto"></param>
  8891. /// <returns></returns>
  8892. [HttpPost]
  8893. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8894. public async Task<IActionResult> PostHotelAutoAuditTest(int diid,int dataId)
  8895. {
  8896. #region 应用推送
  8897. try
  8898. {
  8899. //自动审核
  8900. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  8901. }
  8902. catch (Exception ex)
  8903. {
  8904. return Ok(JsonView(false, "操作失败"));
  8905. }
  8906. #endregion
  8907. return Ok(JsonView(false,"操作成功"));
  8908. }
  8909. /// <summary>
  8910. /// 酒店预订
  8911. /// Del
  8912. /// </summary>
  8913. /// <param name="_dto"></param>
  8914. /// <returns></returns>
  8915. [HttpPost]
  8916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8917. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  8918. {
  8919. #region 参数验证
  8920. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8921. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8922. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8923. #region 团组操作权限验证 76 酒店预定模块
  8924. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8925. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8926. #endregion
  8927. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8928. #region 页面操作权限验证
  8929. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8930. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  8931. #endregion
  8932. #endregion
  8933. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  8934. }
  8935. /// <summary>
  8936. /// 酒店预订
  8937. /// 生成VOUCHER
  8938. /// 2024.05.06 之前版本
  8939. /// </summary>
  8940. /// <param name="_dto"></param>
  8941. /// <returns></returns>
  8942. [HttpPost]
  8943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8944. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  8945. {
  8946. try
  8947. {
  8948. #region 参数验证
  8949. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8950. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8951. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8952. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  8953. #region 团组操作权限验证 76 酒店预定模块
  8954. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8955. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8956. #endregion
  8957. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8958. #region 页面操作权限验证
  8959. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8960. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8961. #endregion
  8962. #endregion
  8963. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  8964. //判断数据是否完整
  8965. if (hr != null)
  8966. {
  8967. if (!string.IsNullOrEmpty(hr.DetermineNo))
  8968. {
  8969. string strFileName = "HotelStatement/";
  8970. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  8971. if (dele != null)
  8972. strFileName += dele.TourCode;
  8973. //载入模板
  8974. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  8975. Document doc = new Document(sss);
  8976. DocumentBuilder builder = new DocumentBuilder(doc);
  8977. #region 替换Word模板书签内容
  8978. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  8979. //入住卷预定号码
  8980. if (doc.Range.Bookmarks["VNO"] != null)
  8981. {
  8982. Bookmark mark = doc.Range.Bookmarks["VNO"];
  8983. mark.Text = hr.CheckNumber;
  8984. }
  8985. //酒店时间
  8986. if (doc.Range.Bookmarks["Date"] != null)
  8987. {
  8988. Bookmark mark = doc.Range.Bookmarks["Date"];
  8989. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8990. }
  8991. //团号
  8992. if (doc.Range.Bookmarks["TNo"] != null)
  8993. {
  8994. Bookmark mark = doc.Range.Bookmarks["TNo"];
  8995. mark.Text = dele.TourCode;
  8996. }
  8997. //预定号码
  8998. if (doc.Range.Bookmarks["BookingId"] != null)
  8999. {
  9000. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  9001. mark.Text = hr.ReservationsNo;
  9002. }
  9003. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  9004. {
  9005. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  9006. mark.Text = hr.DetermineNo;
  9007. }
  9008. //酒店城市
  9009. if (doc.Range.Bookmarks["City"] != null)
  9010. {
  9011. Bookmark mark = doc.Range.Bookmarks["City"];
  9012. mark.Text = hr.City;
  9013. }
  9014. //酒店名称
  9015. if (doc.Range.Bookmarks["HName"] != null)
  9016. {
  9017. Bookmark mark = doc.Range.Bookmarks["HName"];
  9018. mark.Text = hr.HotelName;
  9019. }
  9020. //酒店地址
  9021. if (doc.Range.Bookmarks["Address"] != null)
  9022. {
  9023. Bookmark mark = doc.Range.Bookmarks["Address"];
  9024. mark.Text = hr.HotelAddress;
  9025. }
  9026. //酒店电话
  9027. if (doc.Range.Bookmarks["Tel"] != null)
  9028. {
  9029. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9030. mark.Text = hr.HotelTel;
  9031. }
  9032. //酒店传真
  9033. if (doc.Range.Bookmarks["Fax"] != null)
  9034. {
  9035. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9036. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9037. {
  9038. mark.Text = hr.HotelFax;
  9039. }
  9040. }
  9041. //入住时间
  9042. if (doc.Range.Bookmarks["CIn"] != null)
  9043. {
  9044. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9045. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9046. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9047. }
  9048. //退房时间
  9049. if (doc.Range.Bookmarks["COut"] != null)
  9050. {
  9051. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9052. Bookmark mark = doc.Range.Bookmarks["COut"];
  9053. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9054. }
  9055. //客户名称
  9056. if (doc.Range.Bookmarks["GName"] != null)
  9057. {
  9058. string guestName = "";
  9059. string[] clients = new string[] { };
  9060. if (hr.GuestName.Contains(","))
  9061. {
  9062. clients = hr.GuestName.Split(",");
  9063. }
  9064. else
  9065. {
  9066. clients = new string[] { hr.GuestName };
  9067. }
  9068. List<int> clientIds_int = new List<int>();
  9069. if (clients.Length > 0)
  9070. {
  9071. foreach (var item in clients)
  9072. {
  9073. if (item.IsNumeric())
  9074. {
  9075. clientIds_int.Add(int.Parse(item));
  9076. }
  9077. }
  9078. }
  9079. if (clientIds_int.Count > 0)
  9080. {
  9081. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  9082. foreach (var client in _clientDatas)
  9083. {
  9084. //男
  9085. if (client.Sex == 0) guestName += $"Mr.";
  9086. //女
  9087. else if (client.Sex == 1) guestName += $"Ms.";
  9088. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  9089. {
  9090. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  9091. }
  9092. //guestName += $"{client.Pinyin},";
  9093. }
  9094. if (guestName.Length > 0)
  9095. {
  9096. guestName = guestName.Substring(0, guestName.Length - 1);
  9097. }
  9098. }
  9099. else
  9100. {
  9101. guestName = hr.GuestName;
  9102. }
  9103. Bookmark mark = doc.Range.Bookmarks["GName"];
  9104. mark.Text = guestName;
  9105. }
  9106. //房间介绍
  9107. if (doc.Range.Bookmarks["ROOM"] != null)
  9108. {
  9109. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  9110. mark.Text = hr.RoomExplanation;
  9111. }
  9112. //报价描述
  9113. if (doc.Range.Bookmarks["NOTE"] != null)
  9114. {
  9115. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9116. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9117. if (ss != null)
  9118. mark.Text = ss.Name;
  9119. }
  9120. //入住时间
  9121. if (doc.Range.Bookmarks["CheckIn"] != null)
  9122. {
  9123. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9124. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9125. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9126. }
  9127. //退房时间
  9128. if (doc.Range.Bookmarks["CheckOut"] != null)
  9129. {
  9130. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9131. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9132. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9133. }
  9134. //日期
  9135. if (doc.Range.Bookmarks["DT"] != null)
  9136. {
  9137. Bookmark mark = doc.Range.Bookmarks["DT"];
  9138. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9139. }
  9140. //名称
  9141. if (doc.Range.Bookmarks["VName"] != null)
  9142. {
  9143. Bookmark mark = doc.Range.Bookmarks["VName"];
  9144. mark.Text = hr.HotelName;
  9145. }
  9146. //号码
  9147. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9148. {
  9149. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9150. mark.Text = hr.CheckNumber;
  9151. }
  9152. #endregion
  9153. strFileName += "VOUCHER.doc";
  9154. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9155. doc.Save(fileDir);
  9156. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9157. return Ok(JsonView(true, "操作成功!", Url));
  9158. }
  9159. else
  9160. {
  9161. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9162. }
  9163. }
  9164. else
  9165. {
  9166. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9167. }
  9168. }
  9169. catch (Exception ex)
  9170. {
  9171. return Ok(JsonView(false, ex.Message));
  9172. }
  9173. }
  9174. /// <summary>
  9175. /// 酒店预订
  9176. /// 生成VOUCHER
  9177. /// 2024.05.06 之后版本
  9178. /// </summary>
  9179. /// <param name="_dto"></param>
  9180. /// <returns></returns>
  9181. [HttpPost]
  9182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9183. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9184. {
  9185. #region 参数验证
  9186. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9187. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9188. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9189. #region 团组操作权限验证 76 酒店预定模块
  9190. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9191. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9192. #endregion
  9193. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9194. #region 页面操作权限验证
  9195. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9196. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9197. #endregion
  9198. #endregion
  9199. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9200. //判断数据是否完整
  9201. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9202. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9203. string strFileName = "HotelStatement/";
  9204. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9205. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9206. #region 数据处理
  9207. List<int> guestIds = new List<int>();
  9208. int index = 0;
  9209. foreach (var item in hrDtas)
  9210. {
  9211. if (item.GuestName.Contains(","))
  9212. {
  9213. string[] guestIdArr = item.GuestName.Split(',');
  9214. foreach (var guestIdStr in guestIdArr)
  9215. {
  9216. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9217. if (guestBool)
  9218. {
  9219. guestIds.Add(guestId);
  9220. }
  9221. }
  9222. }
  9223. else guestNames += item.GuestName;
  9224. var voucherInfo = new HotelVoucherInfoView()
  9225. {
  9226. HotelName = item.HotelName,
  9227. CheckInDate = item.CheckInDate,
  9228. CheckOutDate = item.CheckOutDate,
  9229. ConfirmationNumber = item.DetermineNo.Trim(),
  9230. RoomType = item.RoomExplanation
  9231. };
  9232. vouchers.Add(voucherInfo);
  9233. }
  9234. if (guestIds.Count > 0)
  9235. {
  9236. guestIds = guestIds.Distinct().ToList();
  9237. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9238. if (guestDatas.Count > 0)
  9239. {
  9240. guestNames = "";
  9241. foreach (var guest in guestDatas)
  9242. {
  9243. string guestName = "";
  9244. if (guest.Sex == 0) guestName += @"MR.";
  9245. else if (guest.Sex == 1) guestName += @"MS.";
  9246. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9247. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9248. guestNames += @$"{guestName.Trim()}、";
  9249. }
  9250. if (guestNames.Length > 0)
  9251. {
  9252. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9253. }
  9254. }
  9255. }
  9256. #endregion
  9257. //载入模板
  9258. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9259. Document doc = new Document(sss);
  9260. DocumentBuilder builder = new DocumentBuilder(doc);
  9261. if (doc.Range.Bookmarks["GuestName"] != null)
  9262. {
  9263. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9264. mark.Text = guestNames;
  9265. }
  9266. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9267. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9268. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9269. for (int i = 1; i <= vouchers.Count; i++)
  9270. {
  9271. HotelVoucherInfoView hviv = vouchers[i - 1];
  9272. builder.MoveToCell(0, i, 0, 0);
  9273. builder.Write(hviv.HotelName);
  9274. builder.MoveToCell(0, i, 1, 0);
  9275. builder.Write(hviv.CheckInDate);
  9276. builder.MoveToCell(0, i, 2, 0);
  9277. builder.Write(hviv.CheckOutDate);
  9278. builder.MoveToCell(0, i, 3, 0);
  9279. builder.Write(hviv.RoomType);
  9280. builder.MoveToCell(0, i, 4, 0);
  9281. builder.Write(hviv.ConfirmationNumber);
  9282. }
  9283. //删除多余行
  9284. int currRowIndex = vouchers.Count + 1;
  9285. int delRows = 21 - currRowIndex;
  9286. if (delRows > 0)
  9287. {
  9288. for (int i = 0; i < delRows; i++)
  9289. {
  9290. table.Rows.RemoveAt(currRowIndex);
  9291. //cultivateRowIndex++;
  9292. }
  9293. }
  9294. strFileName += "VOUCHER.docx";
  9295. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9296. doc.Save(fileDir);
  9297. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9298. return Ok(JsonView(true, "操作成功!", Url));
  9299. }
  9300. /// <summary>
  9301. /// 酒店预订
  9302. /// 生成VOUCHER 批量生成
  9303. /// New
  9304. /// </summary>
  9305. /// <param name="_dto"></param>
  9306. /// <returns></returns>
  9307. [HttpPost]
  9308. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9309. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  9310. {
  9311. #region 参数验证
  9312. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9313. if (_dto.PageId < 1) _dto.PageId = 28;
  9314. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9315. #region 团组操作权限验证 76 酒店预定模块
  9316. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9317. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9318. #endregion
  9319. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9320. #region 页面操作权限验证
  9321. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9322. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9323. #endregion
  9324. #endregion
  9325. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  9326. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  9327. //.Select(x => new
  9328. //{
  9329. // x.CreateTime,
  9330. // x.CheckNumber,
  9331. // x.ReservationsNo,
  9332. // x.DetermineNo,
  9333. // x.HotelName,
  9334. // x.HotelAddress,
  9335. // x.HotelTel,
  9336. // x.HotelFax,
  9337. // x.CheckInDate,
  9338. // x.CheckOutDate,
  9339. // x.GuestName,
  9340. // x.RoomExplanation,
  9341. //})
  9342. .OrderBy(x => x.CreateTime)
  9343. .ToListAsync();
  9344. //判断数据是否完整
  9345. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9346. string strFileName = "HotelStatement/";
  9347. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9348. if (dele != null)
  9349. strFileName += dele.TourCode;
  9350. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  9351. for (int i = 0; i < hrDtas.Count; i++)
  9352. {
  9353. string guestNames = string.Empty;
  9354. List<int> guestIds = new List<int>();
  9355. var item = hrDtas[i];
  9356. //处理客户姓名
  9357. if (item.GuestName.Contains(","))
  9358. {
  9359. string[] guestIdArr = item.GuestName.Split(',');
  9360. foreach (var guestIdStr in guestIdArr)
  9361. if (int.TryParse(guestIdStr, out int guestId))
  9362. guestIds.Add(guestId);
  9363. }
  9364. else guestNames += item.GuestName;
  9365. if (guestIds.Count > 0)
  9366. {
  9367. guestIds = guestIds.Distinct().ToList();
  9368. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  9369. if (guestDatas1.Count > 0)
  9370. {
  9371. guestNames = "";
  9372. foreach (var guest in guestDatas1)
  9373. {
  9374. string guestName = "";
  9375. if (guest.Sex == 0) guestName += @"MR.";
  9376. else if (guest.Sex == 1) guestName += @"MS.";
  9377. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9378. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9379. guestNames += @$"{guestName.Trim()}、";
  9380. }
  9381. if (guestNames.Length > 0)
  9382. {
  9383. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9384. }
  9385. }
  9386. }
  9387. if (!string.IsNullOrEmpty(guestNames))
  9388. {
  9389. hrDtas[i].GuestName = guestNames;
  9390. }
  9391. }
  9392. strFileName += "VOUCHER.docx";
  9393. Document doc = new Document();
  9394. DocumentBuilder builder = new DocumentBuilder(doc);
  9395. try
  9396. {
  9397. foreach (var item in hrDtas)
  9398. {
  9399. //标题
  9400. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9401. builder.Writeln("ACCOMMODATION VOUCHER");
  9402. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9403. builder.Writeln($"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  9404. //表格
  9405. builder.InsertCell(); //插入单元格
  9406. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9407. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9408. }
  9409. }
  9410. catch (Exception ex)
  9411. {
  9412. throw;
  9413. }
  9414. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9415. //doc.Save(fileDir);
  9416. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9417. return Ok(JsonView(true, "操作成功!", Url));
  9418. }
  9419. /// <summary>
  9420. /// 酒店预订
  9421. /// 生成 预定成本 Excel
  9422. /// </summary>
  9423. /// <param name="_dto"></param>
  9424. /// <returns></returns>
  9425. [HttpPost]
  9426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9427. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  9428. {
  9429. #region 参数验证
  9430. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  9431. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  9432. if (!vadalitorRes.IsValid)
  9433. {
  9434. var errors = new StringBuilder();
  9435. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  9436. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  9437. }
  9438. #region 团组操作权限验证 76 酒店预定模块
  9439. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9440. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9441. #endregion
  9442. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9443. #region 页面操作权限验证
  9444. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9445. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9446. #endregion
  9447. #endregion
  9448. decimal _rate = 1.00M;
  9449. string _currency = "";
  9450. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  9451. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9452. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  9453. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  9454. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  9455. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  9456. {
  9457. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  9458. }
  9459. _currency = _GroupCostParameter.Currency;
  9460. bool isIntType = int.TryParse(_currency, out int currId);
  9461. if (isIntType)
  9462. {
  9463. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  9464. }
  9465. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  9466. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  9467. if (currInfo == null)
  9468. {
  9469. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  9470. }
  9471. if (!_currency.ToUpper().Equals("CNY"))
  9472. {
  9473. _rate = _GroupCostParameter.Rate;
  9474. }
  9475. _rate = currInfo.Rate;
  9476. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9477. string strFileName = "HotelStatement/";
  9478. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9479. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  9480. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  9481. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  9482. #region 数据处理
  9483. foreach (var item in hrDtas)
  9484. {
  9485. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  9486. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  9487. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  9488. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  9489. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  9490. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  9491. string singleRoomFeeStr = string.Empty,
  9492. doubleRoomFeeStr = string.Empty,
  9493. suiteRoomFeeStr = string.Empty,
  9494. otherRoomFeeStr = string.Empty,
  9495. payMoneyStr = string.Empty,
  9496. cardPriceStr = string.Empty;
  9497. if (roomCurr.Equals(_currency))
  9498. {
  9499. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  9500. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  9501. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  9502. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  9503. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  9504. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  9505. }
  9506. else
  9507. {
  9508. singleRoomFeeStr = $"{(item.SingleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  9509. doubleRoomFeeStr = $"{(item.DoubleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  9510. suiteRoomFeeStr = $"{(item.SuiteRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  9511. otherRoomFeeStr = $"{(item.OtherRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  9512. payMoneyStr = $"{(ccpInfo.PayMoney / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  9513. cardPriceStr = $"{(item.CardPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  9514. }
  9515. string breakfastPriceStr = string.Empty,
  9516. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  9517. governmentRentStr = string.Empty,
  9518. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  9519. cityTaxStrStr = string.Empty,
  9520. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  9521. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  9522. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  9523. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  9524. int payDId = roomInfo?.PayDId ?? 0;
  9525. pcfds.Add(new HotelReservations_PCFD_View()
  9526. {
  9527. City = item.City,
  9528. HotelName = item.HotelName,
  9529. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  9530. // SingleRoomCount = item.SingleRoomCount,
  9531. SingleRoomPrice = singleRoomFeeStr,
  9532. // DoubleRoomCount = item.DoubleRoomCount,
  9533. DoubleRoomPrice = doubleRoomFeeStr,
  9534. //SuiteRoomCount = item.SuiteRoomCount,
  9535. SuiteRoomPrice = suiteRoomFeeStr,
  9536. OtherRoomPrice = otherRoomFeeStr,
  9537. //OtherRoomCount = item.OtherRoomCount,
  9538. BreakfastPrice = breakfastPriceStr,
  9539. GovernmentRent = governmentRentStr,
  9540. CityTax = cityTaxStrStr,
  9541. RoomExplanation = item.RoomExplanation,
  9542. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  9543. PayTime = roomInfo?.ConsumptionDate,
  9544. BankNo = roomInfo?.BankNo,
  9545. PayMoney = payMoneyStr,
  9546. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  9547. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  9548. CardPrice = cardPriceStr,
  9549. Remark = ccpInfo.Remark
  9550. });
  9551. }
  9552. #endregion
  9553. //载入模板
  9554. WorkbookDesigner designer = new WorkbookDesigner();
  9555. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  9556. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  9557. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  9558. designer.SetDataSource("TourNo", groupInfo.TourCode);
  9559. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  9560. designer.SetDataSource("Opertor", userInfo.CnName);
  9561. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  9562. dt.TableName = "ViewMyHotelReservations";
  9563. designer.SetDataSource(dt);
  9564. designer.Process();
  9565. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/","").Replace(@"\", "").Trim()}_酒店预订成本_{ DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  9566. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  9567. designer.Workbook.Save(serverPath);
  9568. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  9569. #region 删除指定行
  9570. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  9571. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  9572. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  9573. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  9574. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  9575. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  9576. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  9577. cssIndex = dt.Columns["CityTax"].Ordinal,
  9578. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  9579. remarkIndex = dt.Columns["Remark"].Ordinal;
  9580. //删除指定列
  9581. foreach (DataRow item in dt.Rows)
  9582. {
  9583. string singleStr = item["SingleRoomPrice"].ToString();
  9584. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  9585. if (containsDigitButNotZero1) singleDel = false;
  9586. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  9587. string doubleStr = item["DoubleRoomPrice"].ToString();
  9588. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9589. if (containsDigitButNotZero2) doubleDel = false;
  9590. string suiteStr = item["SuiteRoomPrice"].ToString();
  9591. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9592. if (containsDigitButNotZero3) suiteDel = false;
  9593. string otherStr = item["OtherRoomPrice"].ToString();
  9594. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  9595. if (containsDigitButNotZero4) otherDel = false;
  9596. string zcStr = item["BreakfastPrice"].ToString();
  9597. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  9598. if (containsDigitButNotZero5) zcDel = false;
  9599. string dsStr = item["GovernmentRent"].ToString();
  9600. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  9601. if (containsDigitButNotZero6) dsDel = false;
  9602. string cssStr = item["CityTax"].ToString();
  9603. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  9604. if (containsDigitButNotZero7) cssDel = false;
  9605. string cpStr = item["ConsumptionPatterns"].ToString();
  9606. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  9607. string remarkStr = item["Remark"].ToString();
  9608. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  9609. }
  9610. DeleteColumn(serverPath, remarkIndex, remarkDel);
  9611. DeleteColumn(serverPath, cpIndex, cpDel);
  9612. DeleteColumn(serverPath, dsIndex, dsDel);
  9613. DeleteColumn(serverPath, cssIndex, cssDel);
  9614. DeleteColumn(serverPath, zcIndex, zcDel);
  9615. DeleteColumn(serverPath, otherIndex, otherDel);
  9616. DeleteColumn(serverPath, suiteIndex, suiteDel);
  9617. DeleteColumn(serverPath, doubleIndex, doubleDel);
  9618. DeleteColumn(serverPath, singleIndex, singleDel);
  9619. #endregion
  9620. //只保留第一个表格
  9621. DeleteSheet(serverPath);
  9622. return Ok(JsonView(true, "操作成功", url = rst));
  9623. }
  9624. /// <summary>
  9625. /// 删除指定列
  9626. /// </summary>
  9627. /// <param name="file"></param>
  9628. /// <param name="columnIndex"></param>
  9629. /// <param name="isDel"></param>
  9630. private void DeleteColumn(string file, int columnIndex, bool isDel)
  9631. {
  9632. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9633. //wb.Save(file);
  9634. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  9635. if (sheet1 != null)
  9636. {
  9637. if (isDel)
  9638. {
  9639. Cells cells = sheet1.Cells;
  9640. cells.DeleteColumn(columnIndex);
  9641. }
  9642. }
  9643. wb.Save(file);
  9644. }
  9645. /// <summary>
  9646. /// 删除sheet
  9647. /// </summary>
  9648. /// <param name="file"></param>
  9649. /// <param name="sheetName"></param>
  9650. private void DeleteSheet(string file, string sheetName = "")
  9651. {
  9652. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9653. //wb.Save(file);
  9654. List<string> sheets = new List<string>();
  9655. foreach (var item in wb.Worksheets)
  9656. {
  9657. sheets.Add(item.Name);
  9658. }
  9659. if (sheets.Count > 0)
  9660. {
  9661. sheets.RemoveAt(0);//不删除第一个sheet
  9662. foreach (var item in sheets)
  9663. {
  9664. wb.Worksheets.RemoveAt(item);
  9665. }
  9666. }
  9667. wb.Save(file);
  9668. }
  9669. /// <summary>
  9670. /// 酒店预订
  9671. /// 确认单
  9672. /// </summary>
  9673. /// <param name="_dto"></param>
  9674. /// <returns></returns>
  9675. [HttpPost]
  9676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9677. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  9678. {
  9679. try
  9680. {
  9681. #region 参数验证
  9682. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9683. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9684. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9685. #region 团组操作权限验证 76 酒店预定模块
  9686. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9687. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9688. #endregion
  9689. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9690. #region 页面操作权限验证
  9691. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9692. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9693. #endregion
  9694. #endregion
  9695. //团组信息
  9696. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  9697. //酒店数据
  9698. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  9699. if (listhoteldata.Count < 0)
  9700. {
  9701. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  9702. }
  9703. //利datatable存储
  9704. DataTable dt = new DataTable();
  9705. dt.Columns.Add("CheckInDate", typeof(string));
  9706. dt.Columns.Add("City", typeof(string));
  9707. dt.Columns.Add("Hotel", typeof(string));
  9708. dt.Columns.Add("Room", typeof(string));
  9709. for (int i = 0; i < listhoteldata.Count; i++)
  9710. {
  9711. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  9712. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  9713. while (dayStart < dayEnd)
  9714. {
  9715. string temp = "";
  9716. DataRow row = dt.NewRow();
  9717. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  9718. row["City"] = listhoteldata[i].City;
  9719. row["Hotel"] = listhoteldata[i].HotelName;
  9720. if (listhoteldata[i].SingleRoomCount > 0)
  9721. {
  9722. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  9723. }
  9724. if (listhoteldata[i].DoubleRoomCount > 0)
  9725. {
  9726. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  9727. }
  9728. if (listhoteldata[i].SuiteRoomCount > 0)
  9729. {
  9730. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  9731. }
  9732. if (listhoteldata[i].OtherRoomCount > 0)
  9733. {
  9734. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  9735. }
  9736. row["Room"] = temp;
  9737. dt.Rows.Add(row);
  9738. dayStart = dayStart.AddDays(1);
  9739. }
  9740. }
  9741. Dictionary<string, string> dic = new Dictionary<string, string>();
  9742. dic.Add("Dele", di.TeamName);
  9743. dic.Add("City", di.VisitCountry);
  9744. //模板路径
  9745. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  9746. //载入模板
  9747. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  9748. DocumentBuilder builder = new DocumentBuilder(doc);
  9749. foreach (var key in dic.Keys)
  9750. {
  9751. builder.MoveToBookmark(key);
  9752. builder.Write(dic[key]);
  9753. }
  9754. //获取word里所有表格
  9755. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9756. //获取所填表格的序数
  9757. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9758. var rowStart = tableOne.Rows[0]; //获取第1行
  9759. //循环赋值
  9760. for (int i = 0; i < dt.Rows.Count; i++)
  9761. {
  9762. builder.MoveToCell(0, i + 1, 0, 0);
  9763. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  9764. builder.MoveToCell(0, i + 1, 1, 0);
  9765. builder.Write(dt.Rows[i]["City"].ToString());
  9766. builder.MoveToCell(0, i + 1, 2, 0);
  9767. builder.Write(dt.Rows[i]["Hotel"].ToString());
  9768. builder.MoveToCell(0, i + 1, 3, 0);
  9769. builder.Write(dt.Rows[i]["Room"].ToString());
  9770. }
  9771. //删除多余行
  9772. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  9773. {
  9774. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  9775. }
  9776. string strFileName = di.TeamName + "酒店确认单.doc";
  9777. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  9778. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  9779. return Ok(JsonView(true, "成功", url));
  9780. }
  9781. catch (Exception ex)
  9782. {
  9783. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  9784. }
  9785. }
  9786. #endregion
  9787. #region 团组状态
  9788. /// <summary>
  9789. /// 团组状态列表 Page
  9790. /// </summary>
  9791. /// <param name="dto">团组列表请求dto</param>
  9792. /// <returns></returns>
  9793. [HttpPost]
  9794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9795. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  9796. {
  9797. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9798. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  9799. {
  9800. string sqlWhere = string.Empty;
  9801. if (dto.IsSure == 0) //未完成
  9802. {
  9803. sqlWhere += string.Format(@" And IsSure = 0");
  9804. }
  9805. else if (dto.IsSure == 1) //已完成
  9806. {
  9807. sqlWhere += string.Format(@" And IsSure = 1");
  9808. }
  9809. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  9810. {
  9811. string tj = dto.SearchCriteria;
  9812. 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}%')",
  9813. tj, tj, tj, tj, tj);
  9814. }
  9815. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  9816. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  9817. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  9818. From (
  9819. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  9820. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  9821. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  9822. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  9823. From Grp_DelegationInfo gdi
  9824. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  9825. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  9826. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  9827. Where gdi.IsDel = 0 {0}
  9828. ) temp ", sqlWhere);
  9829. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  9830. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  9831. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  9832. }
  9833. else
  9834. {
  9835. return Ok(JsonView(false, "查询失败"));
  9836. }
  9837. }
  9838. /// <summary>
  9839. /// 团组状态
  9840. /// 设置操作完成
  9841. /// </summary>
  9842. /// <param name="dto">团组列表请求dto</param>
  9843. /// <returns></returns>
  9844. [HttpPost]
  9845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9846. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  9847. {
  9848. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9849. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  9850. {
  9851. Id = dto.Id,
  9852. IsSure = 1
  9853. };
  9854. var result = await _sqlSugar.Updateable(_DelegationInfo)
  9855. .UpdateColumns(it => new { it.IsSure })
  9856. .WhereColumns(it => new { it.Id })
  9857. .ExecuteCommandAsync();
  9858. if (result > 0)
  9859. {
  9860. return Ok(JsonView(true, "操作完成!"));
  9861. }
  9862. return Ok(JsonView(false, "操作失败!"));
  9863. }
  9864. #endregion
  9865. #region 保险费用录入
  9866. /// <summary>
  9867. /// 根据团组Id查询保险费用列表
  9868. /// </summary>
  9869. /// <param name="dto"></param>
  9870. /// <returns></returns>
  9871. [HttpPost]
  9872. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9873. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  9874. {
  9875. try
  9876. {
  9877. Result groupData = await _customersRep.CustomersByDiId(dto);
  9878. if (groupData.Code != 0)
  9879. {
  9880. return Ok(JsonView(false, groupData.Msg));
  9881. }
  9882. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9883. }
  9884. catch (Exception ex)
  9885. {
  9886. return Ok(JsonView(false, ex.Message));
  9887. }
  9888. }
  9889. /// <summary>
  9890. /// 根据保险费用Id查询保险费用详细
  9891. /// </summary>
  9892. /// <param name="dto"></param>
  9893. /// <returns></returns>
  9894. [HttpPost]
  9895. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9896. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  9897. {
  9898. try
  9899. {
  9900. Result groupData = await _customersRep.CustomersById(dto);
  9901. if (groupData.Code != 0)
  9902. {
  9903. return Ok(JsonView(false, groupData.Msg));
  9904. }
  9905. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9906. }
  9907. catch (Exception ex)
  9908. {
  9909. return Ok(JsonView(false, ex.Message));
  9910. }
  9911. }
  9912. /// <summary>
  9913. /// 保险费用录入页面初始化绑定
  9914. /// </summary>
  9915. /// <param name="dto"></param>
  9916. /// <returns></returns>
  9917. [HttpPost]
  9918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9919. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  9920. {
  9921. try
  9922. {
  9923. Result groupData = await _customersRep.CustomersInitialize(dto);
  9924. if (groupData.Code != 0)
  9925. {
  9926. return Ok(JsonView(false, groupData.Msg));
  9927. }
  9928. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9929. }
  9930. catch (Exception ex)
  9931. {
  9932. return Ok(JsonView(false, ex.Message));
  9933. }
  9934. }
  9935. /// <summary>
  9936. /// 保险费用操作(Status:1.新增,2.修改)
  9937. /// </summary>
  9938. /// <param name="dto"></param>
  9939. /// <returns></returns>
  9940. [HttpPost]
  9941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9942. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  9943. {
  9944. try
  9945. {
  9946. Result groupData = await _customersRep.OpCustomers(dto);
  9947. if (groupData.Code != 0)
  9948. {
  9949. return Ok(JsonView(false, groupData.Msg));
  9950. }
  9951. #region 应用推送
  9952. try
  9953. {
  9954. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9955. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9956. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9957. }
  9958. catch (Exception ex)
  9959. {
  9960. }
  9961. #endregion
  9962. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9963. }
  9964. catch (Exception ex)
  9965. {
  9966. return Ok(JsonView(false, ex.Message));
  9967. }
  9968. }
  9969. /// <summary>
  9970. /// 保险文件上传
  9971. /// </summary>
  9972. /// <param name="file"></param>
  9973. /// <returns></returns>
  9974. [HttpPost]
  9975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9976. public async Task<IActionResult> UploadCus(IFormFile file)
  9977. {
  9978. try
  9979. {
  9980. if (file != null)
  9981. {
  9982. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9983. //文件名称
  9984. string projectFileName = file.FileName;
  9985. //上传的文件的路径
  9986. string filePath = "";
  9987. if (!Directory.Exists(fileDir))
  9988. {
  9989. Directory.CreateDirectory(fileDir);
  9990. }
  9991. //上传的文件的路径
  9992. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  9993. using (FileStream fs = System.IO.File.Create(filePath))
  9994. {
  9995. file.CopyTo(fs);
  9996. fs.Flush();
  9997. }
  9998. return Ok(JsonView(true, "上传成功!", projectFileName));
  9999. }
  10000. else
  10001. {
  10002. return Ok(JsonView(false, "上传失败!"));
  10003. }
  10004. }
  10005. catch (Exception ex)
  10006. {
  10007. return Ok(JsonView(false, "程序错误!"));
  10008. throw;
  10009. }
  10010. }
  10011. /// <summary>
  10012. /// 保险删除指定文件
  10013. /// </summary>
  10014. /// <param name="dto"></param>
  10015. /// <returns></returns>
  10016. [HttpPost]
  10017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10018. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  10019. {
  10020. try
  10021. {
  10022. string filePath = "";
  10023. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10024. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  10025. //int id = 0;
  10026. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  10027. // 删除该文件
  10028. try
  10029. {
  10030. System.IO.File.Delete(filePath);
  10031. 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()
  10032. {
  10033. Attachment = "",
  10034. }).ExecuteCommandAsync();
  10035. if (result != 0)
  10036. {
  10037. return Ok(JsonView(true, "成功!"));
  10038. }
  10039. else
  10040. {
  10041. return Ok(JsonView(false, "失败!"));
  10042. }
  10043. }
  10044. catch (Exception)
  10045. {
  10046. 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()
  10047. {
  10048. Attachment = "",
  10049. }).ExecuteCommandAsync();
  10050. if (result != 0)
  10051. {
  10052. return Ok(JsonView(true, "成功!"));
  10053. }
  10054. else
  10055. {
  10056. return Ok(JsonView(false, "失败!"));
  10057. }
  10058. }
  10059. }
  10060. catch (Exception ex)
  10061. {
  10062. return Ok(JsonView(false, "程序错误!"));
  10063. throw;
  10064. }
  10065. }
  10066. /// <summary>
  10067. /// 保险费用操作(删除)
  10068. /// </summary>
  10069. /// <param name="dto"></param>
  10070. /// <returns></returns>
  10071. [HttpPost]
  10072. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10073. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  10074. {
  10075. try
  10076. {
  10077. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  10078. if (!res)
  10079. {
  10080. return Ok(JsonView(false, "删除失败"));
  10081. }
  10082. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  10083. {
  10084. IsDel = 1,
  10085. DeleteUserId = dto.DeleteUserId,
  10086. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10087. }).ExecuteCommandAsync();
  10088. return Ok(JsonView(true, "删除成功!"));
  10089. }
  10090. catch (Exception ex)
  10091. {
  10092. return Ok(JsonView(false, "程序错误!"));
  10093. throw;
  10094. }
  10095. }
  10096. #endregion
  10097. #region 接团客户名单 PageId 104
  10098. /// <summary>
  10099. /// 接团客户名单
  10100. /// 迁移数据(慎用!)
  10101. /// </summary>
  10102. /// <param name="dto"></param>
  10103. /// <returns></returns>
  10104. [HttpPost]
  10105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10106. public async Task<IActionResult> PostTourClientListChange()
  10107. {
  10108. try
  10109. {
  10110. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  10111. //var groupClinetData1
  10112. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  10113. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  10114. int updateCount = 0;
  10115. if (oldOAClientList.Count > 0)
  10116. {
  10117. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  10118. _sqlSugar.BeginTran();
  10119. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  10120. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  10121. foreach (var item in oldOAClientList)
  10122. {
  10123. int comId = 0;
  10124. string format = "yyyy-MM-dd HH:mm:ss";
  10125. string data11 = "1990-01-01 00:00";
  10126. var data1 = IsValidDate(item.OPdate, format);
  10127. if (data1) data11 = item.OPdate;
  10128. //客户公司验证
  10129. if (!string.IsNullOrEmpty(item.Company))
  10130. {
  10131. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  10132. if (clientComInfo == null) // add
  10133. {
  10134. var addInfo = new Crm_CustomerCompany()
  10135. {
  10136. CompanyAbbreviation = "",
  10137. CompanyFullName = item.Company,
  10138. Address = "",
  10139. PostCodes = "",
  10140. LastedOpUserId = item.OPer,
  10141. LastedOpDt = Convert.ToDateTime(data11),
  10142. CreateUserId = item.OPer,
  10143. CreateTime = Convert.ToDateTime(data11),
  10144. IsDel = 0
  10145. };
  10146. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  10147. if (comId1 > 0) comId = comId1;
  10148. }
  10149. else comId = clientComInfo.Id;
  10150. }
  10151. //客户人员验证
  10152. int clientId = 0;
  10153. string name = item.LastName + item.Name;
  10154. if (!string.IsNullOrEmpty(name))
  10155. {
  10156. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  10157. if (clientInfo == null)
  10158. {
  10159. DateTime? dateTime = null;
  10160. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  10161. if (isDt) dateTime = birthDayDt;
  10162. var addInfo1 = new Crm_DeleClient()
  10163. {
  10164. CrmCompanyId = comId,
  10165. DiId = -1,
  10166. LastName = item.LastName,
  10167. FirstName = item.Name,
  10168. OldName = "",
  10169. Pinyin = item.Pinyin,
  10170. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  10171. Marriage = 0,
  10172. Phone = item.Phone,
  10173. Job = item.Job,
  10174. BirthDay = dateTime
  10175. };
  10176. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  10177. if (clientId1 > 0) clientId = clientId1;
  10178. }
  10179. else clientId = clientInfo.Id;
  10180. }
  10181. if (clientId < 1)
  10182. {
  10183. continue;
  10184. }
  10185. int airType = 0;
  10186. if (item.AirType == "超经舱") airType = 459;
  10187. else if (item.AirType == "公务舱") airType = 458;
  10188. else if (item.AirType == "经济舱") airType = 460;
  10189. else if (item.AirType == "其他") airType = 565;
  10190. else if (item.AirType == "头等舱") airType = 457;
  10191. var _TourClientListEntity = new Grp_TourClientList()
  10192. {
  10193. DiId = item.Diid,
  10194. ClientId = clientId,
  10195. CreateUserId = item.OPer,
  10196. CreateTime = Convert.ToDateTime(data11),
  10197. Remark = item.Remark,
  10198. IsDel = item.Isdel,
  10199. ShippingSpaceTypeId = airType,
  10200. ShippingSpaceSpecialNeeds = item.AirRemark,
  10201. HotelSpecialNeeds = item.RoomType
  10202. };
  10203. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  10204. if (_TourClientList > 0)
  10205. {
  10206. updateCount++;
  10207. }
  10208. }
  10209. _sqlSugar.CommitTran();
  10210. }
  10211. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  10212. }
  10213. catch (Exception ex)
  10214. {
  10215. _sqlSugar.RollbackTran();
  10216. return Ok(JsonView(false, ex.Message));
  10217. }
  10218. return Ok(JsonView(true));
  10219. }
  10220. private bool IsValidDate(string dateString, string format)
  10221. {
  10222. DateTime dateValue;
  10223. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  10224. return valid;
  10225. }
  10226. /// <summary>
  10227. /// 接团客户名单
  10228. /// 根据团组Id查询List
  10229. /// </summary>
  10230. /// <param name="dto"></param>
  10231. /// <returns></returns>
  10232. [HttpPost]
  10233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10234. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  10235. {
  10236. #region 参数验证
  10237. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  10238. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10239. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  10240. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10241. #region 页面操作权限验证
  10242. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10243. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10244. #endregion
  10245. #endregion
  10246. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  10247. if (viewData.Code != 0)
  10248. {
  10249. return Ok(JsonView(false, viewData.Msg));
  10250. }
  10251. return Ok(JsonView(viewData.Data));
  10252. }
  10253. /// <summary>
  10254. /// 接团客户名单
  10255. /// 基础数据 Init
  10256. /// </summary>
  10257. /// <param name="_dto"></param>
  10258. /// <returns></returns>
  10259. [HttpPost]
  10260. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10261. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  10262. {
  10263. #region 参数验证
  10264. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10265. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10266. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10267. #region 页面操作权限验证
  10268. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10269. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10270. #endregion
  10271. #endregion
  10272. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  10273. if (viewData.Code != 0)
  10274. {
  10275. return Ok(JsonView(false, viewData.Msg));
  10276. }
  10277. return Ok(JsonView(viewData.Data));
  10278. }
  10279. /// <summary>
  10280. /// 接团客户名单
  10281. /// 根据 Id查询 Details
  10282. /// </summary>
  10283. /// <param name="_dto"></param>
  10284. /// <returns></returns>
  10285. [HttpPost]
  10286. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10287. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  10288. {
  10289. #region 参数验证
  10290. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10291. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10292. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10293. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10294. #region 页面操作权限验证
  10295. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10296. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10297. #endregion
  10298. #endregion
  10299. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  10300. if (viewData.Code != 0)
  10301. {
  10302. return Ok(JsonView(false, viewData.Msg));
  10303. }
  10304. return Ok(JsonView(viewData.Data));
  10305. }
  10306. /// <summary>
  10307. /// 接团客户名单
  10308. /// Add Or Edit
  10309. /// </summary>
  10310. /// <param name="_dto"></param>
  10311. /// <returns></returns>
  10312. [HttpPost]
  10313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10314. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  10315. {
  10316. #region 参数验证
  10317. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10318. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10319. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10320. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10321. #region 页面操作权限验证
  10322. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10323. if (_dto.Id == 0) //添加
  10324. {
  10325. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10326. }
  10327. else if (_dto.Id >= 0) //修改
  10328. {
  10329. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10330. }
  10331. #endregion
  10332. #endregion
  10333. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  10334. if (viewData.Code != 0)
  10335. {
  10336. return Ok(JsonView(false, viewData.Msg));
  10337. }
  10338. return Ok(JsonView(true));
  10339. }
  10340. /// <summary>
  10341. /// 接团客户名单
  10342. /// AddMultiple(添加多个)
  10343. /// </summary>
  10344. /// <param name="_dto"></param>
  10345. /// <returns></returns>
  10346. [HttpPost]
  10347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10348. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  10349. {
  10350. #region 参数验证
  10351. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10352. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10353. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10354. #region 页面操作权限验证
  10355. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10356. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10357. #endregion
  10358. #endregion
  10359. var viewData = await _tourClientListRep._AddMultiple(_dto);
  10360. if (viewData.Code != 0)
  10361. {
  10362. return Ok(JsonView(false, viewData.Msg));
  10363. }
  10364. return Ok(JsonView(true));
  10365. }
  10366. /// <summary>
  10367. /// 接团客户名单
  10368. /// Del
  10369. /// </summary>
  10370. /// <param name="_dto"></param>
  10371. /// <returns></returns>
  10372. [HttpPost]
  10373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10374. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  10375. {
  10376. #region 参数验证
  10377. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10378. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10379. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10380. #region 页面操作权限验证
  10381. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10382. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  10383. #endregion
  10384. #endregion
  10385. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  10386. if (viewData.Code != 0)
  10387. {
  10388. return Ok(JsonView(false, viewData.Msg));
  10389. }
  10390. return Ok(JsonView(true));
  10391. }
  10392. /// <summary>
  10393. /// 接团客户名单
  10394. /// 文件下载 客户名单
  10395. /// </summary>
  10396. /// <param name="_dto"></param>
  10397. /// <returns></returns>
  10398. [HttpPost]
  10399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10400. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  10401. {
  10402. #region 参数验证
  10403. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10404. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10405. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  10406. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10407. #region 页面操作权限验证
  10408. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10409. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10410. #endregion
  10411. #endregion
  10412. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  10413. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  10414. From Grp_TourClientList tcl
  10415. Left Join
  10416. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  10417. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  10418. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  10419. From Crm_DeleClient dc
  10420. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  10421. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  10422. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  10423. Where dc.IsDel = 0) temp
  10424. On temp.DcId =tcl.ClientId
  10425. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  10426. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  10427. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  10428. //载入模板
  10429. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  10430. if (_dto.Language == 1)
  10431. {
  10432. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  10433. }
  10434. //载入模板
  10435. var doc = new Document(tempPath);
  10436. DocumentBuilder builder = new DocumentBuilder(doc);
  10437. //获取word里所有表格
  10438. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10439. //获取所填表格的序数
  10440. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10441. var rowStart = tableOne.Rows[0]; //获取第1行
  10442. if (_dto.Language == 0)
  10443. {
  10444. //循环赋值
  10445. for (int i = 0; i < DcList.Count; i++)
  10446. {
  10447. builder.MoveToCell(0, i + 1, 0, 0);
  10448. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  10449. builder.MoveToCell(0, i + 1, 1, 0);
  10450. int sex = DcList[i].Sex;
  10451. string sexStr = string.Empty;
  10452. if (sex == 0) sexStr = "男";
  10453. else if (sex == 1) sexStr = "女";
  10454. else sexStr = "未设置";
  10455. builder.Write(sexStr);
  10456. builder.MoveToCell(0, i + 1, 2, 0);
  10457. string birthDay = DcList[i].BirthDay;
  10458. string birthDayStr = string.Empty;
  10459. if (!string.IsNullOrEmpty(birthDay))
  10460. {
  10461. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  10462. }
  10463. builder.Write(birthDayStr);
  10464. builder.MoveToCell(0, i + 1, 3, 0);
  10465. string company = "";
  10466. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10467. {
  10468. company = DcList[i].CompanyFullName.ToString();
  10469. }
  10470. builder.Write(company);
  10471. builder.MoveToCell(0, i + 1, 4, 0);
  10472. builder.Write(DcList[i].Job);
  10473. }
  10474. }
  10475. else if (_dto.Language == 1)
  10476. {
  10477. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  10478. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  10479. List<string> transArrayStr = new List<string>();
  10480. string transStrRes1 = "";
  10481. for (int i = 0; i < DcList.Count; i++)
  10482. {
  10483. var dc = DcList[i];
  10484. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  10485. if (dc.Job.Equals("暂无")) dc.Job = "-";
  10486. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  10487. if (DcList.Count - 1 == i) transStrRes1 += str1;
  10488. else transStrRes1 += $"{str1}|";
  10489. }
  10490. //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";
  10491. string transStrRes = "";
  10492. if (transStrRes1.Length > 0 )
  10493. {
  10494. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  10495. }
  10496. //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
  10497. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  10498. //List<string> transArray = new List<string> { };
  10499. List<TranslateInfo> transArray = new List<TranslateInfo>();
  10500. if (transStrRes.Contains("|"))
  10501. {
  10502. string[] transArray1 = transStrRes.Split('|');
  10503. if (transArray1.Length > 0)
  10504. {
  10505. foreach (var item in transArray1)
  10506. {
  10507. if (item.Contains("&"))
  10508. {
  10509. string[] transArray2 = item.Split('&');
  10510. int index = 0;
  10511. string companyName = "", job = "";
  10512. if (transArray2.Length > 0)
  10513. {
  10514. bool success = int.TryParse(transArray2[0].Trim(), out index);
  10515. if (1 < transArray2.Length) companyName = transArray2[1];
  10516. if (2 < transArray2.Length) job = transArray2[2];
  10517. }
  10518. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  10519. }
  10520. }
  10521. }
  10522. }
  10523. //循环赋值
  10524. for (int i = 0; i < DcList.Count; i++)
  10525. {
  10526. string PYName = "";
  10527. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  10528. {
  10529. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  10530. string PY_First = DcList[i].Pinyin.Split('/')[1];
  10531. PYName = PY_First + " " + PY_Last;
  10532. }
  10533. else
  10534. {
  10535. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  10536. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  10537. PYName = PY_First + " " + PY_Last;
  10538. }
  10539. builder.MoveToCell(0, i + 1, 0, 0);
  10540. builder.Write(PYName);
  10541. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  10542. builder.MoveToCell(0, i + 1, 1, 0);
  10543. builder.Write(sex);
  10544. DateTime birthDt;
  10545. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  10546. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  10547. builder.MoveToCell(0, i + 1, 2, 0);
  10548. builder.Write(birthday);
  10549. string company = string.Empty,job = string.Empty;
  10550. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  10551. if (dcTransInfo != null)
  10552. {
  10553. company = dcTransInfo.CompanyName;
  10554. job = dcTransInfo.Job;
  10555. }
  10556. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10557. {
  10558. //查询对照表
  10559. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  10560. if (tempCec != null)
  10561. {
  10562. company = tempCec.enName;
  10563. }
  10564. //翻译
  10565. else
  10566. {
  10567. }
  10568. }
  10569. builder.MoveToCell(0, i + 1, 3, 0);
  10570. builder.Write(company);
  10571. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  10572. {
  10573. //查询对照表
  10574. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  10575. if (tempPec != null)
  10576. {
  10577. job = tempPec.enName;
  10578. }
  10579. //翻译
  10580. else
  10581. {
  10582. }
  10583. }
  10584. builder.MoveToCell(0, i + 1, 4, 0);
  10585. builder.Write(job);
  10586. }
  10587. }
  10588. //删除多余行
  10589. while (tableOne.Rows.Count > DcList.Count + 1)
  10590. {
  10591. tableOne.Rows.RemoveAt(DcList.Count + 1);
  10592. }
  10593. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  10594. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  10595. doc.Save(fileDir);
  10596. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  10597. return Ok(JsonView(true, "操作成功!", Url));
  10598. }
  10599. private class TranslateInfo
  10600. {
  10601. public int Index { get; set; }
  10602. public string CompanyName { get; set; }
  10603. public string Job { get; set; }
  10604. }
  10605. #endregion
  10606. #region 团组倒推表
  10607. /// <summary>
  10608. /// 倒推表基础数据
  10609. /// Init
  10610. /// </summary>
  10611. /// <param name="dto"></param>
  10612. /// <returns></returns>
  10613. [HttpPost]
  10614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10615. public async Task<IActionResult> PostInvertedListInit()
  10616. {
  10617. var viewData = await _invertedListRep._Init();
  10618. if (viewData.Code != 0)
  10619. {
  10620. return Ok(JsonView(false, viewData.Msg));
  10621. }
  10622. return Ok(JsonView(viewData.Data));
  10623. }
  10624. /// <summary>
  10625. /// 倒推表
  10626. /// Info
  10627. /// </summary>
  10628. /// <param name="dto"></param>
  10629. /// <returns></returns>
  10630. [HttpPost]
  10631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10632. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  10633. {
  10634. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  10635. if (viewData.Code != 0)
  10636. {
  10637. return Ok(JsonView(false, viewData.Msg));
  10638. }
  10639. return Ok(JsonView(viewData.Data));
  10640. }
  10641. /// <summary>
  10642. /// 倒推表
  10643. /// Create
  10644. /// </summary>
  10645. /// <param name="dto"></param>
  10646. /// <returns></returns>
  10647. [HttpPost]
  10648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10649. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  10650. {
  10651. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  10652. if (viewData.Code != 0)
  10653. {
  10654. return Ok(JsonView(false, viewData.Msg));
  10655. }
  10656. return Ok(JsonView(viewData.Data));
  10657. }
  10658. /// <summary>
  10659. /// 倒推表
  10660. /// Update
  10661. /// </summary>
  10662. /// <param name="dto"></param>
  10663. /// <returns></returns>
  10664. [HttpPost]
  10665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10666. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  10667. {
  10668. var viewData = await _invertedListRep._Update(dto);
  10669. if (viewData.Code != 0)
  10670. {
  10671. return Ok(JsonView(false, viewData.Msg));
  10672. }
  10673. return Ok(JsonView(viewData.Data));
  10674. }
  10675. /// <summary>
  10676. /// 倒推表
  10677. /// File Download
  10678. /// </summary>
  10679. /// <param name="dto"></param>
  10680. /// <returns></returns>
  10681. [HttpPost]
  10682. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10683. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  10684. {
  10685. var info2 = await _invertedListRep._Info(1, dto.DiId);
  10686. if (info2.Code != 0)
  10687. {
  10688. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  10689. }
  10690. var info1 = info2.Data as InvertedListInfoView;
  10691. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  10692. string teamName = "";
  10693. if (info != null) teamName = info.TeamName;
  10694. //载入模板
  10695. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  10696. DocumentBuilder builder = new DocumentBuilder(doc);
  10697. //利用键值对存放数据
  10698. Dictionary<string, string> dic = new Dictionary<string, string>();
  10699. dic.Add("TeamName", teamName);
  10700. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  10701. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  10702. dic.Add("BPRemark", info1.ApprovalDataRemark);
  10703. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  10704. dic.Add("SQRemark", info1.ApprovalRemark);
  10705. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  10706. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  10707. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  10708. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  10709. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  10710. dic.Add("QZRemark", info1.VisaInformationRemark);
  10711. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  10712. dic.Add("SQQZRemark", info1.SendVisaRemark);
  10713. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  10714. dic.Add("CQRemark", info1.IssueVisaRemark);
  10715. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  10716. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  10717. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  10718. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  10719. #region 填充word模板书签内容
  10720. foreach (var key in dic.Keys)
  10721. {
  10722. builder.MoveToBookmark(key);
  10723. builder.Write(dic[key]);
  10724. }
  10725. #endregion
  10726. var fileDir = AppSettingsHelper.Get("WordBasePath");
  10727. string fileName = $"{teamName}团出行准备流程表.doc";
  10728. string filePath = fileDir + $@"InvertedList/{fileName}";
  10729. doc.Save(filePath);
  10730. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  10731. return Ok(JsonView(true, "操作成功!", Url));
  10732. }
  10733. #endregion
  10734. #region 三公签证费用(签证费、代办费)
  10735. /// <summary>
  10736. /// 三公签证费用(签证费、代办费)
  10737. /// List
  10738. /// </summary>
  10739. /// <returns></returns>
  10740. [HttpPost]
  10741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10742. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  10743. {
  10744. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  10745. if (_view.Code != 0)
  10746. {
  10747. return Ok(JsonView(false, _view.Msg));
  10748. }
  10749. return Ok(JsonView(true, "操作成功!", _view.Data));
  10750. }
  10751. /// <summary>
  10752. /// 三公签证费用(签证费、代办费)
  10753. /// Add Or Update
  10754. /// </summary>
  10755. /// <returns></returns>
  10756. [HttpPost]
  10757. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10758. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  10759. {
  10760. var _view = await _visaFeeInfoRep._Update(_dto);
  10761. if (_view.Code != 0)
  10762. {
  10763. return Ok(JsonView(false, _view.Msg));
  10764. }
  10765. return Ok(JsonView(true, _view.Msg));
  10766. }
  10767. #endregion
  10768. #region 酒店询价
  10769. /// <summary>
  10770. /// 酒店询价
  10771. /// Init
  10772. /// </summary>
  10773. /// <param name="dto"></param>
  10774. /// <returns></returns>
  10775. [HttpPost]
  10776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10777. public async Task<IActionResult> PostHotelInquiryInit()
  10778. {
  10779. var res = await _hotelInquiryRep._Init();
  10780. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10781. return Ok(JsonView(true, res.Msg, res.Data));
  10782. }
  10783. /// <summary>
  10784. /// 酒店询价
  10785. /// page Item
  10786. /// </summary>
  10787. /// <param name="_dto"></param>
  10788. /// <returns></returns>
  10789. [HttpPost]
  10790. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10791. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  10792. {
  10793. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  10794. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10795. var view = res.Data as PageDataViewBase;
  10796. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  10797. }
  10798. /// <summary>
  10799. /// 酒店询价
  10800. /// info
  10801. /// </summary>
  10802. /// <param name="_dto"></param>
  10803. /// <returns></returns>
  10804. [HttpPost]
  10805. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10806. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  10807. {
  10808. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  10809. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10810. return Ok(JsonView(true, res.Msg, res.Data));
  10811. }
  10812. /// <summary>
  10813. /// 酒店询价
  10814. /// Add Or Edit
  10815. /// </summary>
  10816. /// <param name="_dto"></param>
  10817. /// <returns></returns>
  10818. [HttpPost]
  10819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10820. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  10821. {
  10822. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  10823. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10824. return Ok(JsonView(true, res.Msg, res.Data));
  10825. }
  10826. /// <summary>
  10827. /// 酒店询价
  10828. /// Del
  10829. /// </summary>
  10830. /// <param name="_dto"></param>
  10831. /// <returns></returns>
  10832. [HttpPost]
  10833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10834. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  10835. {
  10836. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  10837. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10838. return Ok(JsonView(true, res.Msg, res.Data));
  10839. }
  10840. #endregion
  10841. #region 下载匹配op行程单
  10842. /// <summary>
  10843. /// 匹配op行程单
  10844. /// Init
  10845. /// </summary>
  10846. /// <param name="dto">团组列表请求dto</param>
  10847. /// <returns></returns>
  10848. [HttpPost]
  10849. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10850. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  10851. {
  10852. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10853. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10854. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  10855. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  10856. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  10857. .Where(it => it.IsDel == 0)
  10858. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  10859. .OrderByDescending(it => it.CreateUserId)
  10860. .ToList();
  10861. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  10862. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  10863. var diids = groupInfos.Select(it => it.Id).ToList();
  10864. List<string> countrys = new List<string>();
  10865. foreach (var item in country)
  10866. {
  10867. var data = _groupRepository.FormartTeamName(item);
  10868. var dataArray = _groupRepository.GroupSplitCountry(data);
  10869. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  10870. }
  10871. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  10872. List<string> areaArray = new List<string>(); //GetGroupCityLine
  10873. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  10874. foreach (var item in areaItem)
  10875. {
  10876. string areaStr = item.Value;
  10877. if (!string.IsNullOrEmpty(areaStr))
  10878. {
  10879. string[] str1 = areaStr.Split("-");
  10880. if (str1.Length > 0)
  10881. {
  10882. areaArray.AddRange(str1);
  10883. }
  10884. }
  10885. }
  10886. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  10887. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  10888. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  10889. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  10890. .ToList();
  10891. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  10892. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  10893. .Where(it => countriesIds.Contains(it.Id))
  10894. .Select(it => new { it.Id, Name = it.Name_CN })
  10895. .ToList();
  10896. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  10897. .Select(it => it.TeamName).ToList();
  10898. stopwatch.Stop();
  10899. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  10900. }
  10901. ///// <summary>
  10902. ///// 匹配op行程单
  10903. ///// Init 查询区域数据
  10904. ///// </summary>
  10905. ///// <param name="dto">团组列表请求dto</param>
  10906. ///// <returns></returns>
  10907. //[HttpPost]
  10908. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10909. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  10910. //{
  10911. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10912. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  10913. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  10914. // if (string.IsNullOrEmpty(countriesDataStr))
  10915. // {
  10916. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  10917. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  10918. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  10919. // }
  10920. // else
  10921. // {
  10922. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  10923. // }
  10924. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  10925. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  10926. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  10927. // List<dynamic> childList = new List<dynamic>();
  10928. // int parentId = dto.CountriesId;
  10929. // if (provinceData.Count > 1)
  10930. // {
  10931. // foreach (var item1 in provinceData)
  10932. // {
  10933. // List<dynamic> childList1 = new List<dynamic>();
  10934. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  10935. // foreach (var item2 in citiesData1)
  10936. // {
  10937. // List<dynamic> childList2 = new List<dynamic>();
  10938. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10939. // foreach (var item3 in countiesData1)
  10940. // {
  10941. // childList2.Add(new
  10942. // {
  10943. // id = item3.Id,
  10944. // parentId = item2.Id,
  10945. // level = "district",
  10946. // name = item3.Name_CN,
  10947. // });
  10948. // }
  10949. // childList1.Add(new
  10950. // {
  10951. // id = item2.Id,
  10952. // parentId = item1.Id,
  10953. // level = "city",
  10954. // name = item2.Name_CN,
  10955. // childList = childList2
  10956. // });
  10957. // }
  10958. // childList.Add(new
  10959. // {
  10960. // id = item1.Id,
  10961. // parentId = parentId,
  10962. // level = "province",
  10963. // name = item1.Name_CN,
  10964. // childList = childList1
  10965. // });
  10966. // }
  10967. // //城市
  10968. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  10969. // foreach (var item2 in citiesData2)
  10970. // {
  10971. // List<dynamic> childList22 = new List<dynamic>();
  10972. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10973. // foreach (var item3 in countiesData1)
  10974. // {
  10975. // childList22.Add(new
  10976. // {
  10977. // id = item3.Id,
  10978. // parentId = item2.Id,
  10979. // level = "district",
  10980. // name = item3.Name_CN,
  10981. // });
  10982. // }
  10983. // childList.Add(new
  10984. // {
  10985. // id = item2.Id,
  10986. // parentId = parentId,
  10987. // level = "city",
  10988. // name = item2.Name_CN,
  10989. // childList = childList22
  10990. // });
  10991. // }
  10992. // }
  10993. // else
  10994. // {
  10995. // foreach (var item2 in citiesData)
  10996. // {
  10997. // string cname = item2.Name_CN;
  10998. // List<dynamic> childList1 = new List<dynamic>();
  10999. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11000. // foreach (var item3 in countiesData1)
  11001. // {
  11002. // childList1.Add(new
  11003. // {
  11004. // Id = item3.Id,
  11005. // parentId = item2.Id,
  11006. // level = "district",
  11007. // name = item3.Name_CN
  11008. // });
  11009. // }
  11010. // childList.Add(new
  11011. // {
  11012. // id = item2.Id,
  11013. // parentId = parentId,
  11014. // level = "city",
  11015. // name = item2.Name_CN,
  11016. // childList = childList1
  11017. // });
  11018. // }
  11019. // }
  11020. // stopwatch.Stop();
  11021. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  11022. //}
  11023. /// <summary>
  11024. /// 匹配op行程单
  11025. /// 接团信息列表 Page
  11026. /// </summary>
  11027. /// <param name="dto">团组列表请求dto</param>
  11028. /// <returns></returns>
  11029. [HttpPost]
  11030. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11031. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  11032. {
  11033. var swatch = new Stopwatch();
  11034. swatch.Start();
  11035. #region 参数验证
  11036. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11037. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11038. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11039. #region 页面操作权限验证
  11040. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11041. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  11042. #endregion
  11043. #endregion
  11044. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11045. {
  11046. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  11047. string sqlWhere = "";
  11048. if (!string.IsNullOrEmpty(dto.Country))
  11049. {
  11050. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  11051. }
  11052. if (!string.IsNullOrEmpty(dto.Area))
  11053. {
  11054. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  11055. }
  11056. if (!string.IsNullOrEmpty(dto.TeamName))
  11057. {
  11058. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  11059. }
  11060. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  11061. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  11062. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  11063. swatch.Stop();
  11064. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  11065. }
  11066. else
  11067. {
  11068. return Ok(JsonView(false, "查询失败"));
  11069. }
  11070. }
  11071. /// <summary>
  11072. /// 匹配op行程单
  11073. /// 行程单下载
  11074. /// </summary>
  11075. /// <param name="dto">团组列表请求dto</param>
  11076. /// <returns></returns>
  11077. [HttpPost]
  11078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11079. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  11080. {
  11081. #region 参数验证
  11082. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11083. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11084. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11085. #region 页面操作权限验证
  11086. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11087. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  11088. #endregion
  11089. #endregion
  11090. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11091. {
  11092. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  11093. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  11094. }
  11095. else
  11096. {
  11097. return Ok(JsonView(false, "下载失败!"));
  11098. }
  11099. }
  11100. #endregion
  11101. #region 国家信息 数据 注释
  11102. //[HttpPost]
  11103. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  11104. //{
  11105. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  11106. // foreach (var item in dto)
  11107. // {
  11108. // infos.Add(new Grp_GroupsTaskAssignment()
  11109. // {
  11110. // DIId = item,
  11111. // CTId = 82,
  11112. // UId = 248,
  11113. // IsEnable = 1,
  11114. // CreateUserId = 233,
  11115. // CreateTime = DateTime.Now,
  11116. // IsDel = 0
  11117. // });
  11118. // infos.Add(new Grp_GroupsTaskAssignment()
  11119. // {
  11120. // DIId = item,
  11121. // CTId = 82,
  11122. // UId = 286,
  11123. // IsEnable = 1,
  11124. // CreateUserId = 233,
  11125. // CreateTime = DateTime.Now,
  11126. // IsDel = 0
  11127. // });
  11128. // }
  11129. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  11130. // return Ok("操作成功");
  11131. //}
  11132. //public class paramJsonDto
  11133. //{
  11134. // public List<CountriesInfo> str { get; set; }
  11135. //}
  11136. //[HttpPost]
  11137. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  11138. //{
  11139. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  11140. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  11141. // List<Sys_Cities> cities = new List<Sys_Cities>();
  11142. // List<Sys_Cities> districts = new List<Sys_Cities>();
  11143. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11144. // _sqlSugar.BeginTran();
  11145. // int countitiesIndex = 0;
  11146. // foreach (var item in dto.str)
  11147. // {
  11148. // dynamic data = item.c;
  11149. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  11150. // if (data != null)
  11151. // {
  11152. // countitiesIndex++;
  11153. // foreach (var item1 in data)
  11154. // {
  11155. // string cnname = item1.cn;
  11156. // string enname = item1.en;
  11157. // Sys_Cities provinceInfo = new Sys_Cities()
  11158. // {
  11159. // CountriesId = countriesId,
  11160. // Name_CN = cnname,
  11161. // Name_EN = enname,
  11162. // ParentId = 0,
  11163. // IsCapital = 1,
  11164. // CreateUserId = 208,
  11165. // CreateTime = DateTime.Now,
  11166. // IsDel = 0
  11167. // };
  11168. // if (item1.lv == "province") //省份
  11169. // {
  11170. // provinceInfo.Level = 1;
  11171. // int provinceId = 0;
  11172. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  11173. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  11174. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  11175. // var data1 = item1.c;
  11176. // foreach (var item2 in data1)
  11177. // {
  11178. // if (item2.lv == "city")
  11179. // {
  11180. // string citycnname = item2.cn;
  11181. // string cityenname = item2.en;
  11182. // Sys_Cities cityInfo = new Sys_Cities()
  11183. // {
  11184. // CountriesId = countriesId,
  11185. // ParentId = provinceId,
  11186. // Level = 2,
  11187. // Name_CN = citycnname,
  11188. // Name_EN = cityenname,
  11189. // IsCapital = 1,
  11190. // CreateUserId = 208,
  11191. // CreateTime = DateTime.Now,
  11192. // IsDel = 0
  11193. // };
  11194. // if (item2.c != null)
  11195. // {
  11196. // int cityId = 0;
  11197. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  11198. // if (citiesInfo != null) cityId = citiesInfo.Id;
  11199. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  11200. // foreach (var item3 in item2.c)
  11201. // {
  11202. // if (item3.lv == "district")
  11203. // {
  11204. // var districtInfo = new Sys_Cities()
  11205. // {
  11206. // CountriesId = countriesId,
  11207. // Name_CN = item3.cn,
  11208. // Name_EN = item3.en,
  11209. // Level = 3,
  11210. // ParentId = cityId,
  11211. // IsCapital = 1,
  11212. // CreateUserId = 208,
  11213. // CreateTime = DateTime.Now,
  11214. // IsDel = 0
  11215. // };
  11216. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  11217. // //{
  11218. // districts.Add(districtInfo);
  11219. // //}
  11220. // }
  11221. // }
  11222. // }
  11223. // else
  11224. // {
  11225. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  11226. // //{
  11227. // cities.Add(cityInfo);
  11228. // //}
  11229. // }
  11230. // }
  11231. // }
  11232. // }
  11233. // else if (item1.lv == "city")//城市
  11234. // {
  11235. // provinceInfo.Level = 2;
  11236. // if (item1.c != null)
  11237. // {
  11238. // int cityId = 0;
  11239. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  11240. // if (citiesInfo != null) cityId = citiesInfo.Id;
  11241. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  11242. // foreach (var item3 in item1.c)
  11243. // {
  11244. // if (item3.lv == "district")
  11245. // {
  11246. // var districtInfo = new Sys_Cities()
  11247. // {
  11248. // CountriesId = countriesId,
  11249. // Name_CN = item3.cn,
  11250. // Name_EN = item3.en,
  11251. // Level = 3,
  11252. // ParentId = cityId,
  11253. // IsCapital = 1,
  11254. // CreateUserId = 208,
  11255. // CreateTime = DateTime.Now,
  11256. // IsDel = 0
  11257. // };
  11258. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  11259. // //{
  11260. // districts.Add(districtInfo);
  11261. // //}
  11262. // }
  11263. // }
  11264. // }
  11265. // else
  11266. // {
  11267. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  11268. // //{
  11269. // cities.Add(provinceInfo);
  11270. // //}
  11271. // }
  11272. // }
  11273. // }
  11274. // }
  11275. // }
  11276. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  11277. // cities = cities.Distinct().ToList();
  11278. // districts = districts.Distinct().ToList();
  11279. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  11280. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  11281. // cities.AddRange(districts);
  11282. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  11283. // //_sqlSugar.RollbackTran();
  11284. // _sqlSugar.CommitTran();
  11285. // return Ok(JsonView(false, "操作成功!"));
  11286. //}
  11287. //[HttpPost]
  11288. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  11289. //{
  11290. // List<CountitiesInfo> infos = dto.MyProperty;
  11291. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  11292. // _sqlSugar.BeginTran();
  11293. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11294. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  11295. // foreach (var item in infos)
  11296. // {
  11297. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  11298. // if (countryInfo != null)
  11299. // {
  11300. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  11301. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  11302. // if (cityInfo1 != null)
  11303. // {
  11304. // cityInfo1.IsCapital = 0;
  11305. // cityInfos.Add(cityInfo1);
  11306. // }
  11307. // }
  11308. // }
  11309. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  11310. // .UpdateColumns(it => it.IsCapital)
  11311. // .WhereColumns(it => it.Id)
  11312. // .ExecuteCommand();
  11313. // //_sqlSugar.RollbackTran();
  11314. // _sqlSugar.CommitTran();
  11315. // return Ok(JsonView(false, "操作成功!"));
  11316. //}
  11317. //public class CounrtiesDto
  11318. //{
  11319. // public List<CountitiesInfo> MyProperty { get; set; }
  11320. //}
  11321. //public class CountitiesInfo
  11322. //{
  11323. // /// <summary>
  11324. // /// 圣约翰
  11325. // /// </summary>
  11326. // public string capital_name_chinese { get; set; }
  11327. // /// <summary>
  11328. // ///
  11329. // /// </summary>
  11330. // public string capital_name { get; set; }
  11331. // /// <summary>
  11332. // ///
  11333. // /// </summary>
  11334. // public string country_type { get; set; }
  11335. // /// <summary>
  11336. // /// 安提瓜和巴布达
  11337. // /// </summary>
  11338. // public string country_name_chinese { get; set; }
  11339. // /// <summary>
  11340. // /// 安提瓜和巴布达
  11341. // /// </summary>
  11342. // public string country_name_chinese_short { get; set; }
  11343. // /// <summary>
  11344. // /// 安提瓜和巴布达
  11345. // /// </summary>
  11346. // public string country_name_chinese_UN { get; set; }
  11347. // /// <summary>
  11348. // ///
  11349. // /// </summary>
  11350. // public string country_name_english_abbreviation { get; set; }
  11351. // /// <summary>
  11352. // ///
  11353. // /// </summary>
  11354. // public string country_name_english_formal { get; set; }
  11355. // /// <summary>
  11356. // ///
  11357. // /// </summary>
  11358. // public string country_name_english_UN { get; set; }
  11359. // /// <summary>
  11360. // ///
  11361. // /// </summary>
  11362. // public string continent_name { get; set; }
  11363. // /// <summary>
  11364. // ///
  11365. // /// </summary>
  11366. // public string subregion_name { get; set; }
  11367. // /// <summary>
  11368. // ///
  11369. // /// </summary>
  11370. // public string country_code2 { get; set; }
  11371. // /// <summary>
  11372. // ///
  11373. // /// </summary>
  11374. // public string country_code3 { get; set; }
  11375. // /// <summary>
  11376. // ///
  11377. // /// </summary>
  11378. // public string phone_code { get; set; }
  11379. //}
  11380. //public class CountriesInfo : BasicInfo
  11381. //{
  11382. // public List<CitiesInfo> c { get; set; }
  11383. //}
  11384. //public class CitiesInfo : BasicInfo
  11385. //{
  11386. // public List<AreaInfo> c { get; set; }
  11387. //}
  11388. //public class AreaInfo : BasicInfo
  11389. //{
  11390. // public List<AreaInfo> c { get; set; }
  11391. //}
  11392. //public class BasicInfo
  11393. //{
  11394. // public string code { get; set; }
  11395. // public string cn { get; set; }
  11396. // public string lv { get; set; }
  11397. // public string en { get; set; }
  11398. //}
  11399. #endregion
  11400. #region 查看邀请方
  11401. /// <summary>
  11402. /// 查看邀请方
  11403. /// 邀请方信息 Init
  11404. /// </summary>
  11405. /// <param name="dto"></param>
  11406. /// <returns></returns>
  11407. [HttpPost]
  11408. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11409. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  11410. {
  11411. string sqlWhere = string.Empty;
  11412. if (!string.IsNullOrEmpty(dto.Search))
  11413. {
  11414. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  11415. }
  11416. string sql = string.Format($@"Select
  11417. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  11418. Id,
  11419. UnitName
  11420. From Res_InvitationOfficialActivityData
  11421. Where IsDel = 0
  11422. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  11423. RefAsync<int> total = 0;
  11424. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11425. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  11426. }
  11427. /// <summary>
  11428. /// 查看邀请方
  11429. /// 国家信息 Init
  11430. /// </summary>
  11431. /// <param name="dto"></param>
  11432. /// <returns></returns>
  11433. [HttpPost]
  11434. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11435. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  11436. {
  11437. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  11438. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  11439. var diids = groupInfos.Select(it => it.Id).ToList();
  11440. List<string> countrys = new List<string>();
  11441. foreach (var item in country)
  11442. {
  11443. var data = _groupRepository.FormartTeamName(item);
  11444. var dataArray = _groupRepository.GroupSplitCountry(data);
  11445. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  11446. }
  11447. countrys = countrys.Distinct().ToList();
  11448. for (int i = 0; i < countrys.Count; i++)
  11449. {
  11450. string item = countrys[i];
  11451. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  11452. {
  11453. countrys.Remove(item);
  11454. i--;
  11455. }
  11456. }
  11457. RefAsync<int> total = 0;
  11458. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  11459. .Where(it => countrys.Contains(it.Name_CN))
  11460. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  11461. .Select(it => new { id = it.Id, name = it.Name_CN })
  11462. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11463. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  11464. }
  11465. /// <summary>
  11466. /// 查看邀请方
  11467. /// 城市信息 Init
  11468. /// </summary>
  11469. /// <param name="dto"></param>
  11470. /// <returns></returns>
  11471. [HttpPost]
  11472. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11473. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  11474. {
  11475. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  11476. RefAsync<int> total = 0;
  11477. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  11478. .Where(it => it.CountriesId == dto.CountiesId)
  11479. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  11480. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  11481. .Select(it => new { id = it.Id, name = it.Name_CN })
  11482. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11483. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  11484. }
  11485. /// <summary>
  11486. /// 查看邀请方
  11487. /// 团组名称 Init
  11488. /// </summary>
  11489. /// <param name="dto"></param>
  11490. /// <returns></returns>
  11491. [HttpPost]
  11492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11493. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  11494. {
  11495. var watch = new Stopwatch();
  11496. watch.Start();
  11497. RefAsync<int> total = 0;
  11498. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  11499. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  11500. .Where((oa, di) => oa.IsDel == 0)
  11501. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  11502. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  11503. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  11504. .Distinct()
  11505. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11506. watch.Stop();
  11507. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  11508. }
  11509. /// <summary>
  11510. /// 查看邀请方
  11511. /// 团组 & 邀请方信息
  11512. /// </summary>
  11513. /// <param name="dto"></param>
  11514. /// <returns></returns>
  11515. [HttpPost]
  11516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11517. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  11518. {
  11519. var watch = new Stopwatch();
  11520. watch.Start();
  11521. RefAsync<int> total = 0;
  11522. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  11523. .AS("Grp_DelegationInfo")
  11524. .Includes(x => x.InvitingInfos)
  11525. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  11526. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  11527. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  11528. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  11529. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  11530. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  11531. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11532. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  11533. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  11534. infos.ForEach(x =>
  11535. {
  11536. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  11537. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  11538. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  11539. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  11540. });
  11541. watch.Stop();
  11542. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  11543. }
  11544. #endregion
  11545. #region 报批行程
  11546. /// <summary>
  11547. /// 报批行程初始化
  11548. /// </summary>
  11549. /// <param name="dto"></param>
  11550. /// <returns></returns>
  11551. [HttpPost]
  11552. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  11553. {
  11554. const int chiNumber = 5;
  11555. var jw = JsonView(false);
  11556. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  11557. var group = groupList.First();
  11558. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11559. group = groupList.First(x => x.Id == diid);
  11560. if (group == null)
  11561. {
  11562. jw.Msg = "暂无团组!";
  11563. return Ok(jw);
  11564. }
  11565. var data = new
  11566. {
  11567. groupList = groupList.Select(x => new
  11568. {
  11569. x.TeamName,
  11570. x.Id
  11571. }),
  11572. content = new ArrayList(),
  11573. groupInfo = new
  11574. {
  11575. group.VisitDays,
  11576. group.TourCode,
  11577. group.VisitPNumber,
  11578. group.TeamName,
  11579. group.Id,
  11580. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  11581. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  11582. },
  11583. };
  11584. var resultArr = new ArrayList();
  11585. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  11586. if (content.Count == 0)
  11587. {
  11588. var stay = "-";
  11589. var cityPath = "-";
  11590. //添加城市路径以及住宿地
  11591. //黑屏代码数据
  11592. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  11593. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  11594. {
  11595. jw = JsonView(true, "黑屏代码有误!", data);
  11596. return Ok(jw);
  11597. }
  11598. foreach (DataRow row in dtBlack.Rows)
  11599. {
  11600. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11601. {
  11602. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  11603. return Ok(jw);
  11604. }
  11605. }
  11606. //黑屏代码获取时间区间
  11607. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  11608. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11609. _sqlSugar.BeginTran();
  11610. for (int i = 0; i < timeArr.Count; i++)
  11611. {
  11612. stay = "-";
  11613. cityPath = "-";
  11614. DateTime NewData = DateTime.Parse(timeArr[i]);
  11615. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  11616. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  11617. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  11618. if (tbSelect.Length > 0)
  11619. {
  11620. List<string> threeCodeStr = new List<string>();
  11621. foreach (var item in tbSelect)
  11622. {
  11623. var threeCode = item["Three"].ToString() ?? "";
  11624. if (threeCode.Length == 6)
  11625. {
  11626. var start = threeCode.Substring(0, 3);
  11627. var end = threeCode.Substring(3, 3);
  11628. if (threeCodeStr.Count == 0)
  11629. {
  11630. threeCodeStr.Add(start);
  11631. threeCodeStr.Add(end);
  11632. }
  11633. else
  11634. {
  11635. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  11636. {
  11637. threeCodeStr.Add(end);
  11638. }
  11639. else
  11640. {
  11641. threeCodeStr.Add(start);
  11642. threeCodeStr.Add(end);
  11643. }
  11644. }
  11645. }
  11646. }
  11647. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  11648. var last = threeCodeStr.Last();
  11649. foreach (var item in threeCodeStr)
  11650. {
  11651. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  11652. if (item.Equals(last))
  11653. {
  11654. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  11655. }
  11656. }
  11657. cityPath = cityPath.Trim('-');
  11658. }
  11659. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  11660. appro.Diid = diid ?? -1;
  11661. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  11662. appro.Id = thisId;
  11663. appro.CreateUserId = dto.UserId;
  11664. appro.CreateTime = DateTime.Now;
  11665. content.Add(appro);
  11666. }
  11667. _sqlSugar.CommitTran();
  11668. }
  11669. foreach (var x in content)
  11670. {
  11671. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  11672. if (chiList.Count < chiNumber)
  11673. {
  11674. for (int i = chiList.Count; i < chiNumber; i++)
  11675. {
  11676. chiList.Add(new Grp_ApprovalTravelDetails());
  11677. }
  11678. }
  11679. resultArr.Add(new
  11680. {
  11681. x.Id,
  11682. x.Date,
  11683. x.Diid,
  11684. chiList = chiList.Select(x1 => new
  11685. {
  11686. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  11687. x1.Details,
  11688. x1.ParentId,
  11689. x1.Id
  11690. })
  11691. });
  11692. }
  11693. data = data with
  11694. {
  11695. content = resultArr,
  11696. };
  11697. jw = JsonView(true, "获取成功!", data);
  11698. return Ok(jw);
  11699. }
  11700. /// <summary>
  11701. /// 报批行程删除
  11702. /// </summary>
  11703. /// <param name="dto"></param>
  11704. /// <returns></returns>
  11705. [HttpPost]
  11706. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  11707. {
  11708. var jw = JsonView(false);
  11709. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11710. if (group == null)
  11711. {
  11712. jw.Msg = "团组参数有误!";
  11713. return Ok(jw);
  11714. }
  11715. try
  11716. {
  11717. _sqlSugar.BeginTran();
  11718. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  11719. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  11720. {
  11721. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11722. DeleteUserId = dto.uesrId,
  11723. IsDel = 1
  11724. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  11725. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  11726. {
  11727. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11728. DeleteUserId = dto.uesrId,
  11729. IsDel = 1
  11730. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  11731. _sqlSugar.CommitTran();
  11732. jw = JsonView(true, "删除成功");
  11733. }
  11734. catch (Exception ex)
  11735. {
  11736. jw = JsonView(false, ex.Message);
  11737. }
  11738. return Ok(jw);
  11739. }
  11740. /// <summary>
  11741. /// 报批行程保存
  11742. /// </summary>
  11743. /// <param name="dto"></param>
  11744. /// <returns></returns>
  11745. [HttpPost]
  11746. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  11747. {
  11748. var jw = JsonView(false);
  11749. var Find = dto.Arr.Find(x => x.id == 0);
  11750. if (Find != null)
  11751. {
  11752. jw.Msg = "生成的ID为0!";
  11753. return Ok(jw);
  11754. }
  11755. foreach (var item in dto.Arr)
  11756. {
  11757. foreach (var chi in item.chiList)
  11758. {
  11759. if (chi.parentId == 0)
  11760. {
  11761. chi.parentId = item.id;
  11762. }
  11763. }
  11764. }
  11765. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  11766. _sqlSugar.BeginTran();
  11767. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  11768. {
  11769. var parentIds = dto.Arr.Select(x => x.id).ToList();
  11770. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  11771. {
  11772. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11773. DeleteUserId = dto.UserId,
  11774. IsDel = 1
  11775. }).ExecuteCommand();
  11776. }
  11777. try
  11778. {
  11779. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  11780. {
  11781. CreateTime = DateTime.Now,
  11782. CreateUserId = dto.UserId,
  11783. Details = x.details,
  11784. ParentId = x.parentId,
  11785. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11786. Remark = "",
  11787. IsDel = 0
  11788. }).ToList()).ExecuteCommand();
  11789. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  11790. {
  11791. Id = x.id,
  11792. Details = x.details,
  11793. ParentId = x.parentId,
  11794. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11795. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  11796. {
  11797. Details = x.Details,
  11798. ParentId = x.ParentId,
  11799. Time = x.Time
  11800. }).ExecuteCommand();
  11801. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  11802. {
  11803. Id = x.id,
  11804. Date = x.date,
  11805. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  11806. {
  11807. Date = x.Date
  11808. }).ExecuteCommand();
  11809. _sqlSugar.CommitTran();
  11810. jw = JsonView(true, "保存成功!");
  11811. }
  11812. catch (Exception ex)
  11813. {
  11814. _sqlSugar.RollbackTran();
  11815. jw = JsonView(false, "保存失败!" + ex.Message);
  11816. }
  11817. return Ok(jw);
  11818. }
  11819. /// <summary>
  11820. /// 报批行程生成
  11821. /// </summary>
  11822. /// <param name="dto"></param>
  11823. /// <returns></returns>
  11824. [HttpPost]
  11825. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  11826. {
  11827. var jw = JsonView(false);
  11828. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11829. if (group == null)
  11830. {
  11831. jw.Msg = "暂无该团组!";
  11832. return Ok(jw);
  11833. }
  11834. //黑屏代码数据
  11835. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  11836. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  11837. {
  11838. jw.Msg = "黑屏代码有误!";
  11839. return Ok(jw);
  11840. }
  11841. foreach (DataRow row in dtBlack.Rows)
  11842. {
  11843. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11844. {
  11845. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  11846. return Ok(jw);
  11847. }
  11848. }
  11849. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11850. var resultArr = new ArrayList();
  11851. if (officialActivitiesArr.Count == 0)
  11852. {
  11853. jw.Msg = "暂无公务出访信息!";
  11854. return Ok(jw);
  11855. }
  11856. try
  11857. {
  11858. _sqlSugar.BeginTran();
  11859. DeleteApprovalJourney(new
  11860. Domain.Dtos.Groups.DeleteApprovalJourney
  11861. {
  11862. Diid = dto.Diid,
  11863. uesrId = dto.Userid
  11864. });
  11865. var stay = "-";
  11866. var cityPath = "-";
  11867. //添加城市路径以及住宿地
  11868. //黑屏代码获取时间区间
  11869. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  11870. var empty = "【未收入该三字码!请机票同事录入】";
  11871. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11872. for (int i = 0; i < timeArr.Count; i++)
  11873. {
  11874. stay = "-";
  11875. cityPath = "-";
  11876. var chiarr = new List<Grp_ApprovalTravelDetails>();
  11877. DateTime NewData = DateTime.Parse(timeArr[i]);
  11878. 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();
  11879. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  11880. if (tbSelect.Length > 0)
  11881. {
  11882. List<string> threeCodeStr = new List<string>();
  11883. bool isTrade = false;
  11884. string trip = string.Empty;
  11885. var rowLast = tbSelect.Last();
  11886. var rowFirst = tbSelect.First();
  11887. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  11888. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  11889. var takeOffTime = DateTime.Parse(timeArr[i]);
  11890. var fallToTime = DateTime.Parse(timeArr[i]);
  11891. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  11892. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  11893. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  11894. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  11895. foreach (var item in tbSelect)
  11896. {
  11897. var start = string.Empty;
  11898. var end = string.Empty;
  11899. var threeCode = item["Three"].ToString() ?? "";
  11900. if (threeCode.Length == 6)
  11901. {
  11902. start = threeCode.Substring(0, 3);
  11903. end = threeCode.Substring(3, 3);
  11904. if (threeCodeStr.Count == 0)
  11905. {
  11906. threeCodeStr.Add(start);
  11907. threeCodeStr.Add(end);
  11908. }
  11909. else
  11910. {
  11911. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  11912. {
  11913. threeCodeStr.Add(end);
  11914. }
  11915. else
  11916. {
  11917. threeCodeStr.Add(start);
  11918. threeCodeStr.Add(end);
  11919. }
  11920. }
  11921. }
  11922. //处理机票信息
  11923. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  11924. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  11925. if (start_Object == null)
  11926. {
  11927. start_Object = new Res_ThreeCode()
  11928. {
  11929. AirPort = empty,
  11930. AirPort_En = empty,
  11931. City = empty,
  11932. Country = empty,
  11933. Four = empty,
  11934. Three = empty,
  11935. };
  11936. }
  11937. if (end_Object == null)
  11938. {
  11939. end_Object = new Res_ThreeCode()
  11940. {
  11941. AirPort = empty,
  11942. AirPort_En = empty,
  11943. City = empty,
  11944. Country = empty,
  11945. Four = empty,
  11946. Three = empty,
  11947. };
  11948. }
  11949. //机型判断
  11950. string airModel = item["AirModel"].ToString();
  11951. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  11952. string flightTime = item["FlightTime"].ToString();
  11953. if (flightTime!.Contains(":"))
  11954. {
  11955. flightTime = flightTime.Replace(":", "小时");
  11956. flightTime += "分钟";
  11957. }
  11958. if (flightTime.Contains("H"))
  11959. {
  11960. flightTime = flightTime.Replace("H", "小时");
  11961. }
  11962. if (flightTime.Contains("M"))
  11963. {
  11964. flightTime = flightTime.Replace("M", "分钟");
  11965. }
  11966. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  11967. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  11968. {
  11969. flightTime = flightDataTime.Hour > 0
  11970. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  11971. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  11972. ? flightDataTime.Minute.ToString() + "分钟" : "";
  11973. }
  11974. //航班号
  11975. string flightcode = item["Fliagtcode"].ToString();
  11976. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  11977. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  11978. if (aircompany == null)
  11979. {
  11980. aircompany = new Res_AirCompany
  11981. {
  11982. CnName = hsEmpty,
  11983. EnName = hsEmpty,
  11984. ShortCode = hsEmpty,
  11985. };
  11986. }
  11987. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  11988. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  11989. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  11990. if (isTrade)
  11991. {
  11992. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  11993. }
  11994. else
  11995. {
  11996. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  11997. }
  11998. }
  11999. chiarr.Add(new Grp_ApprovalTravelDetails
  12000. {
  12001. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  12002. CreateTime = DateTime.Now,
  12003. CreateUserId = dto.Userid,
  12004. ParentId = 0,
  12005. Details = trip
  12006. });
  12007. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12008. var last = threeCodeStr.Last();
  12009. foreach (var item in threeCodeStr)
  12010. {
  12011. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12012. if (item.Equals(last))
  12013. {
  12014. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12015. }
  12016. }
  12017. cityPath = cityPath.Trim('-');
  12018. }
  12019. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12020. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12021. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12022. appro.Diid = dto.Diid;
  12023. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12024. appro.Id = thisId;
  12025. appro.CreateUserId = dto.Userid;
  12026. appro.CreateTime = DateTime.Now;
  12027. foreach (var item in gwinfo)
  12028. {
  12029. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  12030. chi.Details = "拜访" + item.Client;
  12031. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  12032. {
  12033. chi.Details += "," + item.ReqSample;
  12034. }
  12035. chi.ParentId = thisId;
  12036. chi.Time = item.Time;
  12037. chiarr.Add(chi);
  12038. }
  12039. if (chiarr.Count < 5)
  12040. {
  12041. for (int j = chiarr.Count; j < 5; j++)
  12042. {
  12043. chiarr.Add(new
  12044. Grp_ApprovalTravelDetails());
  12045. }
  12046. }
  12047. resultArr.Add(new
  12048. {
  12049. appro.Id,
  12050. appro.Date,
  12051. appro.Diid,
  12052. chiList = chiarr.Select(x1 => new
  12053. {
  12054. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12055. x1.Details,
  12056. x1.ParentId,
  12057. x1.Id
  12058. })
  12059. });
  12060. }
  12061. _sqlSugar.CommitTran();
  12062. jw = JsonView(true, "生成成功!", resultArr);
  12063. }
  12064. catch (Exception ex)
  12065. {
  12066. jw.Code = 400;
  12067. jw.Msg = "生成失败!" + ex.Message;
  12068. }
  12069. return Ok(jw);
  12070. }
  12071. /// <summary>
  12072. /// 报批行程word导出
  12073. /// </summary>
  12074. /// <param name="dto"></param>
  12075. /// <returns></returns>
  12076. [HttpPost]
  12077. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  12078. {
  12079. var jw = JsonView(false);
  12080. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12081. if (group == null)
  12082. {
  12083. jw.Msg = "暂无该团组!";
  12084. return Ok(jw);
  12085. }
  12086. //模板路径
  12087. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  12088. //载入模板
  12089. Document doc = new Document(tempPath);
  12090. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12091. //获取所填表格的序数
  12092. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12093. Aspose.Words.Tables.Row titleRowClone = null;
  12094. Aspose.Words.Tables.Row CenterRowClone = null;
  12095. int index = 0;
  12096. int indexChi = 0;
  12097. int SetIndex = 0;
  12098. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  12099. //获取数据,放到datatable
  12100. foreach (var item in ApprovalTravelArr)
  12101. {
  12102. if (index > 0)
  12103. {
  12104. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  12105. tableOne.AppendChild(titleRowClone);
  12106. }
  12107. var textTime = item.Date;
  12108. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  12109. SetCells(tableOne, doc, SetIndex, 0, textTime);
  12110. SetIndex++;
  12111. if (ChiRep.Count > 0)
  12112. {
  12113. foreach (var itemChi in ChiRep)
  12114. {
  12115. var txtTime = itemChi.Time;
  12116. var txtDetail = itemChi.Details;
  12117. if (indexChi > 0)
  12118. {
  12119. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12120. tableOne.AppendChild(CenterRowClone);
  12121. }
  12122. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  12123. {
  12124. SetCells(tableOne, doc, SetIndex, 0, "");
  12125. SetCells(tableOne, doc, SetIndex, 1, "");
  12126. indexChi++;
  12127. SetIndex++;
  12128. break;
  12129. }
  12130. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  12131. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  12132. indexChi++;
  12133. SetIndex++;
  12134. }
  12135. }
  12136. else
  12137. {
  12138. if (indexChi > 0)
  12139. {
  12140. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12141. tableOne.AppendChild(CenterRowClone);
  12142. }
  12143. SetCells(tableOne, doc, SetIndex, 0, "");
  12144. SetCells(tableOne, doc, SetIndex, 1, "");
  12145. indexChi++;
  12146. SetIndex++;
  12147. }
  12148. index++;
  12149. }
  12150. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  12151. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12152. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12153. jw.Code = 200;
  12154. jw.Msg = "";
  12155. return Ok(jw);
  12156. }
  12157. private string intToString(int numberVal)
  12158. {
  12159. string numberval = numberVal.ToString();
  12160. Dictionary<char, string> Number = new Dictionary<char, string>();
  12161. Number.Add('1', "一");
  12162. Number.Add('2', "二");
  12163. Number.Add('3', "三");
  12164. Number.Add('4', "四");
  12165. Number.Add('5', "五");
  12166. Number.Add('6', "六");
  12167. Number.Add('7', "七");
  12168. Number.Add('8', "八");
  12169. Number.Add('9', "九");
  12170. string stringNumberVal = string.Empty;
  12171. for (int i = 0; i < numberval.Length; i++)
  12172. {
  12173. if (i == 0)
  12174. {
  12175. stringNumberVal += Number[numberval[i]];
  12176. }
  12177. else if (i >= 1)
  12178. {
  12179. if (numberval[i] == '0')
  12180. {
  12181. stringNumberVal = "十";
  12182. }
  12183. else
  12184. {
  12185. stringNumberVal += "十" + Number[numberval[i]];
  12186. }
  12187. }
  12188. }
  12189. return stringNumberVal;
  12190. }
  12191. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  12192. {
  12193. //获取table中的某个单元格,从0开始
  12194. Cell lshCell = table.Rows[rows].Cells[cells];
  12195. //将单元格中段落移除
  12196. foreach (Node item in lshCell.Paragraphs)
  12197. {
  12198. lshCell.Paragraphs.Remove(item);
  12199. }
  12200. if (val.Contains("\r\n"))
  12201. {
  12202. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  12203. foreach (var item in spArr)
  12204. {
  12205. //新建一个段落
  12206. Paragraph p = new Paragraph(doc);
  12207. var r = new Run(doc, item);
  12208. //把设置的值赋给之前新建的段落
  12209. p.AppendChild(r);
  12210. //将此段落加到单元格内
  12211. lshCell.AppendChild(p);
  12212. }
  12213. }
  12214. else
  12215. {
  12216. //新建一个段落
  12217. Paragraph p = new Paragraph(doc);
  12218. var r = new Run(doc, val);
  12219. //把设置的值赋给之前新建的段落
  12220. p.AppendChild(r);
  12221. //将此段落加到单元格内
  12222. lshCell.AppendChild(p);
  12223. }
  12224. }
  12225. [HttpPost]
  12226. public async Task<IActionResult> ServerHttp(string paramStr)
  12227. {
  12228. paramStr = paramStr.TrimEnd('\'');
  12229. paramStr = paramStr.TrimStart('\'');
  12230. JsonView jw = JsonView(false);
  12231. JObject param = JObject.Parse(paramStr);
  12232. if (!param.ContainsKey("url"))
  12233. {
  12234. jw.Msg = "url null";
  12235. return Ok(jw);
  12236. }
  12237. string url = param["url"]!.ToString();
  12238. var methon = "get";
  12239. Dictionary<string, string> bodyValues = null;
  12240. Dictionary<string, string> headValues = null;
  12241. if (param.ContainsKey("methon"))
  12242. {
  12243. methon = param["methon"]!.ToString();
  12244. }
  12245. if (param.ContainsKey("header"))
  12246. {
  12247. var header = param["header"]!.ToString();
  12248. JObject headerJobject = JObject.Parse(header);
  12249. headValues = new Dictionary<string, string>();
  12250. foreach (JProperty item in headerJobject.Properties())
  12251. {
  12252. var value = item.Value.ToString();
  12253. var head = item.Path;
  12254. headValues.Add(head, value);
  12255. }
  12256. }
  12257. if (param.ContainsKey("body"))
  12258. {
  12259. var body = param["body"]!.ToString();
  12260. bodyValues = new Dictionary<string, string>();
  12261. JObject bodyJobject = JObject.Parse(body);
  12262. foreach (JProperty item in bodyJobject.Properties())
  12263. {
  12264. var value = item.Value.ToString();
  12265. var head = item.Path;
  12266. bodyValues.Add(head, value);
  12267. }
  12268. }
  12269. HttpClient client = new HttpClient();
  12270. string responseString = string.Empty;
  12271. if (param.ContainsKey("isJson"))
  12272. {
  12273. }
  12274. if (headValues != null)
  12275. {
  12276. foreach (var item in headValues.Keys)
  12277. {
  12278. client.DefaultRequestHeaders.Add(item, headValues[item]);
  12279. }
  12280. }
  12281. try
  12282. {
  12283. if (methon == "get")
  12284. {
  12285. responseString = await client.GetStringAsync(url);
  12286. }
  12287. else if (methon == "post")
  12288. {
  12289. if (bodyValues == null)
  12290. {
  12291. jw.Msg = "methon post body null";
  12292. return Ok(jw);
  12293. }
  12294. // 数据转化为 key=val 格式
  12295. var content = new FormUrlEncodedContent(bodyValues);
  12296. var response = await client.PostAsync(url, content);
  12297. // 获取数据
  12298. responseString = await response.Content.ReadAsStringAsync();
  12299. }
  12300. else
  12301. {
  12302. jw.Msg = "methon error";
  12303. }
  12304. jw = JsonView(true, "success", responseString);
  12305. }
  12306. catch (Exception ex)
  12307. {
  12308. jw.Msg = "error " + ex.Message;
  12309. jw.Data = ex.StackTrace;
  12310. }
  12311. finally
  12312. {
  12313. client.Dispose();
  12314. }
  12315. return Ok(jw);
  12316. }
  12317. #endregion
  12318. // /// <summary>
  12319. // ///
  12320. // /// </summary>
  12321. // /// <param name="_dto"></param>
  12322. // /// <returns></returns>
  12323. // [HttpPost]
  12324. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12325. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  12326. // {
  12327. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  12328. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  12329. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  12330. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  12331. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  12332. // dic_psg.Add("客人", 974);
  12333. // dic_psg.Add("司机", 975);
  12334. // dic_psg.Add("导游", 976);
  12335. // dic_psg.Add("公司内部人员", 977);
  12336. // dic_psg.Add("司机/导游/公司内部人员", 978);
  12337. // foreach (var item in list_visa)
  12338. // {
  12339. // Grp_VisaInfo temp = new Grp_VisaInfo();
  12340. // temp.Id = item.Id;
  12341. // temp.DIId = item.DIId;
  12342. // temp.VisaClient = item.VisaClient;
  12343. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  12344. // temp.VisaCurrency = item.VisaCurrency;
  12345. // temp.IsThird = item.IsThird;
  12346. // if (dic_psg.ContainsKey(item.PassengerType))
  12347. // {
  12348. // temp.PassengerType = dic_psg[item.PassengerType];
  12349. // }
  12350. // else {
  12351. // temp.PassengerType = -1;
  12352. // }
  12353. // temp.VisaNumber = item.VisaNumber;
  12354. // temp.VisaFreeNumber = item.VisaFreeNumber;
  12355. // temp.CreateUserId = item.Operators;
  12356. // DateTime dt_ct;
  12357. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  12358. // if (b_ct)
  12359. // {
  12360. // temp.CreateTime = dt_ct;
  12361. // }
  12362. // else
  12363. // {
  12364. // temp.CreateTime = DateTime.Now;
  12365. // }
  12366. // temp.DeleteTime = "";
  12367. // temp.DeleteUserId = 0;
  12368. // temp.Remark = item.Remark;
  12369. // if (string.IsNullOrEmpty(temp.Remark)) {
  12370. // temp.Remark = "";
  12371. // }
  12372. // temp.IsDel = item.IsDel;
  12373. // temp.VisaDescription = item.VisaAttachment;
  12374. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  12375. //([Id]
  12376. // ,[DIId]
  12377. // ,[VisaClient]
  12378. // ,[VisaPrice]
  12379. // ,[VisaCurrency]
  12380. // ,[IsThird]
  12381. // ,[PassengerType]
  12382. // ,[VisaNumber]
  12383. // ,[VisaFreeNumber]
  12384. // ,[CreateUserId]
  12385. // ,[CreateTime]
  12386. // ,[DeleteTime]
  12387. // ,[DeleteUserId]
  12388. // ,[Remark]
  12389. // ,[IsDel]
  12390. // ,[visaDescription])
  12391. // VALUES
  12392. // ({0},{1},'{2}',{3},{4}
  12393. //,{5},{6},{7},{8},{9}
  12394. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  12395. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  12396. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  12397. //);
  12398. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  12399. // }
  12400. // return Ok(JsonView(true, "操作成功!"));
  12401. // }
  12402. /// <summary>
  12403. /// 123132123
  12404. /// </summary>
  12405. /// <param name="_dto"></param>
  12406. /// <returns></returns>
  12407. [HttpPost]
  12408. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12409. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  12410. {
  12411. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  12412. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  12413. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  12414. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  12415. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  12416. dicDetail.Add(789, 1034);
  12417. dicDetail.Add(790, 1035);
  12418. dicDetail.Add(791, 1036);
  12419. dicDetail.Add(792, 1037);
  12420. dicDetail.Add(793, 1038);
  12421. dicDetail.Add(794, 1039);
  12422. dicDetail.Add(795, 1040);
  12423. dicDetail.Add(796, 1041);
  12424. dicDetail.Add(797, 1042);
  12425. dicDetail.Add(798, 1043);
  12426. dicDetail.Add(801, 1044);
  12427. dicDetail.Add(802, 1045);
  12428. dicDetail.Add(803, 1046);
  12429. Dictionary<int, int> dic = new Dictionary<int, int>();
  12430. dic.Add(806, 1027);
  12431. dic.Add(807, 1028);
  12432. dic.Add(808, 1029);
  12433. dic.Add(809, 1030);
  12434. dic.Add(810, 1031);
  12435. dic.Add(811, 1032);
  12436. dic.Add(812, 1033);
  12437. foreach (var item in list_visa)
  12438. {
  12439. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  12440. temp.Coefficient = item.coefficient;
  12441. DateTime dtCrt;
  12442. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  12443. if (b1)
  12444. {
  12445. temp.CreateTime = dtCrt;
  12446. }
  12447. else
  12448. {
  12449. temp.CreateTime = DateTime.Now;
  12450. }
  12451. temp.CreateUserId = item.Operators;
  12452. temp.DeleteTime = "";
  12453. temp.DeleteUserId = 0;
  12454. temp.DiId = int.Parse(item.DIID);
  12455. temp.FilePath = item.FilePath;
  12456. temp.IsDel = item.IsDel;
  12457. temp.Price = item.Price;
  12458. temp.PriceCount = 1;
  12459. temp.PriceCurrency = item.Currency;
  12460. int detailId = 0;
  12461. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  12462. {
  12463. detailId = dicDetail[item.PriceTypeDetail];
  12464. }
  12465. temp.PriceDetailType = detailId;
  12466. temp.PriceDt = DateTime.Now;
  12467. temp.PriceName = item.PriceName;
  12468. temp.PriceSum = item.Price;
  12469. int tid = 0;
  12470. if (dic.ContainsKey(item.PriceType))
  12471. {
  12472. tid = dic[item.PriceType];
  12473. }
  12474. temp.PriceType = tid;
  12475. temp.Remark = item.Remark;
  12476. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  12477. }
  12478. return Ok(JsonView(true, "操作成功!"));
  12479. }
  12480. }
  12481. }